Skip to content

Commit

Permalink
Merge pull request #63 from einaskoi/per/player/test
Browse files Browse the repository at this point in the history
add player getNetworthTest
  • Loading branch information
einaskoi authored Apr 9, 2026
2 parents 2d1286b + c48cca7 commit 80359ff
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class PurchaseCalculatorTest {

@BeforeEach
void setUp() {
// Setup test data
purchasePrice = new BigDecimal("100");
quantity = new BigDecimal("10");
Stock stock = new Stock("AAPL", "Apple Inc.", new BigDecimal("150"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class SaleCalculatorTest {

@BeforeEach
void setUp() {
// Setup test data
purchasePrice = new BigDecimal("100");
salesPrice = new BigDecimal("150");
quantity = new BigDecimal("10");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,14 @@ void withdrawExactAmountTest() {
player.withdrawMoney(new BigDecimal("10000"));
assertEquals(BigDecimal.ZERO, player.getMoney());
}

@Test
void getNetworthTest() {

// Starting with 10000 money and adding 5000 moneys worth of AAPL then calculating the networth
// with commissions taken account of will result in this:
// 10000 + 5000 - (5000 * 0.01) = 14950
player.getPortfolio().addShare(new Share(new Stock("AAPL", "Apple Inc.", new BigDecimal("5000")), new BigDecimal("1"), new BigDecimal("5000")));
assertEquals(new BigDecimal("14950"), player.getNetWorth());
}
}

0 comments on commit 80359ff

Please sign in to comment.