summaryrefslogtreecommitdiff
path: root/sw-server/src/test/kotlin
diff options
context:
space:
mode:
authorjoffrey-bion <joffrey.bion@gmail.com>2020-12-12 02:04:17 +0100
committerjoffrey-bion <joffrey.bion@gmail.com>2020-12-12 03:04:22 +0100
commita3aa0dee728a299fbb54a758135ac1c8dfe867b2 (patch)
treeac95f0ada0b83b2e2dee4c7f4c94091c2272496c /sw-server/src/test/kotlin
parentMake ready button optional (server side) (diff)
downloadseven-wonders-a3aa0dee728a299fbb54a758135ac1c8dfe867b2.tar.gz
seven-wonders-a3aa0dee728a299fbb54a758135ac1c8dfe867b2.tar.bz2
seven-wonders-a3aa0dee728a299fbb54a758135ac1c8dfe867b2.zip
Add checks for race conditions
Diffstat (limited to 'sw-server/src/test/kotlin')
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/lobby/LobbyTest.kt7
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/LobbyRepositoryTest.kt10
2 files changed, 6 insertions, 11 deletions
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))
}
bgstack15