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.
82 lines
1.8 KiB
82 lines
1.8 KiB
using QwirkleClassLibrary.Players;
|
|
using QwirkleClassLibrary.Tiles;
|
|
namespace TestBase;
|
|
|
|
public class TestPlayers
|
|
{
|
|
[Theory]
|
|
[InlineData(true, "Mathis")]
|
|
[InlineData(false, null)]
|
|
public void Test_CreatePlayer(bool isValid, string? playertag)
|
|
{
|
|
if (!isValid)
|
|
{
|
|
Assert.Throws<ArgumentNullException>(() => new Player(playertag!));
|
|
return;
|
|
}
|
|
Player player = new Player(playertag!);
|
|
Assert.Equal(playertag, player.NameTag);
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_EventPlayer()
|
|
{
|
|
Player player = new Player("jeje");
|
|
Tile tile = new(Shape.Club, Color.Red);
|
|
|
|
bool eventRaised = false;
|
|
|
|
player.PropertyChanged += (sender, args) =>
|
|
{
|
|
eventRaised = true;
|
|
};
|
|
|
|
player.AddTileToPlayer(tile);
|
|
|
|
Assert.True(eventRaised);
|
|
}
|
|
|
|
[Fact]
|
|
|
|
public void Test_AddTilePlayer()
|
|
{
|
|
Player p = new Player("cobaye");
|
|
|
|
Tile tile = new Tile(Shape.Round, Color.Orange);
|
|
|
|
p.AddTileToPlayer(tile);
|
|
|
|
bool r = false;
|
|
|
|
for(int i = 0; i < p.Tiles.Count; i++)
|
|
{
|
|
if (p.Tiles[i] == tile)
|
|
{
|
|
r = true;
|
|
}
|
|
}
|
|
Assert.True(r);
|
|
}
|
|
|
|
[Fact]
|
|
|
|
public void Test_RemoveilePlayer()
|
|
{
|
|
Player p = new Player("cobaye");
|
|
|
|
Tile tile = new Tile(Shape.Round, Color.Orange);
|
|
|
|
p.RemoveTileToPlayer(tile);
|
|
|
|
bool r = true;
|
|
|
|
for (int i = 0; i < p.Tiles.Count; i++)
|
|
{
|
|
if (p.Tiles[i] == tile)
|
|
{
|
|
r = false;
|
|
}
|
|
}
|
|
Assert.True(r);
|
|
}
|
|
} |