parent
69bf511fd2
commit
6b4cd4ebc9
@ -0,0 +1,45 @@
|
|||||||
|
package data;
|
||||||
|
|
||||||
|
import data.ListOfWatchList;
|
||||||
|
import data.WatchList;
|
||||||
|
import data.exceptions.*;
|
||||||
|
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;
|
||||||
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
|
public class ListOfWatchListTest {
|
||||||
|
private WatchList watchlist;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void runBefore() {
|
||||||
|
watchlist = new WatchList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void singletonCheck() {
|
||||||
|
assertTrue(ListOfWatchList.getList() == ListOfWatchList.getList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addDelWatchList() {
|
||||||
|
ListOfWatchList lowl = ListOfWatchList.getList();
|
||||||
|
lowl.addWatchList(watchlist);
|
||||||
|
assertEquals(watchlist, lowl.getWatchList(0));
|
||||||
|
lowl.addWatchList(watchlist);
|
||||||
|
assertEquals(watchlist, lowl.getWatchList(0));
|
||||||
|
try {
|
||||||
|
lowl.getWatchList(1);
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
// expected fail
|
||||||
|
}
|
||||||
|
lowl.delWatchList(watchlist);
|
||||||
|
try {
|
||||||
|
lowl.getWatchList(0);
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
// expected fail
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue