-
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.
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/test/java/edu/ntnu/idi/idatt2003/gruppe42/ExchangeTest.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,48 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Exchange; | ||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Stock; | ||
| import java.math.BigDecimal; | ||
| import java.util.List; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| public class ExchangeTest { | ||
|
|
||
| private Exchange exchange; | ||
|
|
||
| @BeforeEach | ||
| public void setUp() { | ||
| Stock stock = new Stock("AAPL", "Apple Inc.", new BigDecimal("100")); | ||
| exchange = new Exchange("NYSE", List.of(stock)); | ||
| } | ||
|
|
||
| @Test | ||
| void findStocksTest() { | ||
| List<Stock> result = exchange.findStocks("Apple Inc."); | ||
|
|
||
| assertEquals(1, result.size()); | ||
| assertEquals("Apple Inc.", result.get(0).getCompany()); | ||
| } | ||
|
|
||
| @Test | ||
| void findStocksNullTest() { | ||
| List<Stock> result = exchange.findStocks("Google"); | ||
|
|
||
| assertTrue(result.isEmpty()); | ||
| } | ||
|
|
||
| @Test | ||
| void advanceTest() { | ||
| assertEquals(0, exchange.getWeek()); | ||
| exchange.advance(); | ||
|
|
||
| assertEquals(1, exchange.getWeek()); | ||
| exchange.advance(); | ||
|
|
||
| assertEquals(2, exchange.getWeek()); | ||
| } | ||
| } |