|
|
|
@ -5,8 +5,14 @@ using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace UnitTesting
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class CodeUT
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestPremierConstructeurValide()
|
|
|
|
|
{
|
|
|
|
@ -18,12 +24,18 @@ namespace UnitTesting
|
|
|
|
|
Assert.True(code.Vide);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestPremierConstructeurInvalide()
|
|
|
|
|
{
|
|
|
|
|
Assert.Throws<TailleCodeException>(() => new Code(-1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestAjouterJetonValide()
|
|
|
|
|
{
|
|
|
|
@ -34,6 +46,9 @@ namespace UnitTesting
|
|
|
|
|
Assert.Equal(jeton, code.Jetons.ElementAt(0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestAjouterJetonInvalide()
|
|
|
|
|
{
|
|
|
|
@ -45,6 +60,9 @@ namespace UnitTesting
|
|
|
|
|
Assert.Throws<CodeCompletException>(() => code.AjouterJeton(new Jeton(Couleur.Rouge)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestSupprimerDernierJetonValide()
|
|
|
|
|
{
|
|
|
|
@ -57,6 +75,9 @@ namespace UnitTesting
|
|
|
|
|
Assert.Equal(2, code.Taille);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestSupprimerDernierJetonInvalide()
|
|
|
|
|
{
|
|
|
|
@ -64,6 +85,9 @@ namespace UnitTesting
|
|
|
|
|
Assert.Throws<CodeVideException>(() => code.SupprimerDernierJeton());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestRecupererJetonValide()
|
|
|
|
|
{
|
|
|
|
@ -77,6 +101,9 @@ namespace UnitTesting
|
|
|
|
|
Assert.Equal(jetonAttendu.Couleur, jeton.Couleur);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestRecupererJetonInvalide()
|
|
|
|
|
{
|
|
|
|
@ -85,6 +112,9 @@ namespace UnitTesting
|
|
|
|
|
Assert.Throws<IndiceCodeException>(() => code.RecupererJeton(4));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestRecupererJetonNull()
|
|
|
|
|
{
|
|
|
|
@ -92,6 +122,9 @@ namespace UnitTesting
|
|
|
|
|
Assert.Throws<IndiceCodeException>(() => code.RecupererJeton(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestJetonsValide()
|
|
|
|
|
{
|
|
|
|
@ -112,6 +145,9 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestEstCompletValide()
|
|
|
|
|
{
|
|
|
|
@ -124,6 +160,9 @@ namespace UnitTesting
|
|
|
|
|
Assert.True(estComplet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestEstCompletInvalide()
|
|
|
|
|
{
|
|
|
|
@ -132,6 +171,9 @@ namespace UnitTesting
|
|
|
|
|
Assert.False(estComplet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestTailleMaximaleValide()
|
|
|
|
|
{
|
|
|
|
@ -145,6 +187,9 @@ namespace UnitTesting
|
|
|
|
|
Assert.Equal(jetons.Length, tailleMaximale);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestComparerValide()
|
|
|
|
|
{
|
|
|
|
@ -165,6 +210,9 @@ namespace UnitTesting
|
|
|
|
|
Assert.Equal(3, indicateurs.Count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestComparerDifferent()
|
|
|
|
|
{
|
|
|
|
@ -185,6 +233,9 @@ namespace UnitTesting
|
|
|
|
|
Assert.Empty(indicateurs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestComparerMonCodeIncomplet()
|
|
|
|
|
{
|
|
|
|
@ -201,6 +252,9 @@ namespace UnitTesting
|
|
|
|
|
Assert.Empty(indicateurs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestComparerSonCodeIncomplet()
|
|
|
|
|
{
|
|
|
|
@ -215,6 +269,9 @@ namespace UnitTesting
|
|
|
|
|
Assert.Throws<CodeIncompletException>(() => code1.Comparer(code2));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestToString()
|
|
|
|
|
{
|
|
|
|
@ -227,6 +284,9 @@ namespace UnitTesting
|
|
|
|
|
Assert.Equal("Code(1)", code.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestComparerCodeInvalide()
|
|
|
|
|
{
|
|
|
|
@ -239,6 +299,9 @@ namespace UnitTesting
|
|
|
|
|
Assert.Throws<CodeInvalideException>(() => code.Comparer(code1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestComparerCodeCorrect()
|
|
|
|
|
{
|
|
|
|
|