Skip to content

Commit

Permalink
Added ExchangeTest class
Browse files Browse the repository at this point in the history
  • Loading branch information
elisab3 committed Feb 25, 2026
1 parent 6992382 commit d379010
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 0 deletions.
Binary file modified target/classes/Exchange.class
Binary file not shown.
Binary file modified target/classes/Portfolio.class
Binary file not shown.
Binary file added target/classes/PurchaseCalculator.class
Binary file not shown.
Binary file modified target/classes/Share.class
Binary file not shown.
Binary file modified target/classes/Stock.class
Binary file not shown.
50 changes: 50 additions & 0 deletions target/test-classes/ExchangeTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import static org.junit.Assert.assertEquals;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import org.junit.Before;
import org.junit.Test;

public class ExchangeTest {

private Exchange exchange;
private Stock apple;
private Stock google;

@Before
public void setUp() {
apple = new Stock("AAPL", "Apple", new BigDecimal("100"));
google = new Stock("GOOGL", "Google", new BigDecimal("200"));

List<Stock> stocks = new ArrayList<>();
stocks.add(apple);
stocks.add(google);

exchange = new Exchange("ABC", stocks);
}

@Test
public void testFindStocksBySymbol() {
List<Stock> result = exchange.findStocks("AAPL");

assertEquals(1, result.size());
assertEquals("AAPL", result.get(0).getSymbol());
}

@Test
public void testFindStocksByCompanyNames() {
List<Stock> result = exchange.findStocks("e");

assertEquals(2, result.size());
}

@Test
public void testFindStocksNotInList() {
List<Stock> result = exchange.findStocks("Samsung");

assertEquals(0, result.size());
}

}

0 comments on commit d379010

Please sign in to comment.