correction test
continuous-integration/drone/push Build is failing Details

master
parent 597a8b528c
commit 4ff70e4d51

@ -7,12 +7,17 @@
public int NbJetons { get; private set; } = 0;
public Code(int tailleCode)
{
{
if (tailleCode <= 0)
throw new CodeTailleInvalideException();
lesJetons = new Jeton?[tailleCode];
}
public Code(IEnumerable<Jeton> jetons)
{
if (!jetons.Any())
throw new CodeTailleInvalideException();
lesJetons = new Jeton?[jetons.Count()];
foreach(Jeton jeton in jetons)
AjouterJeton(jeton);
@ -31,7 +36,9 @@
if(NbJetons <= 0)
throw new CodeTableauLesJetonsVideException();
lesJetons[NbJetons--] = null;
}
public Jeton RecupererJeton(int indice)

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CoreLibrary
{
public class CodeTailleInvalideException : Exception
{
public CodeTailleInvalideException() : base("La taille du tableau de code est inférieure ou égale à 0")
{ }
}
}

@ -17,8 +17,8 @@ namespace UnitTesting
[Fact]
public void TestConstructorInvalidArguments()
{
Assert.Throws<ArgumentException>(() => new Code(0));
Assert.Throws<ArgumentException>(() => new Code(-1));
Assert.Throws<CodeTailleInvalideException>(() => new Code(0));
Assert.Throws<CodeTailleInvalideException>(() => new Code(-1));
}
[Fact]
@ -35,7 +35,7 @@ namespace UnitTesting
[Fact]
public void TestSecondConstructorInvalidArguments()
{
Assert.Throws<ArgumentException>(() => new Code([]));
Assert.Throws<CodeTailleInvalideException>(() => new Code([]));
}
[Fact]
@ -67,9 +67,9 @@ namespace UnitTesting
public void TestSupprimerDernierJetonInvalid()
{
Code code = new Code([]);
Assert.Throws<Exception>(() => code.SupprimerDernierJeton());
Assert.Throws<CodeTableauLesJetonsVideException>(() => code.SupprimerDernierJeton());
Code code2 = new Code(4);
Assert.Throws<Exception>(() => code2.SupprimerDernierJeton());
Assert.Throws<CodeTableauLesJetonsVideException>(() => code2.SupprimerDernierJeton());
}
[Fact]

Loading…
Cancel
Save