diff --git a/Server/src/test/java/uulm/teamname/marvelous/server/lobby/LobbyTest.java b/Server/src/test/java/uulm/teamname/marvelous/server/lobby/LobbyTest.java index 73eb330..b10ea1f 100644 --- a/Server/src/test/java/uulm/teamname/marvelous/server/lobby/LobbyTest.java +++ b/Server/src/test/java/uulm/teamname/marvelous/server/lobby/LobbyTest.java @@ -8,6 +8,8 @@ import uulm.teamname.marvelous.gamelibrary.config.FieldType; import uulm.teamname.marvelous.gamelibrary.config.PartyConfig; import uulm.teamname.marvelous.gamelibrary.config.ScenarioConfig; import uulm.teamname.marvelous.gamelibrary.entities.EntityType; +import uulm.teamname.marvelous.gamelibrary.events.EventBuilder; +import uulm.teamname.marvelous.gamelibrary.events.EventType; import uulm.teamname.marvelous.gamelibrary.messages.ParticipantType; import uulm.teamname.marvelous.gamelibrary.requests.Request; import uulm.teamname.marvelous.gamelibrary.requests.RequestBuilder; @@ -57,4 +59,40 @@ class LobbyTest { lobby.receiveRequests(requests, playerOne); } + @Test + void soonTimeoutTest(){ + var participant = mock(Participant.class); + lobby.soonTimeout(participant); + verify(connection).sendEvents(participant, new EventBuilder(EventType.TimeoutWarningEvent).buildGameStateEvent()); + } + + @Test + void generateWinPlayer1Test(){ + var webSoc = mock(WebSocket.class); + Participant winner = new Participant(webSoc, ParticipantType.PlayerOne, "playerOne"); + lobby.generateWin(winner); + verify(connection).broadcastEvents( + new EventBuilder(EventType.WinEvent) + .withPlayerWon(1) + .buildGameStateEvent(), + new EventBuilder(EventType.DisconnectEvent) + .buildGameStateEvent()); + verify(connection).terminateConnection(); + } + + @Test + void generateWinPlayer2Test(){ + var webSoc = mock(WebSocket.class); + Participant winner = new Participant(webSoc, ParticipantType.PlayerOne, "playerOne"); + lobby.generateWin(winner); + verify(connection).broadcastEvents( + new EventBuilder(EventType.WinEvent) + .withPlayerWon(2) + .buildGameStateEvent(), + new EventBuilder(EventType.DisconnectEvent) + .buildGameStateEvent()); + verify(connection).terminateConnection(); + } + + }