Modification de la classe ConditionClass en ConditionClassPersonnage, création d'une classe ConditionType et ajout de tests correspondants
This commit is contained in:
62
tests/condition/ConditionClassPersonnageTest.java
Normal file
62
tests/condition/ConditionClassPersonnageTest.java
Normal file
@ -0,0 +1,62 @@
|
||||
package condition;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import main.Joueur;
|
||||
import personnage.Allie;
|
||||
import personnage.Bob;
|
||||
import personnage.CartePersonnage;
|
||||
import personnage.Daniel;
|
||||
|
||||
class ConditionClassPersonnageTest {
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void conditionClass_RenvoieAppartenancePersonnage() {
|
||||
|
||||
|
||||
List<Class<? extends CartePersonnage>> classes = new ArrayList<Class<? extends CartePersonnage>>();
|
||||
classes.add(Allie.class);
|
||||
classes.add(Daniel.class);
|
||||
ConditionClassPersonnage cc = new ConditionClassPersonnage(classes);
|
||||
|
||||
Joueur j = new Joueur(null);
|
||||
CartePersonnage cp1 = new Allie(null, 0, j);
|
||||
|
||||
|
||||
// Le personnage fait partie des classes.
|
||||
j.setCartePersonnage(cp1);
|
||||
assertTrue(cc.isTrue(j));
|
||||
|
||||
|
||||
CartePersonnage cp2 = new Bob(null, 0, j);
|
||||
// Le personnage ne fait pas partie des classes
|
||||
j.setCartePersonnage(cp2);
|
||||
assertFalse(cc.isTrue(j));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void conditionClass_ListClassVide_RenvoieFalse() {
|
||||
|
||||
|
||||
List<Class<? extends CartePersonnage>> classes = new ArrayList<Class<? extends CartePersonnage>>();
|
||||
|
||||
ConditionClassPersonnage cc = new ConditionClassPersonnage(classes);
|
||||
Joueur j = new Joueur(null);
|
||||
CartePersonnage cp1 = new Allie(null, 0, j);
|
||||
j.setCartePersonnage(cp1);
|
||||
assertFalse(cc.isTrue(j));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user