From 1ff57b71c3c37ac7d53b0245b1021d59d613dc69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20LAVERGNE?= Date: Sat, 18 May 2024 08:42:39 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20efonte=20des=20tests=20?= =?UTF-8?q?de=20Cellule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/Trek-12/Tests/CellTest.cs | 45 +++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/source/Trek-12/Tests/CellTest.cs b/source/Trek-12/Tests/CellTest.cs index 1533bba..2346c4a 100644 --- a/source/Trek-12/Tests/CellTest.cs +++ b/source/Trek-12/Tests/CellTest.cs @@ -4,10 +4,47 @@ using Models; public class CellTest { [Fact] - public void CellConstructorTest() + public void CellConstructor_SetsCorrectValues() { - Cell cell = new Cell(0, 0); - Assert.Equal(0, cell.Pos.X); - Assert.Equal(0,cell.Pos.Y); + var cell = new Cell(1, 2, true); + + Assert.Equal(1, cell.X); + Assert.Equal(2, cell.Y); + Assert.True(cell.GetCellType()); + } + + [Fact] + public void CellConstructor_SetsDefaultValues() + { + var cell = new Cell(1, 2); + + Assert.Equal(1, cell.X); + Assert.Equal(2, cell.Y); + Assert.False(cell.GetCellType()); + } + + [Fact] + public void ValueSetter_ThrowsException_WhenValueIsNegative() + { + var cell = new Cell(1, 2); + + Assert.Throws(() => cell.Value = -1); + } + + [Fact] + public void ValueSetter_SetsValue_WhenValueIsPositive() + { + var cell = new Cell(1, 2); + + cell.Value = 5; + + Assert.Equal(5, cell.Value); + } + + [Fact] + public void ValueSetter_SetsValue_WhenValueIsNull() + { + var cell = new Cell(1, 2); + Assert.Null(cell.Value); } } \ No newline at end of file