From 379c7095897a7bc9d7040b2b8ed372b2ab921460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20LAVERGNE?= Date: Tue, 28 May 2024 16:58:33 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20AjAjout=20de=20=20es=20tes?= =?UTF-8?q?ts=20sur=20les=20cellules=20adjacentes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/Trek-12/Tests/RulesTests.cs | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/source/Trek-12/Tests/RulesTests.cs b/source/Trek-12/Tests/RulesTests.cs index 2994420..3b6fe48 100644 --- a/source/Trek-12/Tests/RulesTests.cs +++ b/source/Trek-12/Tests/RulesTests.cs @@ -28,6 +28,16 @@ public class RulesTests Assert.False(rules.IsCellEmpty(cell)); } + [Fact] + public void IsCellValid_ReturnsFalse_WhenCellIsNotEmptyAndHasAdjacentCells() + { + Rules rules = new Rules(); + Map map = new Map("background"); + Cell selectedCell = map.Boards[0]; + selectedCell.Value = 5; + Assert.False(rules.IsCellValid(selectedCell, map.Boards)); + } + [Fact] public void IsCellValid_ReturnsTrue_WhenCellIsEmptyAndHasAdjacentCells() { @@ -36,4 +46,31 @@ public class RulesTests Cell selectedCell = map.Boards[0]; Assert.True(rules.IsCellValid(selectedCell, map.Boards)); } + + [Fact] + public void IsCellAdjacent_ReturnsFalse_WhenCellsAreNotAdjacent() + { + Rules rules = new Rules(); + Cell cell1 = new Cell(0, 0); + Cell cell2 = new Cell(2, 2); + Assert.False(rules.IsCellAdjacent(cell1, cell2)); + } + + [Fact] + public void IsCellAdjacent_ReturnsTrue_WhenCellsAreSideBySide() + { + Rules rules = new Rules(); + Cell cell1 = new Cell(0, 0); + Cell cell2 = new Cell(0, 1); + Assert.True(rules.IsCellAdjacent(cell1, cell2)); + } + + [Fact] + public void IsCellAdjacent_ReturnsTrue_WhenCellsAreDiagonal() + { + Rules rules = new Rules(); + Cell cell1 = new Cell(0, 0); + Cell cell2 = new Cell(1, 1); + Assert.True(rules.IsCellAdjacent(cell1, cell2)); + } } \ No newline at end of file