fix of test by jules + random distribute

test_old_branch
Jérémy Mouyon 1 year ago
parent d9bf6cd72b
commit c55070be58

@ -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;

@ -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);
}

@ -4,18 +4,21 @@ namespace TestBase;
public class TestCell
{
[Theory]
[InlineData(true, 10, 20, 10, 20)]
[InlineData(false, -10, 20, -10, 20)]
[InlineData(true, 10, 20)]
[InlineData(false, -10, -10)]
[InlineData(false, 10, -10)]
[InlineData(false, -10, 10)]
public void Test_CellConstructor(bool isValid, int expectedX, int expectedY, int x, int y)
public void Test_CellConstructor(bool isValid, int x, int y)
{
if (!isValid)
{
Assert.Throws<ArgumentException>(() => 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);
}
}

@ -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);
}
}
}
Loading…
Cancel
Save