Merge pull request 'Classe "Dice": Optimisation, Traduction et requêtes LINQ' (#56) from diceClass into dev
continuous-integration/drone/push Build is failing Details

Reviewed-on: #56
pull/61/head
Rémi LAVERGNE 12 months ago
commit 60d384a97e

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Models.Game namespace Models.Game
{ {
public class De public class Dice
{ {
public int NbMin { get; private set; } public int NbMin { get; private set; }
@ -14,7 +14,7 @@ namespace Models.Game
public int Nb { get; private set; } public int Nb { get; private set; }
public De(int nbmin) public Dice(int nbmin)
{ {
if (nbmin < 0) nbmin = 0; if (nbmin < 0) nbmin = 0;
if (nbmin > 1) nbmin = 1; if (nbmin > 1) nbmin = 1;
@ -22,7 +22,7 @@ namespace Models.Game
NbMax = nbmin + 5; NbMax = nbmin + 5;
} }
public De() public Dice()
{ {
NbMin = 0; NbMin = 0;
NbMax = 5; NbMax = 5;
@ -38,10 +38,9 @@ namespace Models.Game
Nb = new Random().Next(NbMin, NbMax + 1); Nb = new Random().Next(NbMin, NbMax + 1);
} }
public bool IsLower(De de1) public bool IsLower(Dice dice2)
{ {
if (de1.Nb > this.Nb) return true; return dice2.Nb > this.Nb;
else return false;
} }
} }
} }

@ -7,12 +7,12 @@ using Models.Game;
namespace Tests; namespace Tests;
public class DeTest public class DiceTest
{ {
[Fact] [Fact]
public void TestConstructor() public void TestConstructor()
{ {
De d = new De(); Dice d = new Dice();
Assert.NotNull(d); Assert.NotNull(d);
Assert.Equal(0, d.NbMin); Assert.Equal(0, d.NbMin);
Assert.Equal(5, d.NbMax); Assert.Equal(5, d.NbMax);
@ -21,7 +21,7 @@ public class DeTest
[Fact] [Fact]
public void TestConstructorRebelotteWithInvalidNbMin() public void TestConstructorRebelotteWithInvalidNbMin()
{ {
De d = new De(2); Dice d = new Dice(2);
Assert.NotNull(d); Assert.NotNull(d);
Assert.Equal(1, d.NbMin); Assert.Equal(1, d.NbMin);
Assert.Equal(6, d.NbMax); Assert.Equal(6, d.NbMax);
@ -30,7 +30,7 @@ public class DeTest
[Fact] [Fact]
public void TestConstructorReRebelotteWithAnotherInvalidNbMin() public void TestConstructorReRebelotteWithAnotherInvalidNbMin()
{ {
De d = new De(-2); Dice d = new Dice(-2);
Assert.NotNull(d); Assert.NotNull(d);
Assert.Equal(0, d.NbMin); Assert.Equal(0, d.NbMin);
Assert.Equal(5, d.NbMax); Assert.Equal(5, d.NbMax);
@ -39,7 +39,7 @@ public class DeTest
[Fact] [Fact]
public void TestConstructorRebelotteWithValidNbMin() public void TestConstructorRebelotteWithValidNbMin()
{ {
De d = new De(1); Dice d = new Dice(1);
Assert.NotNull(d); Assert.NotNull(d);
Assert.Equal(1, d.NbMin); Assert.Equal(1, d.NbMin);
Assert.Equal(6, d.NbMax); Assert.Equal(6, d.NbMax);
@ -48,7 +48,7 @@ public class DeTest
[Fact] [Fact]
public void TestConstructorRebelotteWithAnotherValidNbMin() public void TestConstructorRebelotteWithAnotherValidNbMin()
{ {
De d = new De(0); Dice d = new Dice(0);
Assert.NotNull(d); Assert.NotNull(d);
Assert.Equal(0, d.NbMin); Assert.Equal(0, d.NbMin);
Assert.Equal(5, d.NbMax); Assert.Equal(5, d.NbMax);
@ -57,7 +57,7 @@ public class DeTest
[Fact] [Fact]
public void TestLancer() public void TestLancer()
{ {
De d = new De(); Dice d = new Dice();
Assert.NotNull(d); Assert.NotNull(d);
Assert.IsType<int>(d.Nb); Assert.IsType<int>(d.Nb);
Assert.InRange(d.Nb, d.NbMin, d.NbMax); Assert.InRange(d.Nb, d.NbMin, d.NbMax);
Loading…
Cancel
Save