test: created test for TurnTimer

This commit is contained in:
Richard Reiber 2021-06-05 23:28:17 +02:00
parent 0088a4b3e9
commit 4dec57d483
3 changed files with 34 additions and 1 deletions

View File

@ -33,6 +33,7 @@ public class Lobby {
PartyConfig partyConfig,
CharacterConfig characterConfig,
ScenarioConfig scenarioConfig) {
this.gameID = gameID;
this.connection = connection;

View File

@ -0,0 +1,32 @@
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.messages.ParticipantType;
import uulm.teamname.marvelous.server.lobbymanager.LobbyConnection;
import uulm.teamname.marvelous.server.lobbymanager.Participant;
import java.util.function.Consumer;
import static org.junit.jupiter.api.Assertions.*;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
class TurnTimerTest {
TurnTimer turnTimer;
@BeforeEach
void beforeEach(){
var callback = mock(Consumer.class);
turnTimer = new TurnTimer(20, callback);
}
@Test
void startTurnTimerTest(){
var connection = mock(WebSocket.class);
var participant = new Participant(connection, ParticipantType.Spectator, "spectator");
assertThatIllegalStateException().describedAs("Spectators don't have TurnTime").isThrownBy(() -> turnTimer.startTurnTimer(participant));
}
}

View File

@ -47,7 +47,7 @@ class PacketTest {
new RequestBuilder(RequestType.Req).buildGameRequest(),
new RequestBuilder(RequestType.MoveRequest).buildGameRequest()
};
var participant = new Participant(null, ParticipantType.PlayerOne, "PlaerOne");
var participant = new Participant(null, ParticipantType.PlayerOne, "PlayerOne");
packet = new Packet(requests, participant);
assertThat(packet.getOrigin()).isEqualTo(participant);