added tests to configTest class to improve coverage
This commit is contained in:
parent
78fdb64bdf
commit
30635b4a21
1 changed files with 34 additions and 7 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package client.scenes;
|
package client.scenes;
|
||||||
|
|
||||||
import client.utils.Config;
|
import client.utils.Config;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -8,27 +9,30 @@ import java.util.ArrayList;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class ConfigTest {
|
public class ConfigTest {
|
||||||
|
private Config config;
|
||||||
|
|
||||||
private static final long FAV_LIST_ID_1 = 1234L;
|
private static final long FAV_LIST_ID_1 = 1234L;
|
||||||
private static final long FAV_LIST_ID_2 = 1235L;
|
private static final long FAV_LIST_ID_2 = 1235L;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp(){
|
||||||
|
config = new Config();
|
||||||
|
config.setLanguage("nl");
|
||||||
|
config.setServerUrl("http://localhost:8081");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void configDefaultValueTest(){
|
public void configDefaultValueTest(){
|
||||||
Config config = new Config();
|
|
||||||
|
|
||||||
assertEquals("en", config.getLanguage());
|
assertEquals("nl", config.getLanguage());
|
||||||
assertEquals("http://localhost:8080", config.getServerUrl());
|
assertEquals("http://localhost:8081", config.getServerUrl());
|
||||||
assertTrue(config.getFavourites().isEmpty());
|
assertTrue(config.getFavourites().isEmpty());
|
||||||
assertTrue(config.getShoppingList().isEmpty());
|
assertTrue(config.getShoppingList().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void configGetterTest(){
|
public void configGetterTest(){
|
||||||
Config config = new Config();
|
|
||||||
config.setLanguage("nl");
|
|
||||||
config.setServerUrl("http://localhost:8081");
|
|
||||||
|
|
||||||
ArrayList<String> x = new ArrayList<>();
|
ArrayList<String> x = new ArrayList<>();
|
||||||
x.add("Lava Cake");
|
x.add("Lava Cake");
|
||||||
x.add("Brownie");
|
x.add("Brownie");
|
||||||
|
|
@ -42,4 +46,27 @@ public class ConfigTest {
|
||||||
config.setShoppingList(x);
|
config.setShoppingList(x);
|
||||||
assertEquals(config.getShoppingList(), x);
|
assertEquals(config.getShoppingList(), x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isFavTest(){
|
||||||
|
assertFalse(config.isFavourite(FAV_LIST_ID_1)); //not yet fav
|
||||||
|
|
||||||
|
ArrayList<Long> y = new ArrayList<>();
|
||||||
|
y.add(FAV_LIST_ID_1);
|
||||||
|
config.setFavourites(y);
|
||||||
|
|
||||||
|
assertTrue(config.isFavourite(FAV_LIST_ID_1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void removeFavTest(){
|
||||||
|
ArrayList<Long> y = new ArrayList<>();
|
||||||
|
y.add(FAV_LIST_ID_1);
|
||||||
|
config.setFavourites(y);
|
||||||
|
|
||||||
|
assertTrue(config.isFavourite(FAV_LIST_ID_1));
|
||||||
|
|
||||||
|
config.removeFavourite(FAV_LIST_ID_1);
|
||||||
|
assertFalse(config.isFavourite(FAV_LIST_ID_1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue