Modification de la classe ConditionClass en ConditionClassPersonnage, création d'une classe ConditionType et ajout de tests correspondants

This commit is contained in:
Paul Gross
2020-04-19 11:55:59 +02:00
parent fd3cf937c4
commit b6a1db9e3b
8 changed files with 242 additions and 61 deletions

View 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));
}
}