|
|
|
@ -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));
|
|
|
|
@ -96,7 +96,7 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestJetonsValid()
|
|
|
|
|
public void TestJetonsValide()
|
|
|
|
|
{
|
|
|
|
|
Jeton[] jetonsAttendus = [new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLEU)];
|
|
|
|
|
Code code = new Code(jetonsAttendus);
|
|
|
|
@ -113,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();
|
|
|
|
@ -121,7 +121,7 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestEstCompletInvalid()
|
|
|
|
|
public void TestEstCompletInvalide()
|
|
|
|
|
{
|
|
|
|
|
Code code = new Code(3);
|
|
|
|
|
bool estComplet = code.EstComplet();
|
|
|
|
@ -129,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);
|
|
|
|
|