-
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.
Finnished Sale and Purchase, then added the last tests
- Loading branch information
Showing
16 changed files
with
232 additions
and
90 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Exceptions/InsufficientFunds.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,7 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42.Model.Exceptions; | ||
|
|
||
| public class InsufficientFunds extends RuntimeException { | ||
| public InsufficientFunds(String message) { | ||
| super(message); | ||
| } | ||
| } |
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
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
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
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
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
10 changes: 10 additions & 0 deletions
10
src/test/java/edu/ntnu/idi/idatt2003/gruppe42/MillionsTest.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 |
|---|---|---|
| @@ -1,2 +1,12 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| public class MillionsTest { | ||
| @Test | ||
| void mainTest() { | ||
| assertDoesNotThrow(() -> Millions.main(new String[]{})); | ||
| } | ||
| } |
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
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
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
61 changes: 61 additions & 0 deletions
61
src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/PlayerTest.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,61 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42.Model; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Exceptions.InsufficientFunds; | ||
| import java.math.BigDecimal; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| public class PlayerTest { | ||
| private Player player; | ||
|
|
||
| @BeforeEach | ||
| void setUp() { | ||
| player = new Player("John Doe", new BigDecimal("10000")); | ||
| } | ||
|
|
||
| @Test | ||
| void addMoneyTest() { | ||
| player.addMoney(new BigDecimal("5000")); | ||
| assertEquals(new BigDecimal("15000"), player.getMoney()); | ||
| } | ||
|
|
||
| @Test | ||
| void withdrawMoneyTest() { | ||
| player.withdrawMoney(new BigDecimal("5000")); | ||
| assertEquals(new BigDecimal("5000"), player.getMoney()); | ||
| } | ||
|
|
||
| @Test | ||
| void withdrawInsufficientFundsTest() { | ||
| assertThrows(InsufficientFunds.class, () -> player.withdrawMoney(new BigDecimal("15000"))); | ||
| } | ||
|
|
||
| @Test | ||
| void getNameTest() { | ||
| assertEquals("John Doe", player.getName()); | ||
| } | ||
|
|
||
| @Test | ||
| void getPortfolioTest() { | ||
| assertNotNull(player.getPortfolio()); | ||
| } | ||
|
|
||
| @Test | ||
| void getTransactionArchiveTest() { | ||
| assertNotNull(player.getTransactionArchive()); | ||
| } | ||
|
|
||
| @Test | ||
| void getMoneyTest() { | ||
| assertEquals(new BigDecimal("10000"), player.getMoney()); | ||
| } | ||
| @Test | ||
| void withdrawExactAmountTest() { | ||
| player.withdrawMoney(new BigDecimal("10000")); | ||
| assertEquals(BigDecimal.ZERO, player.getMoney()); | ||
| } | ||
| } |
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
20 changes: 20 additions & 0 deletions
20
src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/ShareTest.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,20 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42.Model; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| public class ShareTest { | ||
| @Test | ||
| void sharePropertiesTest() { | ||
| Stock stock = new Stock("AAPL", "Apple Inc.", new BigDecimal("100")); | ||
| BigDecimal quantity = new BigDecimal("10"); | ||
| BigDecimal purchasePrice = new BigDecimal("90"); | ||
| Share share = new Share(stock, quantity, purchasePrice); | ||
|
|
||
| assertEquals(stock, share.getStock()); | ||
| assertEquals(0, quantity.compareTo(share.getQuantity())); | ||
| assertEquals(0, purchasePrice.compareTo(share.getPurchasePrice())); | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockTest.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,27 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42.Model; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| public class StockTest { | ||
| @Test | ||
| void stockPropertiesTest() { | ||
| BigDecimal price = new BigDecimal("100"); | ||
| Stock stock = new Stock("AAPL", "Apple Inc.", price); | ||
|
|
||
| assertEquals("AAPL", stock.getSymbol()); | ||
| assertEquals("Apple Inc.", stock.getCompany()); | ||
| assertEquals(0, price.compareTo(stock.getSalesPrice())); | ||
| } | ||
|
|
||
| @Test | ||
| void addNewPriceTest() { | ||
| Stock stock = new Stock("AAPL", "Apple Inc.", new BigDecimal("100")); | ||
| BigDecimal newPrice = new BigDecimal("110"); | ||
| stock.addNewSalesPrices(newPrice); | ||
|
|
||
| assertEquals(0, newPrice.compareTo(stock.getSalesPrice())); | ||
| } | ||
| } |
Oops, something went wrong.