You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.5 KiB
82 lines
2.5 KiB
using CoreLibrary;
|
|
using Xunit;
|
|
|
|
namespace UnitTesting
|
|
{
|
|
public class CodeUT
|
|
{
|
|
[Fact]
|
|
public void TestFirstConstructorValidArguments()
|
|
{
|
|
Code code = new Code(4);
|
|
Assert.NotNull(code);
|
|
Assert.Equal(4, code.Jetons().Count());
|
|
Assert.Equal(0, code.NbJetons);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestConstructorInvalidArguments()
|
|
{
|
|
Assert.Throws<CodeTailleInvalideException>(() => new Code(0));
|
|
Assert.Throws<CodeTailleInvalideException>(() => new Code(-1));
|
|
}
|
|
|
|
[Fact]
|
|
public void TestSecondConstructorValidArguments()
|
|
{
|
|
Jeton[] jetons = [new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLEU)];
|
|
|
|
Code code = new Code(jetons);
|
|
Assert.NotNull(code);
|
|
Assert.Equal(3, code.Jetons().Count());
|
|
Assert.Equal(3, code.NbJetons);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestSecondConstructorInvalidArguments()
|
|
{
|
|
Assert.Throws<CodeTailleInvalideException>(() => new Code([]));
|
|
}
|
|
|
|
[Fact]
|
|
public void TestAjouterJetonValid()
|
|
{
|
|
Jeton jeton = new Jeton(Couleur.JAUNE);
|
|
Code code = new Code(3);
|
|
code.AjouterJeton(jeton);
|
|
Assert.Equal(1, code.NbJetons);
|
|
Assert.Equal(jeton, code.Jetons().ElementAt(0));
|
|
}
|
|
|
|
[Fact]
|
|
public void TestAjouterJetonInvalid()
|
|
{
|
|
Code code = new Code([new Jeton(Couleur.NOIR)]);
|
|
Assert.Throws<CodeTableauLesJetonsCompletException>(() => code.AjouterJeton(new Jeton(Couleur.ROUGE)));
|
|
}
|
|
|
|
[Fact]
|
|
public void TestSupprimerDernierJetonValid()
|
|
{
|
|
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
|
|
code.SupprimerDernierJeton();
|
|
Assert.Equal(2, code.NbJetons);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestSupprimerDernierJetonInvalid()
|
|
{
|
|
//Code code = new Code([]);
|
|
//Assert.Throws<CodeTableauLesJetonsVideException>(() => code.SupprimerDernierJeton());
|
|
Code code2 = new Code(4);
|
|
Assert.Throws<CodeTableauLesJetonsVideException>(() => code2.SupprimerDernierJeton());
|
|
}
|
|
|
|
[Fact]
|
|
public void TestRecupererJetonValid()
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|