-
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.
implement test for portfolio and fix small bug in Stock class
- Loading branch information
Showing
2 changed files
with
42 additions
and
1 deletion.
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
41 changes: 41 additions & 0 deletions
41
src/test/java/edu/ntnu/idi/idatt2003/gruppe42/PortfolioTest.java
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,41 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Portfolio; | ||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Share; | ||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Stock; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.math.BigDecimal; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| public class PortfolioTest { | ||
|
|
||
| @Test | ||
| public void addShareTest() { | ||
| Portfolio portfolio = new Portfolio(); | ||
| Stock stock = new Stock("AAPL", "Apple", new BigDecimal("10000")); | ||
| Share share = new Share(stock, new BigDecimal("10"), new BigDecimal("15000")); | ||
|
|
||
| boolean result = portfolio.addShare(share); | ||
| assertTrue(portfolio.contains(share)); | ||
| } | ||
|
|
||
| @Test | ||
| public void removeShareTest() { | ||
| Portfolio portfolio = new Portfolio(); | ||
| Stock stock = new Stock("AAPL", "Apple", new BigDecimal("10000")); | ||
| Share share = new Share(stock, new BigDecimal("10"), new BigDecimal("15000")); | ||
|
|
||
| portfolio.addShare(share); | ||
| boolean result = portfolio.removeShare(share); | ||
| assertFalse(portfolio.contains(share)); | ||
| } | ||
|
|
||
| @Test | ||
| void containsTest() { | ||
| Portfolio portfolio = new Portfolio(); | ||
| assertFalse(portfolio.contains(null)); | ||
| } | ||
| } |