From a3aa0dee728a299fbb54a758135ac1c8dfe867b2 Mon Sep 17 00:00:00 2001 From: joffrey-bion Date: Sat, 12 Dec 2020 02:04:17 +0100 Subject: Add checks for race conditions --- .../kotlin/org/luxons/sevenwonders/server/lobby/LobbyTest.kt | 7 ++----- .../sevenwonders/server/repositories/LobbyRepositoryTest.kt | 10 ++++------ 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'sw-server/src/test/kotlin') diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/lobby/LobbyTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/lobby/LobbyTest.kt index 4125810f..7e27cf7f 100644 --- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/lobby/LobbyTest.kt +++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/lobby/LobbyTest.kt @@ -34,24 +34,21 @@ class LobbyTest { @Before fun setUp() { gameOwner = Player("gameowner", "Game owner") - lobby = Lobby(0, "Test Game", gameOwner, gameDefinition) + lobby = Lobby(42, "Test Game", gameOwner, gameDefinition) } @Test fun testId() { - val lobby = Lobby(5, "Test Game", gameOwner, gameDefinition) - assertEquals(5, lobby.id) + assertEquals(42, lobby.id) } @Test fun testName() { - val lobby = Lobby(5, "Test Game", gameOwner, gameDefinition) assertEquals("Test Game", lobby.name) } @Test fun testOwner() { - val lobby = Lobby(5, "Test Game", gameOwner, gameDefinition) assertSame(gameOwner, lobby.getPlayers()[0]) assertSame(lobby, gameOwner.lobby) } diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/LobbyRepositoryTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/LobbyRepositoryTest.kt index c59dc49f..8bef7efc 100644 --- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/LobbyRepositoryTest.kt +++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/LobbyRepositoryTest.kt @@ -25,9 +25,8 @@ class LobbyRepositoryTest { @Test fun list_returnsAllLobbies() { - val owner = Player("owner", "The Owner") - val lobby1 = repository.create("Test Name 1", owner) - val lobby2 = repository.create("Test Name 2", owner) + val lobby1 = repository.create("Test Name 1", Player("owner1", "The Owner")) + val lobby2 = repository.create("Test Name 2", Player("owner2", "The Owner")) assertTrue(repository.list().contains(lobby1)) assertTrue(repository.list().contains(lobby2)) } @@ -48,9 +47,8 @@ class LobbyRepositoryTest { @Test fun find_returnsTheSameObject() { - val owner = Player("owner", "The Owner") - val lobby1 = repository.create("Test Name 1", owner) - val lobby2 = repository.create("Test Name 2", owner) + val lobby1 = repository.create("Test Name 1", Player("owner1", "The Owner")) + val lobby2 = repository.create("Test Name 2", Player("owner2", "The Owner")) assertSame(lobby1, repository.find(lobby1.id)) assertSame(lobby2, repository.find(lobby2.id)) } -- cgit