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 new file mode 100644 index 0000000..ba9ce42 --- /dev/null +++ b/Server/src/test/java/uulm/teamname/marvelous/server/lobby/LobbyTest.java @@ -0,0 +1,59 @@ +package uulm.teamname.marvelous.server.lobby; + +import org.java_websocket.WebSocket; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import uulm.teamname.marvelous.gamelibrary.config.CharacterConfig; +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.messages.ParticipantType; +import uulm.teamname.marvelous.gamelibrary.requests.Request; +import uulm.teamname.marvelous.gamelibrary.requests.RequestBuilder; +import uulm.teamname.marvelous.gamelibrary.requests.RequestType; +import uulm.teamname.marvelous.server.lobbymanager.LobbyConnection; +import uulm.teamname.marvelous.server.lobbymanager.Participant; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static org.assertj.core.api.Assertions.*; + +class LobbyTest { + Lobby lobby; + LobbyConnection connection; + + @BeforeEach + void beforeEach(){ + var gameID = "GameID"; + connection = mock(LobbyConnection.class); + var partyConfig = mock(PartyConfig.class); + var scenarioConfig = new ScenarioConfig(); + scenarioConfig.scenario = new FieldType[][] { + {FieldType.GRASS, FieldType.GRASS, FieldType.GRASS, FieldType.GRASS, FieldType.GRASS}, + {FieldType.GRASS, FieldType.GRASS, FieldType.GRASS, FieldType.GRASS, FieldType.GRASS} + }; + var characterConfig = mock(CharacterConfig.class); + + lobby = new Lobby( + gameID, + connection, + partyConfig, + characterConfig, + scenarioConfig + ); + } + + @Test + void receiveRequestsTest(){ + var requests = new Request[] { + new RequestBuilder(RequestType.Req).buildGameRequest(), + new RequestBuilder(RequestType.MoveRequest).buildGameRequest() + }; + var playerConnection = mock(WebSocket.class); + + Participant playerOne = new Participant(playerConnection, ParticipantType.PlayerOne, "P1"); + lobby.receiveRequests(requests, playerOne); + } + +} \ No newline at end of file