You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
2.7 KiB
133 lines
2.7 KiB
using QwirkleClassLibrary.Boards;
|
|
using QwirkleClassLibrary.Tiles;
|
|
using System.Collections.ObjectModel;
|
|
namespace TestBase;
|
|
|
|
public class TestBoard
|
|
{
|
|
public static IEnumerable<object[]> Data_Board()
|
|
{
|
|
yield return new object[]
|
|
{
|
|
true,
|
|
1,
|
|
2,
|
|
new Tile(Shape.Round, Color.Red)
|
|
};
|
|
yield return new object[]
|
|
{
|
|
false,
|
|
-5,
|
|
9999,
|
|
new Tile(Shape.Round, Color.Red)
|
|
};
|
|
}
|
|
|
|
[Theory]
|
|
[MemberData(nameof(Data_Board))]
|
|
public void Test_BoardAddSolo(bool except, int x, int y, Tile t)
|
|
{
|
|
|
|
Board b = new Board(12, 12);
|
|
|
|
if (!except)
|
|
{
|
|
Assert.False(b.AddTileInCell(x, y, t));
|
|
return;
|
|
|
|
}
|
|
Assert.True(b.AddTileInCell(x, y, t));
|
|
}
|
|
|
|
public static IEnumerable<object[]> Data_BoardDouble()
|
|
{
|
|
yield return new object[]
|
|
{
|
|
1,
|
|
2,
|
|
new Tile(Shape.Round, Color.Red)
|
|
};
|
|
}
|
|
|
|
[Theory]
|
|
[MemberData(nameof(Data_BoardDouble))]
|
|
public void Test_BoardFree(int x, int y, Tile t)
|
|
{
|
|
Board board = new Board(12, 12);
|
|
board.AddTileInCell(x, y, t);
|
|
Assert.False(board.AddTileInCell(x, y, t));
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_GetCells()
|
|
{
|
|
Board board = new Board(12, 12);
|
|
|
|
Assert.Equal((12 * 12), board.GetCells().Count);
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_GetReadCells()
|
|
{
|
|
Board board = new Board(12, 12);
|
|
|
|
List<Cell> cells = new List<Cell>();
|
|
|
|
for (int a = 0; a < 12; a++)
|
|
{
|
|
for (int b = 0; b < 12; b++)
|
|
{
|
|
Cell localcell = new(a, b);
|
|
cells.Add(localcell);
|
|
}
|
|
}
|
|
ReadOnlyCollection<Cell> readCells = cells.AsReadOnly();
|
|
|
|
Assert.Equal(readCells.Count, board.GetReadCells().Count);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(true)]
|
|
[InlineData(false)]
|
|
public void Test_GetOccupiedCase(bool except)
|
|
{
|
|
Board board = new Board(12, 12);
|
|
Tile tile = new Tile(Shape.Club, Color.Blue);
|
|
|
|
if (except)
|
|
{
|
|
board.AddTileInCell(1, 1, tile);
|
|
Assert.True(board.HasOccupiedCase());
|
|
return;
|
|
}
|
|
|
|
Assert.False(board.HasOccupiedCase());
|
|
return;
|
|
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(true)]
|
|
[InlineData(false)]
|
|
public void Test_GetCellPos(bool except)
|
|
{
|
|
Board board = new Board(12, 12);
|
|
|
|
if (except)
|
|
{
|
|
Cell? c = board.GetCell(1, 1);
|
|
Assert.Equal(board.GetCell(1,1), c);
|
|
return;
|
|
}
|
|
|
|
Assert.Null(board.GetCell(900, 900));
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|