Skip to content

Commit

Permalink
add test for portfolio value change
Browse files Browse the repository at this point in the history
  • Loading branch information
taveras committed Apr 17, 2024
1 parent 8287314 commit 5263355
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/edu/berkeley/aep/PortfolioTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,23 @@ public void shouldBeAbleToBuyStock() {
p.buyStock(company, 1);
assertEquals(50, p.currentValue());
}
@Test
public void currentValueShouldIncreaseWhenStockIncreases() {
Portfolio p = new Portfolio();
Stock company = new Stock("XYZ", 50);

p.buyStock(company, 1);
company.increasePrice(5);
assertEquals(55, p.currentValue());
}

@Test
public void currentValueShouldDecreaseWhenStockIncreases() {
Portfolio p = new Portfolio();
Stock company = new Stock("XYZ", 50);

p.buyStock(company, 1);
company.decreasePrice(5);
assertEquals(45, p.currentValue());
}
}

0 comments on commit 5263355

Please sign in to comment.