📝 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>
/// Lowest number on the dice.
/// </summary>
public int NbMin { get; private set; }
public int MinVal { get; private set; }
/// <summary>
/// Highest number on the dice.
/// </summary>
public int NbMax { get; private set; }
public int MaxVal { get; private set; }
/// <summary>
/// Value of the dice.
@ -29,9 +29,9 @@ namespace Models.Game
get => _value;
private set
{
if (value < NbMin || value > NbMax)
if (value < MinVal || value > MaxVal)
{
value = NbMin;
value = MinVal;
}
_value = value;
}
@ -40,13 +40,13 @@ namespace Models.Game
/// <summary>
/// Initializes a new instance of the <see cref="Dice"/> class.
/// </summary>
/// <param name="nbmin">The lowest number on the dice, on which the highest number is set</param>
public Dice(int nbmin)
/// <param name="minval">The lowest number on the dice, on which the highest number is set</param>
public Dice(int minval)
{
if (nbmin < 0) nbmin = 0;
if (nbmin > 1) nbmin = 1;
NbMin = nbmin;
NbMax = nbmin + 5;
if (minval < 0) minval = 0;
if (minval > 1) minval = 1;
MinVal = minval;
MaxVal = minval + 5;
}
/// <summary>
@ -54,13 +54,13 @@ namespace Models.Game
/// </summary>
public Dice()
{
NbMin = 0;
NbMax = 5;
MinVal = 0;
MaxVal = 5;
}
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>
@ -68,7 +68,7 @@ namespace Models.Game
/// </summary>
public void Roll()
{
Value = new Random().Next(NbMin, NbMax + 1);
Value = new Random().Next(MinVal, MaxVal + 1);
}
/// <summary>

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