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.
sae201_qwirkle/Qwirkle/TestBase/TestCell.cs

73 lines
1.4 KiB

using QwirkleClassLibrary;
namespace TestBase;
public class TestCell
{
[Theory]
[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<ArgumentException>(() => new Cell(x, y));
return;
}
Cell c = new Cell(x, y);
Assert.Equal(x, c.GetX);
Assert.Equal(y, c.GetY);
}
public static IEnumerable<object[]> Data_Cell()
{
yield return new object[]
{
true,
new Cell(0,0),
new Tile(Shape.Round, Color.Red)
};
yield return new object[]
{
false,
new Cell(0,0),
new Tile(Shape.Round, Color.Red)
};
}
[Theory]
[MemberData(nameof(Data_Cell))]
public void Test_CellSetTile(bool except, Cell c, Tile t)
{
if (!except)
{
c.SetTile(t);
Assert.False(c.SetTile(t));
return;
}
Assert.True(c.SetTile(t));
}
[Theory]
[MemberData(nameof(Data_Cell))]
public void Test_IsFree(bool except, Cell c, Tile t)
{
if (except == false)
{
c.SetTile(t);
Assert.False(c.IsFree);
return;
}
Assert.True(c.IsFree);
}
}