|
|
|
@ -7,7 +7,7 @@ namespace UnitTesting
|
|
|
|
|
public class CodeUT
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestFirstConstructorValidArguments()
|
|
|
|
|
public void TestPremierConstructeurValide()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code(4);
|
|
|
|
|
Assert.NotNull(code);
|
|
|
|
@ -16,14 +16,14 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestConstructorInvalidArguments()
|
|
|
|
|
public void TestPremierConstructeurInvalide()
|
|
|
|
|
{
|
|
|
|
|
Assert.Throws<TailleCodeException>(() => new Code(0));
|
|
|
|
|
Assert.Throws<TailleCodeException>(() => new Code(-1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestSecondConstructorValidArguments()
|
|
|
|
|
public void TestDeuxiemeConstructeurValide()
|
|
|
|
|
{
|
|
|
|
|
Jeton[] jetons = [new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLEU)];
|
|
|
|
|
|
|
|
|
@ -34,13 +34,13 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestSecondConstructorInvalidArguments()
|
|
|
|
|
public void TestDeuxiemeConstructeurInvalide()
|
|
|
|
|
{
|
|
|
|
|
Assert.Throws<TailleCodeException>(() => new Code([]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestAjouterJetonValid()
|
|
|
|
|
public void TestAjouterJetonValide()
|
|
|
|
|
{
|
|
|
|
|
Jeton jeton = new Jeton(Couleur.JAUNE);
|
|
|
|
|
Code code = new Code(3);
|
|
|
|
@ -50,14 +50,14 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestAjouterJetonInvalid()
|
|
|
|
|
public void TestAjouterJetonInvalide()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code([new Jeton(Couleur.NOIR)]);
|
|
|
|
|
Assert.Throws<CodeCompletException>(() => code.AjouterJeton(new Jeton(Couleur.ROUGE)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestSupprimerDernierJetonValid()
|
|
|
|
|
public void TestSupprimerDernierJetonValide()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
|
|
|
|
|
code.SupprimerDernierJeton();
|
|
|
|
@ -65,14 +65,14 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestSupprimerDernierJetonInvalid()
|
|
|
|
|
public void TestSupprimerDernierJetonInvalide()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code(4);
|
|
|
|
|
Assert.Throws<CodeVideException>(() => code.SupprimerDernierJeton());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestRecupererJetonValid()
|
|
|
|
|
public void TestRecupererJetonValide()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
|
|
|
|
|
Jeton jetonAttendu = new Jeton(Couleur.BLEU);
|
|
|
|
@ -81,7 +81,7 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestRecupererJetonInvalid()
|
|
|
|
|
public void TestRecupererJetonInvalide()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code(4);
|
|
|
|
|
Assert.Throws<IndiceCodeException>(() => code.RecupererJeton(-1));
|
|
|
|
@ -89,7 +89,14 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestJetonsValid()
|
|
|
|
|
public void TestRecupererJetonNull()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code(4);
|
|
|
|
|
Assert.Throws<IndiceCodeException>(() => code.RecupererJeton(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestJetonsValide()
|
|
|
|
|
{
|
|
|
|
|
Jeton[] jetonsAttendus = [new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLEU)];
|
|
|
|
|
Code code = new Code(jetonsAttendus);
|
|
|
|
@ -106,7 +113,7 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestEstCompletValid()
|
|
|
|
|
public void TestEstCompletValide()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
|
|
|
|
|
bool estComplet = code.EstComplet();
|
|
|
|
@ -114,7 +121,7 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestEstCompletInvalid()
|
|
|
|
|
public void TestEstCompletInvalide()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code(3);
|
|
|
|
|
bool estComplet = code.EstComplet();
|
|
|
|
@ -122,7 +129,7 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestTailleMaximaleValid()
|
|
|
|
|
public void TestTailleMaximaleValide()
|
|
|
|
|
{
|
|
|
|
|
Jeton[] jetons = [new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLEU)];
|
|
|
|
|
Code code = new Code(jetons);
|
|
|
|
@ -132,7 +139,7 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestComparerValid()
|
|
|
|
|
public void TestComparerValide()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
|
|
|
|
|
Code autreCode = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
|
|
|
|
@ -145,7 +152,7 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestComparerGoodPlace()
|
|
|
|
|
public void TestComparerBonnePlace()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
|
|
|
|
|
Code autreCode = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.NOIR)]);
|
|
|
|
@ -158,7 +165,7 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestComparerGoodColor()
|
|
|
|
|
public void TestComparerBonneCouleur()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
|
|
|
|
|
Code autreCode = new Code([new Jeton(Couleur.BLEU), new Jeton(Couleur.ROUGE), new Jeton(Couleur.NOIR)]);
|
|
|
|
@ -171,7 +178,7 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestComparerGoodPlaceAndColor()
|
|
|
|
|
public void TestComparerBonnePlaceEtCouleur()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
|
|
|
|
|
Code autreCode = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLANC), new Jeton(Couleur.BLEU)]);
|
|
|
|
@ -184,7 +191,7 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestComparerNoMatch()
|
|
|
|
|
public void TestComparerDifferent()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
|
|
|
|
|
Code autreCode = new Code([new Jeton(Couleur.VERT), new Jeton(Couleur.JAUNE), new Jeton(Couleur.NOIR)]);
|
|
|
|
@ -192,6 +199,27 @@ namespace UnitTesting
|
|
|
|
|
|
|
|
|
|
Assert.Empty(indicateurs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestComparerMonCodeIncomplet()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code(3);
|
|
|
|
|
Code autreCode = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
|
|
|
|
|
IEnumerable<Indicateur> indicateurs = code.Comparer(autreCode);
|
|
|
|
|
|
|
|
|
|
Assert.Empty(indicateurs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestComparerSonCodeIncomplet()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
|
|
|
|
|
Code autreCode = new Code(3);
|
|
|
|
|
IEnumerable<Indicateur> indicateurs = code.Comparer(autreCode);
|
|
|
|
|
|
|
|
|
|
Assert.Empty(indicateurs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|