diff options
Diffstat (limited to 'sw-server/src')
-rw-r--r-- | sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt | 10 | ||||
-rw-r--r-- | sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/ClientEventsAsserts.kt | 11 |
2 files changed, 16 insertions, 5 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 bb32a79e..2b7330ec 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 @@ -59,13 +59,16 @@ class SevenWondersTest { session2.joinGameAndAwaitLobby(lobby.id) val outsiderSession = newPlayer("Outsider") - val outsiderAsserter = outsiderSession.eventAsserter(scope = this) + val outsiderAsserter = outsiderSession.eventAsserter(scope = this) val ownerAsserter = ownerSession.eventAsserter(scope = this) + ownerSession.startGame() ownerAsserter.expectGameEvent<GameEvent.GameStarted>() outsiderAsserter.expectNoGameEvent("outsider should not receive the game start event of this game") + ownerAsserter.cancel() + outsiderAsserter.cancel() disconnect(ownerSession, session1, session2, outsiderSession) } @@ -97,6 +100,7 @@ class SevenWondersTest { assertEquals(createdLobby.id, receivedLobby.id) assertEquals(createdLobby.name, receivedLobby.name) + asserter.cancel() disconnect(ownerSession, otherSession) } @@ -142,6 +146,10 @@ class SevenWondersTest { asserter2.expectPlayFromHandTurn() asserter3.expectPlayFromHandTurn() + asserter1.cancel() + asserter2.cancel() + asserter3.cancel() + session1.disconnect() session2.disconnect() session3.disconnect() diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/ClientEventsAsserts.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/ClientEventsAsserts.kt index 62245764..c5c4fedb 100644 --- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/ClientEventsAsserts.kt +++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/ClientEventsAsserts.kt @@ -1,10 +1,8 @@ package org.luxons.sevenwonders.server.test -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.* import kotlinx.coroutines.channels.ReceiveChannel import kotlinx.coroutines.flow.produceIn -import kotlinx.coroutines.withTimeoutOrNull import org.luxons.sevenwonders.client.SevenWondersSession import org.luxons.sevenwonders.model.api.events.GameEvent import org.luxons.sevenwonders.model.api.events.GameListEvent @@ -18,7 +16,12 @@ import kotlin.time.Duration.Companion.seconds class EventAsserter( val gameListEvents: ReceiveChannel<GameListEvent>, val gameEvents: ReceiveChannel<GameEvent>, -) +) { + fun cancel() { + gameListEvents.cancel() + gameEvents.cancel() + } +} @OptIn(FlowPreview::class) suspend fun SevenWondersSession.eventAsserter(scope: CoroutineScope): EventAsserter { |