test: created test for Lobby
This commit is contained in:
parent
6eff0a4813
commit
4e66a4eb24
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user