diff --git a/Qwirkle/QwirkleClassLibrary/Cell.cs b/Qwirkle/QwirkleClassLibrary/Cell.cs index 9108fe5..4570e43 100644 --- a/Qwirkle/QwirkleClassLibrary/Cell.cs +++ b/Qwirkle/QwirkleClassLibrary/Cell.cs @@ -11,9 +11,9 @@ public class Cell public Cell(int x, int y) { - if (this.x < 0 || this.y < 0) + if (x < 0 || y < 0) { - throw new ArgumentException(""); + throw new ArgumentException(x.ToString() + y.ToString()); } this.x = x; diff --git a/Qwirkle/QwirkleClassLibrary/Game.cs b/Qwirkle/QwirkleClassLibrary/Game.cs index 4d32293..66dcb53 100644 --- a/Qwirkle/QwirkleClassLibrary/Game.cs +++ b/Qwirkle/QwirkleClassLibrary/Game.cs @@ -22,6 +22,7 @@ namespace QwirkleClassLibrary { board = new Board(); bag = new TileBag(3); + Console.Write(bag.TilesBag.Count); gameRunning = false; PlayerList = players.AsReadOnly(); } @@ -106,7 +107,9 @@ namespace QwirkleClassLibrary { for (int j = 0; j < 6; j++) { - Tile tile = bag.TilesBag[j]; + Random random = new Random(); + int val = random.Next(0, bag.TilesBag.Count); + Tile tile = bag.TilesBag[val]; players[i].AddTilePlayer(tile); bag.RemoveTileInBag(tile); } diff --git a/Qwirkle/TestBase/TestCell.cs b/Qwirkle/TestBase/TestCell.cs index 07cc6a3..33f1eba 100644 --- a/Qwirkle/TestBase/TestCell.cs +++ b/Qwirkle/TestBase/TestCell.cs @@ -4,18 +4,21 @@ namespace TestBase; public class TestCell { [Theory] - [InlineData(true, 10, 20, 10, 20)] - [InlineData(false, -10, 20, -10, 20)] - - public void Test_CellConstructor(bool isValid, int expectedX, int expectedY, int x, int y) + [InlineData(true, 10, 20)] + [InlineData(false, -10, -10)] + [InlineData(false, 10, -10)] + [InlineData(false, -10, 10)] + + public void Test_CellConstructor(bool isValid, int x, int y) { if (!isValid) { Assert.Throws(() => new Cell(x, y)); + return; } Cell c = new Cell(x, y); - Assert.Equal(expectedX, x); - Assert.Equal(expectedY, y); + Assert.Equal(x, c.GetX); + Assert.Equal(y, c.GetY); } } \ No newline at end of file diff --git a/Qwirkle/TestBase/UnitTest1.cs b/Qwirkle/TestBase/UnitTest1.cs index f00d528..a8c190e 100644 --- a/Qwirkle/TestBase/UnitTest1.cs +++ b/Qwirkle/TestBase/UnitTest1.cs @@ -39,5 +39,27 @@ namespace TestBase } Assert.True(r); } + + [Fact] + + public void Test_RemoveilePlayer() + { + Player p = new Player("cobaye"); + + Tile tile = new Tile(Shape.Round, Color.Orange); + + p.RemoveTilePlayer(tile); + + bool r = true; + + for (int i = 0; i < p.Tiles.Count; i++) + { + if (p.Tiles[i] == tile) + { + r = false; + } + } + Assert.True(r); + } } } \ No newline at end of file