code check
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
7d4fb356fd
commit
500a50ee71
@ -0,0 +1,127 @@
|
||||
using QwirkleClassLibrary;
|
||||
namespace TestBase;
|
||||
|
||||
public class TestGame
|
||||
{
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData(true, false, "testt")]
|
||||
[InlineData(false, false, "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)
|
||||
{
|
||||
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());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in new issue