parent
f7137a818b
commit
d7ab73eb1c
@ -0,0 +1,23 @@
|
|||||||
|
import data.StypeMap;
|
||||||
|
import data.StockType;
|
||||||
|
import data.Nyse;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
public class StypeMapTest {
|
||||||
|
private StypeMap stypemap;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void runBefore() {
|
||||||
|
stypemap = new StypeMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetStype() {
|
||||||
|
StockType stype = stypemap.getStype("Nyse");
|
||||||
|
assertEquals(stype.getName(), "NYSE");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
import data.WatchList;
|
||||||
|
import data.StypeMap;
|
||||||
|
import data.StockType;
|
||||||
|
import data.Nyse;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
public class WatchListTest {
|
||||||
|
private WatchList watchlist;
|
||||||
|
private StypeMap smap;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void runBefore() {
|
||||||
|
watchlist = new WatchList();
|
||||||
|
smap = new StypeMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddStock() {
|
||||||
|
StockType nyyyse = smap.getStype("Nyse");
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
watchlist.addStock(Integer.toString(i), nyyyse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSize() {
|
||||||
|
assertEquals(watchlist.size(), 0);
|
||||||
|
StockType nyyyse = smap.getStype("Nyse");
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
watchlist.addStock(Integer.toString(i), nyyyse);
|
||||||
|
}
|
||||||
|
assertEquals(watchlist.size(), 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDelStock() {
|
||||||
|
StockType nyyyse = smap.getStype("Nyse");
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
watchlist.addStock(Integer.toString(i), nyyyse);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 50; i++) {
|
||||||
|
watchlist.delStock(Integer.toString(i));
|
||||||
|
}
|
||||||
|
assertEquals(watchlist.size(), 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue