Skip to content

Commit

Permalink
Update PlayerTest.java
Browse files Browse the repository at this point in the history
  • Loading branch information
peretr authored Apr 10, 2026
1 parent 6a0165c commit a335692
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,10 @@ void withdrawExactAmountTest() {

@Test
void getNetworthTest() {
BigDecimal originalMoney = player.getMoney();
Portfolio portfolio = player.getPortfolio();

Share share = new Share(new Stock("AAPL", "Apple Inc.", new BigDecimal("276.43")), new BigDecimal("10"), new BigDecimal("50"));
portfolio.addShare(share);

player.getNetWorth();

assertEquals(originalMoney, player.getMoney());
// 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.00"), player.getNetWorth());
}
}

0 comments on commit a335692

Please sign in to comment.