|
|
@ -149,6 +149,47 @@ namespace UnitTesting
|
|
|
|
Assert.False(estTerminee);
|
|
|
|
Assert.False(estTerminee);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void TestEstTermineeVictoire()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ReglesClassiques regles = new ReglesClassiques();
|
|
|
|
|
|
|
|
Partie partie = new Partie(regles);
|
|
|
|
|
|
|
|
Joueur joueur1 = regles.AjouterJoueur("joueur1");
|
|
|
|
|
|
|
|
Joueur joueur2 = regles.AjouterJoueur("joueur2");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
regles.CommencerLaPartie();
|
|
|
|
|
|
|
|
Plateau plateauj1 = regles.JoueurCourant().Plateau;
|
|
|
|
|
|
|
|
Type type = typeof(Plateau);
|
|
|
|
|
|
|
|
FieldInfo? fieldInfo = type.GetField("codeSecret", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
|
|
|
Assert.NotNull(fieldInfo);
|
|
|
|
|
|
|
|
Code? codeSecret = (Code?)fieldInfo.GetValue(plateauj1);
|
|
|
|
|
|
|
|
Assert.NotNull(codeSecret);
|
|
|
|
|
|
|
|
regles.JoueurCourant().Plateau.AjouterCode(codeSecret);
|
|
|
|
|
|
|
|
bool estTerminee = regles.EstTerminee();
|
|
|
|
|
|
|
|
Assert.True(estTerminee);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void TestEstTermineeToursMaximesAtteints()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ReglesClassiques regles = new ReglesClassiques();
|
|
|
|
|
|
|
|
Partie partie = new Partie(regles);
|
|
|
|
|
|
|
|
regles.AjouterJoueur("joueur1");
|
|
|
|
|
|
|
|
regles.AjouterJoueur("joueur2");
|
|
|
|
|
|
|
|
regles.CommencerLaPartie();
|
|
|
|
|
|
|
|
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC), new Jeton(Couleur.JAUNE)]);
|
|
|
|
|
|
|
|
for (int i = 1; i <= regles.TourMaximum*regles.NbJoueursMaximum; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
regles.JoueurCourant().Plateau.AjouterCode(code);
|
|
|
|
|
|
|
|
regles.PasserLaMain();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool estTerminee = regles.EstTerminee();
|
|
|
|
|
|
|
|
Assert.True(estTerminee);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestGagnantsAucunGagnants()
|
|
|
|
public void TestGagnantsAucunGagnants()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -162,5 +203,29 @@ namespace UnitTesting
|
|
|
|
Assert.Empty(gagnants);
|
|
|
|
Assert.Empty(gagnants);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void TestGagnantsGagnants()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ReglesClassiques regles = new ReglesClassiques();
|
|
|
|
|
|
|
|
Partie partie = new Partie(regles);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
regles.AjouterJoueur("joueur1");
|
|
|
|
|
|
|
|
regles.AjouterJoueur("joueur2");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
regles.CommencerLaPartie();
|
|
|
|
|
|
|
|
Plateau plateauj1 = regles.JoueurCourant().Plateau;
|
|
|
|
|
|
|
|
Type type = typeof(Plateau);
|
|
|
|
|
|
|
|
FieldInfo? fieldInfo = type.GetField("codeSecret", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
|
|
|
Assert.NotNull(fieldInfo);
|
|
|
|
|
|
|
|
Code? codeSecret = (Code?)fieldInfo.GetValue(plateauj1);
|
|
|
|
|
|
|
|
Assert.NotNull(codeSecret);
|
|
|
|
|
|
|
|
regles.JoueurCourant().Plateau.AjouterCode(codeSecret);
|
|
|
|
|
|
|
|
var resulta = regles.Gagnants();
|
|
|
|
|
|
|
|
Assert.Single(resulta);
|
|
|
|
|
|
|
|
Assert.Contains(regles.JoueurCourant(), resulta);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|