summaryrefslogtreecommitdiff
path: root/sw-server
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@booking.com>2020-05-16 10:28:04 +0200
committerJoffrey Bion <joffrey.bion@booking.com>2020-05-16 10:28:04 +0200
commit51e045465323cd8fdf94b1ada0f05cf7e82ca48a (patch)
tree0212d767af694f88fb23b26772bd7bd4b7e004c8 /sw-server
parentAdd visuals for discard and wonder upgrade moves (diff)
downloadseven-wonders-51e045465323cd8fdf94b1ada0f05cf7e82ca48a.tar.gz
seven-wonders-51e045465323cd8fdf94b1ada0f05cf7e82ca48a.tar.bz2
seven-wonders-51e045465323cd8fdf94b1ada0f05cf7e82ca48a.zip
Cleanup SW test
Diffstat (limited to 'sw-server')
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt21
1 files changed, 8 insertions, 13 deletions
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt
index c8a287f7..b2b86131 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt
@@ -5,8 +5,6 @@ import kotlinx.coroutines.flow.produceIn
import kotlinx.coroutines.launch
import kotlinx.coroutines.withTimeout
import kotlinx.coroutines.withTimeoutOrNull
-import org.junit.Before
-import org.junit.Test
import org.junit.runner.RunWith
import org.luxons.sevenwonders.client.SevenWondersClient
import org.luxons.sevenwonders.client.SevenWondersSession
@@ -18,6 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertNull
+import kotlin.test.Test
@RunWith(SpringRunner::class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@@ -26,14 +25,10 @@ class SevenWondersTest {
@LocalServerPort
private val randomServerPort: Int = 0
- private lateinit var client: SevenWondersClient
-
- private lateinit var serverUrl: String
-
- @Before
- fun setUpClientAndUrl() {
- client = SevenWondersClient()
- serverUrl = "localhost:$randomServerPort"
+ private suspend fun connectNewClient(): SevenWondersSession {
+ val client = SevenWondersClient()
+ val serverUrl = "localhost:$randomServerPort"
+ return client.connect(serverUrl)
}
private suspend fun disconnect(vararg sessions: SevenWondersSession) {
@@ -43,8 +38,8 @@ class SevenWondersTest {
}
@Test
- fun chooseName() = runAsyncTest {
- val session = client.connect(serverUrl)
+ fun chooseName_succeedsWithCorrectDisplayName() = runAsyncTest {
+ val session = connectNewClient()
val playerName = "Test User"
val player = session.chooseName(playerName)
assertNotNull(player)
@@ -52,7 +47,7 @@ class SevenWondersTest {
session.disconnect()
}
- private suspend fun newPlayer(name: String): SevenWondersSession = client.connect(serverUrl).apply {
+ private suspend fun newPlayer(name: String): SevenWondersSession = connectNewClient().apply {
chooseName(name)
}
bgstack15