edited some tests in ServerStateTest
This commit is contained in:
@@ -5,10 +5,13 @@
|
||||
import pp.mdga.client.*;
|
||||
import pp.mdga.client.Ceremony;
|
||||
import pp.mdga.client.StartPiece;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.game.Game;
|
||||
import pp.mdga.message.client.ClientMessage;
|
||||
import pp.mdga.message.server.*;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -79,59 +82,88 @@ public class ClientStateTest {
|
||||
private MoveMessage moveMessage;
|
||||
private NoTurn noTurn;
|
||||
private PauseGame pauseGame;
|
||||
private PlayCard playCard;
|
||||
private PossibleCard possibleCard;
|
||||
private PossiblePiece possiblePiece;
|
||||
private RankingResponse rankingResponce;
|
||||
private RankingRollAgain rankingRollAgain;
|
||||
private ReconnectBriefing reconnectBriefing;
|
||||
private ResumeGame resumeGame;
|
||||
private ServerStartGame startGame;
|
||||
private StartPiece startPieceMessage;
|
||||
private UpdateReady updateReady;
|
||||
private UpdateTSK updateTSK;
|
||||
private WaitPiece waitPiece;
|
||||
|
||||
private PlayCard playCardSwap;
|
||||
private PlayCard playCardShield;
|
||||
private PlayCard playCardTurbo;
|
||||
|
||||
private int from;
|
||||
private String name;
|
||||
private Color color;
|
||||
private BonusCard swapCard;
|
||||
private BonusCard shieldCard;
|
||||
private BonusCard turboCard;
|
||||
|
||||
private Game game;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
// This method will be executed before each test.
|
||||
// Initialize common objects or setup required state for Client State transitions.
|
||||
//initialize the game
|
||||
game = new Game();
|
||||
|
||||
//initialize the playerID
|
||||
from=1234;
|
||||
name="Daniel";
|
||||
color=Color.ARMY;
|
||||
swapCard = BonusCard.SWAP;
|
||||
shieldCard = BonusCard.SHIELD;
|
||||
turboCard = BonusCard.TURBO;
|
||||
|
||||
//initialize the messages from the server
|
||||
activePlayer = new ActivePlayer();
|
||||
activePlayer = new ActivePlayer(color);
|
||||
anyPiece = new AnyPiece();
|
||||
briefing = new Briefing();
|
||||
ceremonyMessage = new CeremonyMessage();
|
||||
dice = new Dice();
|
||||
dice = new Dice(6,new ArrayList<>());
|
||||
diceAgain = new DiceAgain();
|
||||
diceNow = new DiceNow();
|
||||
endOfTurn = new EndOfTurn();
|
||||
lobbyAccept = new LobbyAccept();
|
||||
lobbyDeny = new LobbyDeny();
|
||||
lobbyPlayerJoin = new LobbyPlayerJoin();
|
||||
lobbyPlayerLeave = new LobbyPlayerLeave();
|
||||
lobbyPlayerJoin = new LobbyPlayerJoin(name);
|
||||
lobbyPlayerLeave = new LobbyPlayerLeave(name,color);
|
||||
moveMessage = new MoveMessage();
|
||||
noTurn = new NoTurn();
|
||||
pauseGame = new PauseGame();
|
||||
playCard = new PlayCard();
|
||||
playCardSwap = new PlayCard(swapCard);
|
||||
playCardShield = new PlayCard(shieldCard);
|
||||
playCardTurbo = new PlayCard(turboCard);
|
||||
possibleCard = new PossibleCard();
|
||||
possiblePiece = new PossiblePiece();
|
||||
rankingResponce = new RankingResponse();
|
||||
rankingRollAgain = new RankingRollAgain();
|
||||
reconnectBriefing = new ReconnectBriefing();
|
||||
reconnectBriefing = new ReconnectBriefing(game);
|
||||
resumeGame = new ResumeGame();
|
||||
startGame = new ServerStartGame();
|
||||
startPieceMessage = new StartPiece();
|
||||
updateReady = new UpdateReady();
|
||||
updateTSK = new UpdateTSK();
|
||||
waitPiece = new WaitPiece();
|
||||
|
||||
//initialize the clientGameLogic
|
||||
clientGameLogic = new ClientGameLogic();
|
||||
clientGameLogic = new ClientGameLogic(game, new ClientSender() {
|
||||
@Override
|
||||
public void send(ClientMessage msg) {
|
||||
|
||||
}
|
||||
});
|
||||
clientAutomaton = (ClientAutomaton) clientGameLogic.getState();
|
||||
|
||||
//initialize the settings
|
||||
mainSettings = new MainSettings();
|
||||
videoSettings = new VideoSettings();
|
||||
audioSettings = new AudioSettings();
|
||||
mainSettings = new MainSettings(settingsStateMachine,clientGameLogic);
|
||||
videoSettings = new VideoSettings(settingsStateMachine,clientGameLogic);
|
||||
audioSettings = new AudioSettings(settingsStateMachine,clientGameLogic);
|
||||
settings = new Settings();
|
||||
|
||||
|
||||
@@ -535,7 +567,7 @@ public void testLobbyToRollRankingDice() {
|
||||
//sends the clientStatemachine in Lobby
|
||||
assertTrue(clientAutomaton.getState() instanceof Dialogs);
|
||||
Dialogs dialogs1 = (Dialogs) clientAutomaton.getState();
|
||||
DialogsStateMachine dialogsStateMachine1 = lobby.getDialogsStatemachine();
|
||||
DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine();
|
||||
dialogsStateMachine1.gotoState(lobby);
|
||||
assertTrue(dialogsStateMachine1.getState() instanceof Lobby);
|
||||
|
||||
@@ -547,7 +579,7 @@ public void testLobbyToRollRankingDice() {
|
||||
|
||||
//tests if the clientStateMachine is in the DetermineStartPlayer
|
||||
GameState gameState1 = (GameState) clientAutomaton.getState();
|
||||
GameStateMachine gameStateMachine1 = gameState1.getGameSatateMachine();
|
||||
GameStateMachine gameStateMachine1 = gameState1.getGameStateMachine();
|
||||
assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer);
|
||||
|
||||
//tests if the clientStateMachine is in the RollRankingDice
|
||||
|
||||
@@ -51,7 +51,6 @@
|
||||
import pp.mdga.server.TurnStateMachine;
|
||||
import pp.mdga.server.WaitingPiece;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -79,7 +78,9 @@ public class ServerStateTest {
|
||||
private SelectedPieces selectedPieces;
|
||||
private SelectTSK selectTSK;
|
||||
private ClientMessage[] clientMessages;
|
||||
|
||||
private int from;
|
||||
private int fromHost;
|
||||
|
||||
private GameStateMachine gameStateMachine;
|
||||
private TurnStateMachine turnStateMachine;
|
||||
@@ -152,74 +153,69 @@ public void send(int id, ServerMessage msg) {
|
||||
selectedPieces,
|
||||
selectTSK
|
||||
};
|
||||
from=1234;
|
||||
from = 1234;
|
||||
fromHost = 2345;
|
||||
|
||||
choosePieceStateMachine = choosePiece.getChoosePieceMachine();
|
||||
rollDiceMachine = rollDice.getRollDicemachine();
|
||||
turnStateMachine = turn.getTurnStatemachine();
|
||||
serverAutomaton = new ServerAutomaton(logic);
|
||||
serverAutomaton = logic.getServerAutomaton();
|
||||
gameStateMachine = gameState.getGameStatemachine();
|
||||
|
||||
thirdRoll = new ThirdRoll(rollDiceMachine,logic);
|
||||
secondRoll = new SecondRoll(rollDiceMachine,logic);
|
||||
firstRoll = new FirstRoll(rollDiceMachine,logic);
|
||||
thirdRoll = new ThirdRoll(rollDiceMachine, logic);
|
||||
secondRoll = new SecondRoll(rollDiceMachine, logic);
|
||||
firstRoll = new FirstRoll(rollDiceMachine, logic);
|
||||
|
||||
noPiece = new NoPiece(choosePieceStateMachine,logic);
|
||||
noTurn = new NoTurn(choosePieceStateMachine,logic);
|
||||
waitingPiece = new WaitingPiece(choosePieceStateMachine,logic);
|
||||
startPiece = new StartPiece(choosePieceStateMachine,logic);
|
||||
selectPiece = new SelectPiece(choosePieceStateMachine,logic);
|
||||
noPiece = new NoPiece(choosePieceStateMachine, logic);
|
||||
noTurn = new NoTurn(choosePieceStateMachine, logic);
|
||||
waitingPiece = new WaitingPiece(choosePieceStateMachine, logic);
|
||||
startPiece = new StartPiece(choosePieceStateMachine, logic);
|
||||
selectPiece = new SelectPiece(choosePieceStateMachine, logic);
|
||||
|
||||
powerCard = new PowerCard(turnStateMachine,logic);
|
||||
playPowerCard = new PlayPowerCard(turnStateMachine,logic);
|
||||
rollDice = new RollDice(turnStateMachine,logic);
|
||||
choosePiece = new ChoosePiece(turnStateMachine,logic);
|
||||
movePiece = new MovePiece(turnStateMachine,logic);
|
||||
powerCard = new PowerCard(turnStateMachine, logic);
|
||||
playPowerCard = new PlayPowerCard(turnStateMachine, logic);
|
||||
rollDice = new RollDice(turnStateMachine, logic);
|
||||
choosePiece = new ChoosePiece(turnStateMachine, logic);
|
||||
movePiece = new MovePiece(turnStateMachine, logic);
|
||||
|
||||
determineStartPlayer = new DetermineStartPlayer(gameStateMachine,logic);
|
||||
turn = new Turn(gameStateMachine,logic);
|
||||
animation = new Animation(gameStateMachine,logic);
|
||||
determineStartPlayer = new DetermineStartPlayer(gameStateMachine, logic);
|
||||
turn = new Turn(gameStateMachine, logic);
|
||||
animation = new Animation(gameStateMachine, logic);
|
||||
|
||||
lobby = new Lobby(serverAutomaton,logic);
|
||||
gameState = new GameState(serverAutomaton,logic);
|
||||
ceremony = new Ceremony(serverAutomaton,logic);
|
||||
interrupt = new Interrupt(serverAutomaton,logic,gameState);
|
||||
lobby = new Lobby(serverAutomaton, logic);
|
||||
gameState = new GameState(serverAutomaton, logic);
|
||||
ceremony = new Ceremony(serverAutomaton, logic);
|
||||
interrupt = new Interrupt(serverAutomaton, logic, gameState);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitialStateServerState() {
|
||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
||||
assertTrue(automaton.getState() instanceof Lobby);
|
||||
assertTrue(serverAutomaton.getState() instanceof Lobby);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLobbyToDetermineStartPlayer() {
|
||||
//tests if Server is in State Lobby
|
||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
||||
assertTrue(automaton.getState() instanceof Lobby);
|
||||
Lobby lobby = (Lobby) automaton.getState();
|
||||
//tests, when not all players are ready and the hosts send clientStartGame, that the Server stays in Lobby
|
||||
//TODO set one player not ready
|
||||
lobby.receivedStartGame(clientStartGame, from);
|
||||
assertTrue(automaton.getState() instanceof Lobby);
|
||||
//tests, when all players are ready and the hosts send clientStartGame, that the Server changes to DSP
|
||||
//TODO set all player Ready
|
||||
lobby.receivedStartGame(clientStartGame, from);
|
||||
assertTrue(automaton.getState() instanceof GameState);
|
||||
GameState gameState = (GameState) automaton.getState();
|
||||
assertTrue(gameState.getState() instanceof DetermineStartPlayer);
|
||||
//sends the server in the lobby-state
|
||||
serverAutomaton.gotoState(lobby);
|
||||
assertTrue(serverAutomaton.getState() instanceof Lobby);
|
||||
|
||||
//sends the startGame message from the Host to the server
|
||||
logic.received(clientStartGame, from);
|
||||
|
||||
//tests if the server iss in DSP-state
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
GameState gameState1 = (GameState) serverAutomaton.getState();//Todo erzeuge state
|
||||
GameStateMachine gameStateMachine1 = gameState.getGameStateMachine();
|
||||
assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStayInLobby() {
|
||||
//tests if Server is in State Lobby
|
||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
||||
assertTrue(automaton.getState() instanceof Lobby);
|
||||
//sends the server in the lobby-state
|
||||
serverAutomaton.gotoState(lobby);
|
||||
assertTrue(serverAutomaton.getState() instanceof Lobby);
|
||||
|
||||
//lobby gets all possible messages
|
||||
Lobby lobby = (Lobby) automaton.getState();
|
||||
|
||||
//logic gets all messages
|
||||
//TODO logic gets all messages
|
||||
logic.received(animationEnd, from);
|
||||
logic.received(clientStartGame, from);
|
||||
logic.received(deselectTSK, from);
|
||||
@@ -238,135 +234,209 @@ public void testStayInLobby() {
|
||||
logic.received(selectTSK, from);
|
||||
|
||||
//tests if Server is still in Lobby
|
||||
assertTrue(automaton.getState() instanceof Lobby);
|
||||
assertTrue(serverAutomaton.getState() instanceof Lobby);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testServerGameSubStatesToInterrupt() {
|
||||
// TODO: Implement test logic for transition from Server Game Sub-States to Interrupt
|
||||
//sends the server in the gameState
|
||||
serverAutomaton.gotoState(gameState);
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState); //TODO könnte auch auf gleichheit prüfen
|
||||
|
||||
//TODO create interrupt
|
||||
|
||||
//tests if the server is in the Interrupt-state
|
||||
assertTrue(serverAutomaton.getState() instanceof Interrupt);
|
||||
}
|
||||
|
||||
/**
|
||||
* tests the state-change from Game to Ceremony if the Game is finished
|
||||
*/
|
||||
@Test
|
||||
public void testServerGameToCeremony() {
|
||||
// TODO: Implement test logic for transition from Server Game to Ceremony
|
||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
||||
assertTrue(automaton.getState() instanceof Lobby);
|
||||
Lobby lobby = (Lobby) automaton.getState();
|
||||
//Todo set all players ready
|
||||
logic.received(clientStartGame, from);
|
||||
assertTrue(automaton.getState() instanceof GameState);
|
||||
//sends the server in the gameState
|
||||
serverAutomaton.gotoState(gameState);
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
|
||||
//Todo game is finished
|
||||
assertTrue(automaton.getState() instanceof Ceremony);
|
||||
|
||||
//tests if the server is in the Ceremony-state
|
||||
assertTrue(serverAutomaton.getState() instanceof Ceremony);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterruptToGameContinue() {
|
||||
//sends the server into the interrupt
|
||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
||||
automaton.gotoState(interrupt);
|
||||
assertTrue(automaton.getState() instanceof Interrupt);
|
||||
//sends the server in the Interrupt-State
|
||||
serverAutomaton.gotoState(interrupt);
|
||||
assertTrue(serverAutomaton.getState() instanceof Interrupt);
|
||||
|
||||
//sends the continue-message to the server
|
||||
logic.received(forceContinueGame, from);
|
||||
|
||||
//tests if new Stet is in GameState
|
||||
assertTrue(automaton.getState() instanceof GameState);
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterruptToGameReconnect() {
|
||||
// TODO: Implement test logic for transition from Interrupt to Game Reconnect
|
||||
//sends the server in the Interrupt-State
|
||||
serverAutomaton.gotoState(interrupt);
|
||||
assertTrue(serverAutomaton.getState() instanceof Interrupt);
|
||||
|
||||
//todo implement the timer
|
||||
|
||||
//tests if new Stet is in GameState
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterruptToGameTimer() {
|
||||
// TODO: Implement test logic for transition from Interrupt to Game Timer
|
||||
//sends the server in the Interrupt-State
|
||||
serverAutomaton.gotoState(interrupt);
|
||||
assertTrue(serverAutomaton.getState() instanceof Interrupt);
|
||||
|
||||
//Todo implement the timer
|
||||
|
||||
//tests if new Stet is in GameState
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCeremonyToServerStateEndState() {
|
||||
// TODO: Implement test logic for transition from Ceremony to Server State End State
|
||||
// TODO how????
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDetermineStartPlayerToDetermineStartPlayer1() {
|
||||
// Implement test logic for Determine Start Player to Determine Start Player (Variant 1)
|
||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
||||
assertTrue(automaton.getState() instanceof GameState);
|
||||
GameState gameState = (GameState) automaton.getState();
|
||||
assertTrue(gameState.getState() instanceof GameStateMachine);
|
||||
GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState();
|
||||
//sends the server in Game-State
|
||||
serverAutomaton.gotoState(gameState);
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
|
||||
//sends the gameStateMachine in DSP-state
|
||||
gameStateMachine.gotoState(determineStartPlayer);
|
||||
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer);
|
||||
|
||||
logic.received(requestDice, from);
|
||||
|
||||
assertTrue(automaton.getState() instanceof DetermineStartPlayer);
|
||||
//TODO sends messages to the server
|
||||
|
||||
//tests if the server is still in DSP-state
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDetermineStartPlayerToDetermineStartPlayer2() {
|
||||
// Implement test logic for Determine Start Player to Determine Start Player (Variant 2)
|
||||
// sends the server in determineStartPlayer
|
||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
||||
assertTrue(automaton.getState() instanceof GameState);
|
||||
GameState gameState = (GameState) automaton.getState();
|
||||
assertTrue(gameState.getState() instanceof GameStateMachine);
|
||||
GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState();
|
||||
//sends the server in Game-State
|
||||
serverAutomaton.gotoState(gameState);
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
|
||||
//sends the gameStateMachine in DSP-state
|
||||
gameStateMachine.gotoState(determineStartPlayer);
|
||||
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer);
|
||||
|
||||
//TODO sends messages 2 RequestDiceMessage, die gleich geränkt werden to the server
|
||||
|
||||
//tests if the server is still in DSP-state
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer);
|
||||
//Todo: input same dices for both players
|
||||
logic.received(requestDice, from);
|
||||
logic.received(requestDice, 1235);
|
||||
assertTrue(automaton.getState() instanceof DetermineStartPlayer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDetermineStartPlayerToAnimation() {
|
||||
// Implement test logic for Determine Start Player to Determine Start Player (Variant 2)
|
||||
// sends the server in determineStartPlayer
|
||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
||||
assertTrue(automaton.getState() instanceof GameState);
|
||||
GameState gameState = (GameState) automaton.getState();
|
||||
assertTrue(gameState.getState() instanceof GameStateMachine);
|
||||
GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState();
|
||||
//sends the server in Game-State
|
||||
serverAutomaton.gotoState(gameState);
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
|
||||
//sends the gameStateMachine in DSP-state
|
||||
gameStateMachine.gotoState(determineStartPlayer);
|
||||
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer);
|
||||
//Todo: input different dices for both players
|
||||
logic.received(requestDice, from);
|
||||
logic.received(requestDice, 1235);
|
||||
assertTrue(automaton.getState() instanceof Animation);
|
||||
|
||||
//TODO sends messages 2 RequestDiceMessage, die ungleich geränkt werden, sodass der server weitergeht
|
||||
|
||||
//tests if the Server is in animationState
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
assertTrue(gameStateMachine.getState() instanceof Animation);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnimationToPowerCard() {
|
||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
||||
assertTrue(automaton.getState() instanceof GameState);
|
||||
GameState gameState = (GameState) automaton.getState();
|
||||
assertTrue(gameState.getState() instanceof GameStateMachine);
|
||||
GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState();
|
||||
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer);
|
||||
//Todo: input different dices for both players
|
||||
logic.received(requestDice, from);
|
||||
logic.received(requestDice, 1235);
|
||||
assertTrue(automaton.getState() instanceof Animation);
|
||||
logic.received(animationEnd, from);
|
||||
//sends the server in Game-State
|
||||
serverAutomaton.gotoState(gameState);
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
|
||||
//sends the gameStateMachine in Animation
|
||||
gameStateMachine.gotoState(animation);
|
||||
assertTrue(gameStateMachine.getState() instanceof Animation);
|
||||
logic.received(animationEnd, 1235);
|
||||
|
||||
//receives one animation endMessage and tests if the server is still in the Animation-state
|
||||
logic.received(animationEnd, fromHost);
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
assertTrue(gameStateMachine.getState() instanceof Animation);
|
||||
|
||||
//receives another animation endMessage
|
||||
logic.received(animationEnd, from);
|
||||
|
||||
//tests if the server is in the PowerCard-state
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||
TurnStateMachine turnStateMachine = (TurnStateMachine) automaton.getState();
|
||||
Turn turn1 = (Turn) gameStateMachine.getState();
|
||||
TurnStateMachine turnStateMachine = (TurnStateMachine) turn1.getTurnStateMachine();
|
||||
assertTrue(turnStateMachine.getState() instanceof PowerCard);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTurnToAnimation() {
|
||||
// TODO: Implement test logic for transition from Turn to Animation
|
||||
//sends the server in Game-State
|
||||
serverAutomaton.gotoState(gameState);
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
|
||||
//sends the gameStateMachine in Turn
|
||||
gameStateMachine.gotoState(turn);
|
||||
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||
|
||||
//todo set the turn finished and there are still two players left
|
||||
|
||||
//tests if the server is in the AnimationState
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
assertTrue(gameStateMachine.getState() instanceof Animation);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTurnToGameEndState() {
|
||||
// TODO: Implement test logic for transition from Turn to Game End State
|
||||
//sends the server in Game-State
|
||||
serverAutomaton.gotoState(gameState);
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
|
||||
//sends the gameStateMachine in Turn
|
||||
gameStateMachine.gotoState(turn);
|
||||
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||
|
||||
//todo set the turn finished and there is only one players left
|
||||
|
||||
//tests if the server is in the end-state of game, Ceremony
|
||||
assertTrue(serverAutomaton.getState() instanceof Ceremony);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStayInPowerCard() {
|
||||
// TODO: Implement test logic for staying in Power Card state
|
||||
//sends the server in Game-State
|
||||
serverAutomaton.gotoState(gameState);
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
|
||||
//sends the gameStateMachine in Turn
|
||||
gameStateMachine.gotoState(turn);
|
||||
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||
|
||||
//sends the TurnStateMachine in PowerCard
|
||||
turnStateMachine.gotoState(powerCard);
|
||||
assertTrue(turnStateMachine.getState() instanceof PowerCard);
|
||||
|
||||
//Todo: receive messages which dont lead to a state change
|
||||
|
||||
//tests if the server is in PowerCard
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||
assertTrue(turnStateMachine.getState() instanceof PowerCard);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -375,7 +445,24 @@ public void testStayInPowerCard() {
|
||||
*/
|
||||
@Test
|
||||
public void testPowerCardToPlayPowerCard() {
|
||||
// UC-ServerState-17
|
||||
//sends the server in Game-State
|
||||
serverAutomaton.gotoState(gameState);
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
|
||||
//sends the gameStateMachine in Turn
|
||||
gameStateMachine.gotoState(turn);
|
||||
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||
|
||||
//sends the TurnStateMachine in PowerCard
|
||||
turnStateMachine.gotoState(powerCard);
|
||||
assertTrue(turnStateMachine.getState() instanceof PowerCard);
|
||||
|
||||
//todo
|
||||
|
||||
//tests if the server is in PlayPowerCard
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||
assertTrue(turnStateMachine.getState() instanceof PlayPowerCard);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -384,7 +471,34 @@ public void testPowerCardToPlayPowerCard() {
|
||||
*/
|
||||
@Test
|
||||
public void testPlayPowerCardToRollDice() {
|
||||
// UC-ServerState-18
|
||||
//sends the server in Game-State
|
||||
serverAutomaton.gotoState(gameState);
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
|
||||
//sends the gameStateMachine in Turn
|
||||
gameStateMachine.gotoState(turn);
|
||||
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||
|
||||
//sends the TurnStateMachine in PowerCard
|
||||
turnStateMachine.gotoState(playPowerCard);
|
||||
assertTrue(turnStateMachine.getState() instanceof PlayPowerCard);
|
||||
|
||||
//receive first AnimationEndMessage from the host
|
||||
logic.received(animationEnd, fromHost);
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||
assertTrue(turnStateMachine.getState() instanceof PlayPowerCard);
|
||||
|
||||
//receive second AnimationEndMessage
|
||||
logic.received(animationEnd, from);
|
||||
|
||||
//tests if the server is in RollDice and in FirstRoll
|
||||
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||
assertTrue(turnStateMachine.getState() instanceof RollDice);
|
||||
RollDice rollDice = (RollDice) turnStateMachine.getState();
|
||||
RollDiceMachine rollDiceMachine1 = rollDice.getRollDiceStateMachine();
|
||||
assertTrue(rollDiceMachine1.getState() instanceof FirstRoll);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user