From 28eae5dfaafe4df5d855a8e943fec8c7ee950d61 Mon Sep 17 00:00:00 2001 From: Andrey Zakharov Date: Sun, 30 Apr 2023 11:59:40 +0200 Subject: [PATCH] Fixes tests --- .../tri/service/GameSessionsServiceTest.kt | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/backend/src/test/kotlin/io/zakh/tri/service/GameSessionsServiceTest.kt b/backend/src/test/kotlin/io/zakh/tri/service/GameSessionsServiceTest.kt index 5c78316..98f9778 100644 --- a/backend/src/test/kotlin/io/zakh/tri/service/GameSessionsServiceTest.kt +++ b/backend/src/test/kotlin/io/zakh/tri/service/GameSessionsServiceTest.kt @@ -71,7 +71,13 @@ class GameSessionsServiceTest { whenever(service.sessionsRepo.findById(sessionID)) .thenReturn(Optional.of(GameSession(sessionID, emptyList()))) - assertThrows { service.changeConfig(playerID, sessionID, config) } + assertThrows { + service.changeConfig( + playerID, + sessionID, + config + ) + } } @Test @@ -88,17 +94,17 @@ class GameSessionsServiceTest { .thenAnswer { it.getArgument(0) } val sessionWithGame = service.changeConfig(playerID, sessionID, config) - assertEquals(sessionWithGame.state, GameSession.State.IN_PROGRESS) + assertEquals(sessionWithGame.state, GameSession.State.IDLE) assertNotNull(sessionWithGame.cells) - assertEquals(sessionWithGame.cells?.size, config.rowsCount * config.columnCount) - assertEquals(sessionWithGame.cells?.count { it.type == GameFieldCell.Type.END_GAME }, 1) + assertEquals(sessionWithGame.cells.size, config.rowsCount * config.columnCount) + assertEquals(sessionWithGame.cells.count { it.type == GameFieldCell.Type.END_GAME }, 1) assertEquals( - sessionWithGame.cells?.count { it.type == GameFieldCell.Type.TEAM_OWNED }, + sessionWithGame.cells.count { it.type == GameFieldCell.Type.TEAM_OWNED }, (config.rowsCount * config.columnCount) / (config.teamsCount + 1) ) assertEquals( - sessionWithGame.cells?.filter { it.ownerTeamId != null }?.map { it.ownerTeamId } - ?.toSet()?.size, + sessionWithGame.cells.filter { it.ownerTeamId != null }.map { it.ownerTeamId } + .toSet().size, config.teamsCount ) }