From cb2a5130ed7f133941935b981fec89b7e9b4b644 Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Mon, 15 May 2017 20:56:33 +0200 Subject: Add test for Lobby owner index --- backend/src/main/java/org/luxons/sevenwonders/lobby/Lobby.java | 2 +- .../src/test/java/org/luxons/sevenwonders/lobby/LobbyTest.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'backend') diff --git a/backend/src/main/java/org/luxons/sevenwonders/lobby/Lobby.java b/backend/src/main/java/org/luxons/sevenwonders/lobby/Lobby.java index b143538a..2081d531 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/lobby/Lobby.java +++ b/backend/src/main/java/org/luxons/sevenwonders/lobby/Lobby.java @@ -30,7 +30,7 @@ public class Lobby { this.gameDefinition = gameDefinition; this.players = new ArrayList<>(gameDefinition.getMinPlayers()); this.settings = new CustomizableSettings(); - players.add(owner); + addPlayer(owner); } public long getId() { 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 9ce4ce0c..8a428aef 100644 --- a/backend/src/test/java/org/luxons/sevenwonders/lobby/LobbyTest.java +++ b/backend/src/test/java/org/luxons/sevenwonders/lobby/LobbyTest.java @@ -21,6 +21,7 @@ import org.luxons.sevenwonders.lobby.Lobby.UnknownPlayerException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; @@ -64,6 +65,14 @@ public class LobbyTest { assertEquals("Test Game", l.getName()); } + @Test + public void testOwner() { + gameOwner.setIndex(42); + Lobby l = new Lobby(5, "Test Game", gameOwner, gameDefinition); + assertSame(gameOwner, l.getPlayers().get(0)); + assertEquals(0, gameOwner.getIndex()); + } + @Test public void isOwner_falseWhenNull() { assertFalse(lobby.isOwner(null)); -- cgit