-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Solveig Natvig
committed
Mar 24, 2026
1 parent
4b12887
commit ba8f76e
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| import java.math.BigDecimal; | ||
|
|
||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| public class PurchaseTest { | ||
| Stock stock; | ||
| Share share; | ||
| Purchase purchase; | ||
|
|
||
| @BeforeEach | ||
| void setUp() { | ||
| this.stock = new Stock("symbol", "company", new BigDecimal(100)); | ||
| this.share = new Share(this.stock, new BigDecimal(20), new BigDecimal(50)); | ||
| this.purchase = new Purchase(this.share, 18); | ||
| } | ||
|
|
||
| @Test | ||
| void commit_validPurchase_updatesPlayer() { | ||
|
|
||
| // Arrange | ||
| Player player = new Player("Jane", new BigDecimal(500000)); | ||
| BigDecimal startingMoney = player.getMoney(); | ||
|
|
||
| // Act | ||
| this.purchase.commit(player); | ||
|
|
||
| // Assert | ||
| assertEquals(1, startingMoney.subtract(player.getMoney()).signum()); | ||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
||
| } |