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.
164 lines
3.6 KiB
164 lines
3.6 KiB
using QwirkleClassLibrary.Boards;
|
|
using QwirkleClassLibrary.Games;
|
|
using QwirkleClassLibrary.Players;
|
|
namespace TestBase;
|
|
|
|
public class TestGame
|
|
{
|
|
|
|
|
|
[Theory]
|
|
[InlineData(true, false, "testt")]
|
|
[InlineData(false, false, "testt")]
|
|
[InlineData(false, true, "testt")]
|
|
public void Test_GameAddPlayerIngame(bool result, bool gamestate, string p)
|
|
{
|
|
Game game = new Game();
|
|
|
|
if (!result)
|
|
{
|
|
game.AddPlayerInGame(p);
|
|
Assert.False(game.AddPlayerInGame(p));
|
|
}
|
|
else
|
|
{
|
|
Assert.True(game.AddPlayerInGame(p));
|
|
}
|
|
|
|
if (gamestate)
|
|
{
|
|
game.StartGame();
|
|
Assert.False(game.AddPlayerInGame(p));
|
|
}
|
|
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(false, null)]
|
|
[InlineData(true, "test")]
|
|
public void Test_GameAddPlayerIngame2(bool result, string p)
|
|
{
|
|
Game game = new Game();
|
|
|
|
if (!result)
|
|
{
|
|
Assert.False(game.AddPlayerInGame(p));
|
|
}
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
string name = p + i;
|
|
game.AddPlayerInGame(name);
|
|
}
|
|
Assert.False(game.AddPlayerInGame(p));
|
|
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("test")]
|
|
public void Test_GameCreatePlayers(string p)
|
|
{
|
|
Game game = new Game();
|
|
Player player = new Player(p);
|
|
Assert.Equal(game.CreatePlayer(p).NameTag, player.NameTag);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(true, "test1", "test2")]
|
|
[InlineData(false, "test1", "test2")]
|
|
public void Test_GameState(bool result, string p1, string p2)
|
|
{
|
|
Game game = new Game();
|
|
|
|
if (!result)
|
|
{
|
|
game.StartGame();
|
|
Assert.False(game.GameRunning);
|
|
}
|
|
game.AddPlayerInGame(p1);
|
|
game.AddPlayerInGame(p2);
|
|
game.StartGame();
|
|
|
|
Assert.True(game.GameRunning);
|
|
}
|
|
|
|
|
|
[Theory]
|
|
[InlineData(true, "test1", "test2", "test3")]
|
|
[InlineData(false, "test1", "test2", "test3")]
|
|
public void Test_GameGetPlayingPlayerPosition(bool result, string p1, string p2, string p3)
|
|
{
|
|
Game game = new Game();
|
|
game.AddPlayerInGame(p1);
|
|
game.AddPlayerInGame(p2);
|
|
game.AddPlayerInGame(p3);
|
|
|
|
if (!result)
|
|
{
|
|
Assert.Equal(-1, game.GetPlayingPlayerPosition());
|
|
return;
|
|
}
|
|
game.StartGame();
|
|
game.SetFirstPlayer();
|
|
Assert.Equal(0, game.GetPlayingPlayerPosition());
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(true)]
|
|
[InlineData(false)]
|
|
public void Test_GameGetPlaylingPlayer(bool result)
|
|
{
|
|
Game game = new Game();
|
|
game.AddPlayerInGame("patrick");
|
|
game.AddPlayerInGame("jean");
|
|
if (!result)
|
|
{
|
|
Assert.Throws<ArgumentException>(() => game.GetPlayingPlayer());
|
|
}
|
|
game.StartGame();
|
|
game.SetFirstPlayer();
|
|
|
|
Assert.Equal(game.PlayerList[0], game.GetPlayingPlayer());
|
|
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_BoardReturn()
|
|
{
|
|
Game game = new Game();
|
|
Assert.IsType<Board>(game.GetBoard());
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_EmptyCell()
|
|
{
|
|
Game game = new Game();
|
|
Board b = game.GetBoard();
|
|
Cell? c = b.GetCell(1, 1);
|
|
|
|
game.AddCellUsed(c);
|
|
|
|
game.EmptyCellUsed();
|
|
|
|
Assert.Empty(game.CellsUsed);
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_TileOfPlayer()
|
|
{
|
|
Game game = new Game();
|
|
game.AddPlayerInGame("Test1");
|
|
game.AddPlayerInGame("Test2");
|
|
|
|
game.StartGame();
|
|
game.SetFirstPlayer();
|
|
|
|
game.GiveTilesToPlayers();
|
|
|
|
Assert.Equal(game.PlayerList[0].Tiles[0], game.TileOfPlayerWithPos(0));
|
|
}
|
|
|
|
|
|
}
|
|
|