diff --git a/source/Trek-12/Tests/BestScoreTests.cs b/source/Trek-12/Tests/BestScoreTests.cs new file mode 100644 index 0000000..7ddd806 --- /dev/null +++ b/source/Trek-12/Tests/BestScoreTests.cs @@ -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); + } + } +} diff --git a/source/Trek-12/Tests/CellTest.cs b/source/Trek-12/Tests/CellTests.cs similarity index 81% rename from source/Trek-12/Tests/CellTest.cs rename to source/Trek-12/Tests/CellTests.cs index 2346c4a..1d196f4 100644 --- a/source/Trek-12/Tests/CellTest.cs +++ b/source/Trek-12/Tests/CellTests.cs @@ -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(() => 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); } } \ No newline at end of file diff --git a/source/Trek-12/Tests/DiceTest.cs b/source/Trek-12/Tests/DiceTest.cs deleted file mode 100644 index b18d16a..0000000 --- a/source/Trek-12/Tests/DiceTest.cs +++ /dev/null @@ -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(d.Nb); - Assert.InRange(d.Nb, d.NbMin, d.NbMax); - } - - - - -} diff --git a/source/Trek-12/Tests/DiceTests.cs b/source/Trek-12/Tests/DiceTests.cs new file mode 100644 index 0000000..ab6aa14 --- /dev/null +++ b/source/Trek-12/Tests/DiceTests.cs @@ -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)); + } + +} diff --git a/source/Trek-12/Tests/MapTests.cs b/source/Trek-12/Tests/MapTests.cs new file mode 100644 index 0000000..0a7f3cf --- /dev/null +++ b/source/Trek-12/Tests/MapTests.cs @@ -0,0 +1,6 @@ +namespace Tests; + +public class MapTest +{ + +} \ No newline at end of file diff --git a/source/Trek-12/Tests/OperationCellTests.cs b/source/Trek-12/Tests/OperationCellTests.cs new file mode 100644 index 0000000..274e02d --- /dev/null +++ b/source/Trek-12/Tests/OperationCellTests.cs @@ -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); + } + } +} diff --git a/source/Trek-12/Tests/OperationGridTest.cs b/source/Trek-12/Tests/OperationGridTest.cs deleted file mode 100644 index 80f0692..0000000 --- a/source/Trek-12/Tests/OperationGridTest.cs +++ /dev/null @@ -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) - { - - } - } -} diff --git a/source/Trek-12/Tests/PlayerTest.cs b/source/Trek-12/Tests/PlayerTests.cs similarity index 96% rename from source/Trek-12/Tests/PlayerTest.cs rename to source/Trek-12/Tests/PlayerTests.cs index 0ff7ed9..05b0770 100644 --- a/source/Trek-12/Tests/PlayerTest.cs +++ b/source/Trek-12/Tests/PlayerTests.cs @@ -1,7 +1,7 @@ namespace Tests; using Models.Game; -public class PlayerTest +public class PlayerTests { [Fact] public void PlayerConstructorTest() diff --git a/source/Trek-12/Tests/testBestScore.cs b/source/Trek-12/Tests/testBestScore.cs deleted file mode 100644 index e78457a..0000000 --- a/source/Trek-12/Tests/testBestScore.cs +++ /dev/null @@ -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); - } - } -}