⚙️ Mise à jour des tests de BestScore

pull/67/head
Rémi LAVERGNE 11 months ago
parent 8681eded45
commit 10ba49c233

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models;
namespace Tests
{
public class BestScoreTests
{
[Fact]
public void Constructor_WithNegativeInputs_SetsPropertiesToZero()
{
var bestScore = new BestScore(-5, -10);
Assert.Equal(0, bestScore.GamesPlayed);
Assert.Equal(0, bestScore.Score);
}
[Fact]
public void Constructor_WithPositiveInputs_SetsPropertiesCorrectly()
{
var bestScore = new BestScore(5, 10);
Assert.Equal(5, bestScore.GamesPlayed);
Assert.Equal(10, bestScore.Score);
}
[Fact]
public void IncrGamesPlayed_IncrementsGamesPlayed()
{
var bestScore = new BestScore(0, 0);
bestScore.IncrGamesPlayed();
Assert.Equal(1, bestScore.GamesPlayed);
}
[Fact]
public void ScoreSetter_WithLowerValue_DoesNotChangeScore()
{
var bestScore = new BestScore(0, 10);
bestScore.UpdateScore(5);
Assert.Equal(10, bestScore.Score);
}
[Fact]
public void ScoreSetter_WithHigherValue_ChangesScore()
{
var bestScore = new BestScore(0, 5);
bestScore.UpdateScore(10);
Assert.Equal(10, bestScore.Score);
}
}
}

@ -6,7 +6,7 @@ public class CellTest
[Fact]
public void CellConstructor_SetsCorrectValues()
{
var cell = new Cell(1, 2, true);
Cell cell = new Cell(1, 2, true);
Assert.Equal(1, cell.X);
Assert.Equal(2, cell.Y);
@ -16,7 +16,7 @@ public class CellTest
[Fact]
public void CellConstructor_SetsDefaultValues()
{
var cell = new Cell(1, 2);
Cell cell = new Cell(1, 2);
Assert.Equal(1, cell.X);
Assert.Equal(2, cell.Y);
@ -26,7 +26,7 @@ public class CellTest
[Fact]
public void ValueSetter_ThrowsException_WhenValueIsNegative()
{
var cell = new Cell(1, 2);
Cell cell = new Cell(1, 2);
Assert.Throws<Exception>(() => cell.Value = -1);
}
@ -34,7 +34,7 @@ public class CellTest
[Fact]
public void ValueSetter_SetsValue_WhenValueIsPositive()
{
var cell = new Cell(1, 2);
Cell cell = new Cell(1, 2);
cell.Value = 5;
@ -44,7 +44,7 @@ public class CellTest
[Fact]
public void ValueSetter_SetsValue_WhenValueIsNull()
{
var cell = new Cell(1, 2);
Cell cell = new Cell(1, 2);
Assert.Null(cell.Value);
}
}

@ -1,69 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models.Game;
namespace Tests;
public class DiceTest
{
[Fact]
public void TestConstructor()
{
Dice d = new Dice();
Assert.NotNull(d);
Assert.Equal(0, d.NbMin);
Assert.Equal(5, d.NbMax);
}
[Fact]
public void TestConstructorRebelotteWithInvalidNbMin()
{
Dice d = new Dice(2);
Assert.NotNull(d);
Assert.Equal(1, d.NbMin);
Assert.Equal(6, d.NbMax);
}
[Fact]
public void TestConstructorReRebelotteWithAnotherInvalidNbMin()
{
Dice d = new Dice(-2);
Assert.NotNull(d);
Assert.Equal(0, d.NbMin);
Assert.Equal(5, d.NbMax);
}
[Fact]
public void TestConstructorRebelotteWithValidNbMin()
{
Dice d = new Dice(1);
Assert.NotNull(d);
Assert.Equal(1, d.NbMin);
Assert.Equal(6, d.NbMax);
}
[Fact]
public void TestConstructorRebelotteWithAnotherValidNbMin()
{
Dice d = new Dice(0);
Assert.NotNull(d);
Assert.Equal(0, d.NbMin);
Assert.Equal(5, d.NbMax);
}
[Fact]
public void TestLancer()
{
Dice d = new Dice();
Assert.NotNull(d);
Assert.IsType<int>(d.Nb);
Assert.InRange(d.Nb, d.NbMin, d.NbMax);
}
}

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models.Game;
namespace Tests;
public class DiceTest
{
[Fact]
public void Constructor_WithNegativeNbMin_SetsNbMinToZero()
{
Dice dice = new Dice(-1);
Assert.Equal(0, dice.NbMin);
}
[Fact]
public void Constructor_WithNbMinGreaterThanOne_SetsNbMinToOne()
{
Dice dice = new Dice(2);
Assert.Equal(1, dice.NbMin);
}
[Fact]
public void Constructor_WithValidNbMin_SetsNbMinAndNbMaxCorrectly()
{
Dice dice = new Dice(1);
Assert.Equal(1, dice.NbMin);
Assert.Equal(6, dice.NbMax);
}
[Fact]
public void DefaultConstructor_SetsNbMinToZeroAndNbMaxToFive()
{
Dice dice = new Dice();
Assert.Equal(0, dice.NbMin);
Assert.Equal(5, dice.NbMax);
}
[Fact]
public void Roll_SetsValueBetweenNbMinAndNbMax()
{
Dice dice = new Dice();
dice.Roll();
Assert.True(dice.Value >= dice.NbMin && dice.Value <= dice.NbMax);
}
[Fact]
public void IsLower_WhenOtherDiceHasHigherValue_ReturnsTrue()
{
Dice dice1 = new Dice();
Dice dice2 = new Dice();
dice1.Roll();
dice2.Roll();
while (dice1.Value >= dice2.Value)
{
dice2.Roll();
}
Assert.True(dice1.IsLower(dice2));
}
[Fact]
public void IsLower_WhenOtherDiceHasLowerValue_ReturnsFalse()
{
Dice dice1 = new Dice();
Dice dice2 = new Dice();
dice1.Roll();
dice2.Roll();
while (dice1.Value <= dice2.Value)
{
dice1.Roll();
}
Assert.False(dice1.IsLower(dice2));
}
}

@ -0,0 +1,6 @@
namespace Tests;
public class MapTest
{
}

@ -0,0 +1,27 @@
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tests
{
public class OperationCellTest
{
[Fact]
public void Constructor_WithValidCoordinates_SetsCoordinatesCorrectly()
{
OperationCell operationCell = new OperationCell(1, 2);
Assert.Equal(1, operationCell.X);
Assert.Equal(2, operationCell.Y);
}
[Fact]
public void Constructor_WithValidCoordinates_SetsIsCheckedToFalse()
{
OperationCell operationCell = new OperationCell(1, 2);
Assert.False(operationCell.IsChecked);
}
}
}

@ -1,21 +0,0 @@
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tests
{
public class OperationGridTest
{
public string Name = "toto";
[Theory]
[InlineData("toto")]
[InlineData(" ")]
public void testResultGrid(string name)
{
}
}
}

@ -1,7 +1,7 @@
namespace Tests;
using Models.Game;
public class PlayerTest
public class PlayerTests
{
[Fact]
public void PlayerConstructorTest()

@ -1,48 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models;
namespace Tests
{
public class testBestScore
{
[Fact]
public void TestCstor()
{
BestScore b = new BestScore(12, 456);
Assert.NotNull(b);
Assert.Equal(12, b.GamesPlayed);
Assert.Equal(456, b.Score);
}
[Fact]
public void TestCstorNotEqual()
{
BestScore b = new BestScore(15, 4656);
Assert.NotNull(b);
Assert.NotEqual(12, b.GamesPlayed);
Assert.NotEqual(456, b.Score);
}
[Fact]
public void TestIncr()
{
BestScore b = new BestScore(12, 456);
b.IncrGamesPlayed();
Assert.NotNull(b);
Assert.Equal(13, b.GamesPlayed);
}
[Fact]
public void TestNotNegative()
{
BestScore b = new BestScore(-4, -98);
Assert.NotNull(b);
Assert.Equal(0, b.GamesPlayed);
Assert.Equal(0, b.Score);
}
}
}
Loading…
Cancel
Save