M431-ShadowHunterGame/tests/condition/ConditionMultipleTest.java

121 lines
2.9 KiB
Java
Raw Permalink Normal View History

2020-04-17 12:27:52 +02:00
package condition;
2020-04-18 22:16:49 +02:00
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
2020-04-17 12:27:52 +02:00
2020-04-20 13:48:13 +02:00
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
2020-04-17 12:27:52 +02:00
import org.junit.jupiter.api.Test;
import main.Joueur;
2020-04-20 13:48:13 +02:00
import main.Plateau;
2020-04-17 12:27:52 +02:00
class ConditionMultipleTest {
2020-04-20 13:48:13 +02:00
Joueur joueur;
Plateau plateau;
@BeforeEach
void init()
{
List<Joueur> list = new ArrayList<Joueur>();
joueur = new Joueur("Jack");
list.add(joueur);
plateau = new Plateau(list);
joueur.setPlateau(plateau);
}
2020-04-17 12:27:52 +02:00
@Test
2020-04-20 13:48:13 +02:00
public void conditionMultiple_Vide_RenvoieTrue() throws Exception {
2020-04-17 12:27:52 +02:00
2020-04-20 13:48:13 +02:00
Condition condition = new ConditionMultiple(new ArrayList<Condition>());
2020-04-17 12:27:52 +02:00
2020-04-20 13:48:13 +02:00
assertTrue(condition.isTrue(joueur));
2020-04-17 12:27:52 +02:00
}
@Test
2020-04-20 13:48:13 +02:00
public void conditionMultipleOR_Vide_False() throws Exception {
Condition condition = new ConditionMultipleOR(new ArrayList<Condition>());
assertFalse(condition.isTrue(joueur));
}
@Test
public void conditionMultiple_AllTrue_True() throws Exception {
plateau.setStat("test", 20);
List<Condition> list = new ArrayList<Condition>();
for(int i = 0; i <= 20;i++)
{
ConditionStatistiques cs = new ConditionStatistiques(true,"test",20,ConditionStatistiques.EQUAL);
list.add(cs);
}
Condition condition = new ConditionMultiple(list);
assertTrue(condition.isTrue(joueur));
}
@Test
public void conditionMultiple_OneFalse_False() throws Exception {
plateau.setStat("test", 20);
List<Condition> list = new ArrayList<Condition>();
for(int i = 0; i <= 20;i++)
{
ConditionStatistiques cs = new ConditionStatistiques(true,"test",20,ConditionStatistiques.EQUAL);
list.add(cs);
}
// False one
ConditionStatistiques cs = new ConditionStatistiques(true,"test",30,ConditionStatistiques.EQUAL);
list.add(cs);
Condition condition = new ConditionMultiple(list);
assertFalse(condition.isTrue(joueur));
}
@Test
public void conditionMultiple_AllFalse_False() throws Exception {
plateau.setStat("test", 20);
List<Condition> list = new ArrayList<Condition>();
for(int i = 0; i <= 20;i++)
{
ConditionStatistiques cs = new ConditionStatistiques(true,"test",30,ConditionStatistiques.EQUAL);
list.add(cs);
}
Condition condition = new ConditionMultiple(list);
assertFalse(condition.isTrue(joueur));
}
@Test
public void conditionMultipleOR_OneFalse_True() throws Exception {
plateau.setStat("test", 20);
List<Condition> list = new ArrayList<Condition>();
for(int i = 0; i <= 20;i++)
{
ConditionStatistiques cs = new ConditionStatistiques(true,"test",20,ConditionStatistiques.EQUAL);
list.add(cs);
}
// False one
ConditionStatistiques cs = new ConditionStatistiques(true,"test",30,ConditionStatistiques.EQUAL);
list.add(cs);
2020-04-17 12:27:52 +02:00
2020-04-20 13:48:13 +02:00
Condition condition = new ConditionMultipleOR(list);
2020-04-17 12:27:52 +02:00
2020-04-20 13:48:13 +02:00
assertTrue(condition.isTrue(joueur));
2020-04-17 12:27:52 +02:00
}
2020-04-18 22:16:49 +02:00
2020-04-17 12:27:52 +02:00
}