...
continuous-integration/drone/push Build is passing Details

test_old_branch
Jérémy Mouyon 11 months ago
parent 617b9a9ce8
commit a82aa56f56

@ -58,6 +58,12 @@ namespace QwirkleClassLibrary.Games
/// <returns>boolean to check it</returns> /// <returns>boolean to check it</returns>
public bool AddPlayerInGame(List<string> PlayersTag) public bool AddPlayerInGame(List<string> PlayersTag)
{ {
if (GameRunning)
{
OnPlayerNotified(new AddPlayerNotifiedEventArgs("ERROR : The game is running."));
return false;
}
for (int i = PlayersTag.Count - 1; i >= 0; i--) for (int i = PlayersTag.Count - 1; i >= 0; i--)
{ {
if (string.IsNullOrWhiteSpace(PlayersTag[i])) if (string.IsNullOrWhiteSpace(PlayersTag[i]))
@ -100,12 +106,6 @@ namespace QwirkleClassLibrary.Games
return false; return false;
} }
if (GameRunning)
{
OnPlayerNotified(new AddPlayerNotifiedEventArgs("ERROR with " + (pos + 1) + " entry : The game is running."));
return false;
}
for(int i=0; i<PlayersTag.Count; i++) for(int i=0; i<PlayersTag.Count; i++)
{ {
if (i == pos) if (i == pos)

@ -10,12 +10,12 @@ public class TestGame
{ {
[Theory] [Theory]
[InlineData(true, false, "test", "test1")] [InlineData(true, false, "test", "test1")]
[InlineData(false, false, "test", "test1")] [InlineData(false, false, "test", "test")]
[InlineData(false, true, "test", "test1")]
public void Test_GameAddPlayerIngame(bool result, bool gamestate, string p1, string p2) public void Test_GameAddPlayerIngame(bool result, bool gamestate, string p1, string p2)
{ {
Game game = new Game(); Game game = new Game();
List<string> players = [p1, p2]; List<string> players = [p1, p2];
List<string> players2 = ["patrick", "jeanclaude"];
if (!result) if (!result)
{ {
@ -29,8 +29,9 @@ public class TestGame
if (gamestate) if (gamestate)
{ {
game.AddPlayerInGame(players);
game.StartGame(); game.StartGame();
Assert.False(game.AddPlayerInGame(players)); Assert.False(game.AddPlayerInGame(players2));
} }
} }

Loading…
Cancel
Save