Test Plateau
continuous-integration/drone/push Build is passing Details

master
Camille TURPIN-ETIENNE 11 months ago
parent 3cb4826ebd
commit 1ca07b1ba6

@ -501,7 +501,6 @@ namespace UnitTesting
[Fact] [Fact]
public void TestPartieTerminee() public void TestPartieTerminee()
{ {
// Création de la partie avec des règles de jeu
IRegles regle = new ReglesClassiques(); IRegles regle = new ReglesClassiques();
Partie partie = new Partie(regle); Partie partie = new Partie(regle);

@ -107,5 +107,77 @@ namespace UnitTesting
plateau.AjouterCode(codeSecret); plateau.AjouterCode(codeSecret);
Assert.True(plateau.Victoire); Assert.True(plateau.Victoire);
} }
[Fact]
public void TestGrilleAjouterCode()
{
Code code = new Code(4);
Couleur[] couleurs = Enum.GetValues<Couleur>();
Plateau plateau = new Plateau(4, 12);
Jeton[] jetons = new Jeton[]
{
new Jeton(Couleur.Rouge),
new Jeton(Couleur.Bleu),
new Jeton(Couleur.Blanc),
new Jeton(Couleur.Jaune)
};
code.AjouterJeton(jetons[0]);
code.AjouterJeton(jetons[1]);
code.AjouterJeton(jetons[2]);
code.AjouterJeton(jetons[3]);
plateau.AjouterCode(code);
(IEnumerable<IEnumerable<Jeton>>, IEnumerable<IEnumerable<Indicateur>>) grille = plateau.Grille;
var (jetonsGrille, indicateurs) = grille;
Assert.Single(jetonsGrille);
Assert.Equal(4, jetonsGrille.First().Count());
Assert.Single(indicateurs);
}
[Fact]
public void TestGrilleEstVide()
{
Plateau plateau = new Plateau(4, 12);
(IEnumerable<IEnumerable<Jeton>>, IEnumerable<IEnumerable<Indicateur>>) grille = plateau.Grille;
var (jetons, indicateurs) = grille;
Assert.Empty(jetons);
Assert.Empty(indicateurs);
}
[Fact]
public void AjouterCode_GrilleComplete_ThrowsGrilleCompleteException()
{
Plateau plateau = new Plateau(4, 2);
Code codeComplet1 = new Code(4);
Code codeComplet2 = new Code(4);
Code codeComplet3 = new Code(4);
Jeton[] jetons = new Jeton[]
{
new Jeton(Couleur.Rouge),
new Jeton(Couleur.Bleu),
new Jeton(Couleur.Blanc),
new Jeton(Couleur.Jaune)
};
foreach (Jeton jeton in jetons)
{
codeComplet1.AjouterJeton(jeton);
codeComplet2.AjouterJeton(jeton);
codeComplet3.AjouterJeton(jeton);
}
plateau.AjouterCode(codeComplet1);
plateau.AjouterCode(codeComplet2);
Assert.Throws<GrilleCompleteException>(() => plateau.AjouterCode(codeComplet3));
}
} }
} }

Loading…
Cancel
Save