📝 Traduction de propriétés pour les dés et traduction des tests
continuous-integration/drone/push Build is passing Details

pull/91/head
Rémi LAVERGNE 11 months ago
parent 170f002e14
commit 756764f8ce
No known key found for this signature in database
GPG Key ID: 7BCBAE9031E39160

@ -14,12 +14,12 @@ namespace Models.Game
/// <summary> /// <summary>
/// Lowest number on the dice. /// Lowest number on the dice.
/// </summary> /// </summary>
public int NbMin { get; private set; } public int MinVal { get; private set; }
/// <summary> /// <summary>
/// Highest number on the dice. /// Highest number on the dice.
/// </summary> /// </summary>
public int NbMax { get; private set; } public int MaxVal { get; private set; }
/// <summary> /// <summary>
/// Value of the dice. /// Value of the dice.
@ -29,9 +29,9 @@ namespace Models.Game
get => _value; get => _value;
private set private set
{ {
if (value < NbMin || value > NbMax) if (value < MinVal || value > MaxVal)
{ {
value = NbMin; value = MinVal;
} }
_value = value; _value = value;
} }
@ -40,13 +40,13 @@ namespace Models.Game
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Dice"/> class. /// Initializes a new instance of the <see cref="Dice"/> class.
/// </summary> /// </summary>
/// <param name="nbmin">The lowest number on the dice, on which the highest number is set</param> /// <param name="minval">The lowest number on the dice, on which the highest number is set</param>
public Dice(int nbmin) public Dice(int minval)
{ {
if (nbmin < 0) nbmin = 0; if (minval < 0) minval = 0;
if (nbmin > 1) nbmin = 1; if (minval > 1) minval = 1;
NbMin = nbmin; MinVal = minval;
NbMax = nbmin + 5; MaxVal = minval + 5;
} }
/// <summary> /// <summary>
@ -54,13 +54,13 @@ namespace Models.Game
/// </summary> /// </summary>
public Dice() public Dice()
{ {
NbMin = 0; MinVal = 0;
NbMax = 5; MaxVal = 5;
} }
public override string ToString() public override string ToString()
{ {
return $"Ce dé a pour valeur {Value} et est entre {NbMin} et {NbMax}"; return $"Ce dé a pour valeur {Value} et est entre {MinVal} et {MaxVal}";
} }
/// <summary> /// <summary>
@ -68,7 +68,7 @@ namespace Models.Game
/// </summary> /// </summary>
public void Roll() public void Roll()
{ {
Value = new Random().Next(NbMin, NbMax + 1); Value = new Random().Next(MinVal, MaxVal + 1);
} }
/// <summary> /// <summary>

@ -13,30 +13,30 @@ public class DiceTests
public void Constructor_WithNegativeNbMin_SetsNbMinToZero() public void Constructor_WithNegativeNbMin_SetsNbMinToZero()
{ {
Dice dice = new Dice(-1); Dice dice = new Dice(-1);
Assert.Equal(0, dice.NbMin); Assert.Equal(0, dice.MinVal);
} }
[Fact] [Fact]
public void Constructor_WithNbMinGreaterThanOne_SetsNbMinToOne() public void Constructor_WithNbMinGreaterThanOne_SetsNbMinToOne()
{ {
Dice dice = new Dice(2); Dice dice = new Dice(2);
Assert.Equal(1, dice.NbMin); Assert.Equal(1, dice.MinVal);
} }
[Fact] [Fact]
public void Constructor_WithValidNbMin_SetsNbMinAndNbMaxCorrectly() public void Constructor_WithValidNbMin_SetsNbMinAndNbMaxCorrectly()
{ {
Dice dice = new Dice(1); Dice dice = new Dice(1);
Assert.Equal(1, dice.NbMin); Assert.Equal(1, dice.MinVal);
Assert.Equal(6, dice.NbMax); Assert.Equal(6, dice.MaxVal);
} }
[Fact] [Fact]
public void DefaultConstructor_SetsNbMinToZeroAndNbMaxToFive() public void DefaultConstructor_SetsNbMinToZeroAndNbMaxToFive()
{ {
Dice dice = new Dice(); Dice dice = new Dice();
Assert.Equal(0, dice.NbMin); Assert.Equal(0, dice.MinVal);
Assert.Equal(5, dice.NbMax); Assert.Equal(5, dice.MaxVal);
} }
[Fact] [Fact]
@ -44,6 +44,6 @@ public class DiceTests
{ {
Dice dice = new Dice(); Dice dice = new Dice();
dice.Roll(); dice.Roll();
Assert.True(dice.Value >= dice.NbMin && dice.Value <= dice.NbMax); Assert.True(dice.Value >= dice.MinVal && dice.Value <= dice.MaxVal);
} }
} }

Loading…
Cancel
Save