diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2017-05-15 20:48:57 +0200 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2017-05-15 20:48:57 +0200 |
commit | 0640d57928bc0681227c2e513b501e437201fdf8 (patch) | |
tree | bcf29785dd8590cf5cb60e2fa7637d6458212345 /backend/src/test | |
parent | Add 'leave lobby' action (backend only) (diff) | |
download | seven-wonders-0640d57928bc0681227c2e513b501e437201fdf8.tar.gz seven-wonders-0640d57928bc0681227c2e513b501e437201fdf8.tar.bz2 seven-wonders-0640d57928bc0681227c2e513b501e437201fdf8.zip |
Add test for Lobby.removePlayer()
Diffstat (limited to 'backend/src/test')
-rw-r--r-- | backend/src/test/java/org/luxons/sevenwonders/lobby/LobbyTest.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/backend/src/test/java/org/luxons/sevenwonders/lobby/LobbyTest.java b/backend/src/test/java/org/luxons/sevenwonders/lobby/LobbyTest.java index c47e30b4..9ce4ce0c 100644 --- a/backend/src/test/java/org/luxons/sevenwonders/lobby/LobbyTest.java +++ b/backend/src/test/java/org/luxons/sevenwonders/lobby/LobbyTest.java @@ -128,7 +128,21 @@ public class LobbyTest { } @Test - public void reorderPlayers_failsOnSameName() { + public void removePlayer_failsWhenNotPresent() { + thrown.expect(UnknownPlayerException.class); + lobby.removePlayer("anyname"); + } + + @Test + public void removePlayer_success() { + Player player = new Player("testuser", "Test User"); + lobby.addPlayer(player); + lobby.removePlayer("testuser"); + assertFalse(lobby.containsUser("testuser")); + } + + @Test + public void reorderPlayers_success() { Player player1 = new Player("testuser1", "Test User 1"); Player player2 = new Player("testuser2", "Test User 2"); Player player3 = new Player("testuser3", "Test User 3"); @@ -139,6 +153,9 @@ public class LobbyTest { assertEquals("testuser3", lobby.getPlayers().get(0).getUsername()); assertEquals("testuser1", lobby.getPlayers().get(1).getUsername()); assertEquals("testuser2", lobby.getPlayers().get(2).getUsername()); + assertEquals(0, lobby.getPlayers().get(0).getIndex()); + assertEquals(1, lobby.getPlayers().get(1).getIndex()); + assertEquals(2, lobby.getPlayers().get(2).getIndex()); } @Test(expected = UnknownPlayerException.class) @@ -164,7 +181,7 @@ public class LobbyTest { @Theory public void startGame_succeedsAboveMinPlayers(int nbPlayers) { assumeTrue(nbPlayers >= gameDefinition.getMinPlayers()); - assumeTrue(nbPlayers < gameDefinition.getMaxPlayers()); + assumeTrue(nbPlayers <= gameDefinition.getMaxPlayers()); // there is already the owner addPlayers(nbPlayers - 1); lobby.startGame(); |