corrected some testmethods in the serverStateTest,

changed all assertTrue( .... isinstanceof ....) to assertEquals(...,....)
This commit is contained in:
Benjamin Feyer
2024-11-28 18:40:07 +01:00
parent 8a5ebfd9d2
commit b3504925a5
2 changed files with 228 additions and 219 deletions

View File

@@ -32,8 +32,6 @@ public class ClientStateTest {
//declare game here
private Game game;
//declare state-machines here
//declare states here
private Animation animation;
private AudioSettings audioSettings;
@@ -181,15 +179,13 @@ public void send(ClientMessage msg) {
settings = new Settings(clientGameLogic,clientGameLogic);
//initialize the stateMachines
ceremonyState =ceremony.getCeremonyState();
choosePiece = choosePiece.getChoosePieceStateMachine();
determineStartPlayerStateMachine = determineStartPlayer.getDetermineStartPlayerStateMachine();
dialogs = dialogs.getDialogsState();
gameState = gameState.getGameStateMachine();
powerCardStateMachine = powerCard.getPowerCardStateMachine();
settingsStateMachine = settings.getSettingsStateMachine();
turnState = turnState.getTurnState();
turnState = gameState.getTurnState();
//initialize the states
@@ -700,7 +696,7 @@ public void testWaitToGameEndState() {
*/
@Test
public void testTurnSubStatesToGameEndState() {
// Implementation goes here
// todo Implementation goes here
}
/**
@@ -708,7 +704,7 @@ public void testTurnSubStatesToGameEndState() {
*/
@Test
public void testTurnSubStatesToWait() {
// Implementation goes here
// todo Implementation goes here
}
/**
@@ -716,7 +712,7 @@ public void testTurnSubStatesToWait() {
*/
@Test
public void testTurnSubStatesToSpectator() {
// Implementation goes here
// todo Implementation goes here
}
/**
@@ -724,7 +720,7 @@ public void testTurnSubStatesToSpectator() {
*/
@Test
public void testSpectatorToGameEndState() {
// Implementation goes here
// todo Implementation goes here
}
/**
@@ -1001,7 +997,7 @@ public void testChoosePieceToMovePiece() {
*/
@Test
public void testMovePieceToWait() {
// Implementation goes here
// Todo Implementation goes here
}
/**
@@ -1009,7 +1005,7 @@ public void testMovePieceToWait() {
*/
@Test
public void testMovePieceToSpectator() {
// Implementation goes here
// Todo Implementation goes here
}
/**
@@ -1017,7 +1013,7 @@ public void testMovePieceToSpectator() {
*/
@Test
public void testMovePieceToCeremony() {
// Implementation goes here
// Todo Implementation goes here
}
/**
@@ -1025,7 +1021,7 @@ public void testMovePieceToCeremony() {
*/
@Test
public void testStayInChoosePowerCard() {
// Implementation goes here
// Todo Implementation goes here
}
/**
@@ -1508,7 +1504,7 @@ public void testStartPieceToChoosePieceEndState() {
*/
@Test
public void testRollRankingDiceToWaitRanking() {
// Implementation goes here
// Todo Implementation goes here
}
/**
@@ -1516,7 +1512,7 @@ public void testRollRankingDiceToWaitRanking() {
*/
@Test
public void testWaitRankingToRollRankingDice() {
// Implementation goes here
// Todo Implementation goes here
}
/**
@@ -1524,7 +1520,7 @@ public void testWaitRankingToRollRankingDice() {
*/
@Test
public void testWaitRankingToEndStateDetermineStartingPlayer() {
// Implementation goes here
// Todo Implementation goes here
}
/**
@@ -1591,7 +1587,7 @@ public void testMainSettingsToAudioSettings() {
*/
@Test
public void testMainSettingsToClientState() {
// Implementation goes here
// Todo Implementation goes here
}
/**
@@ -1659,7 +1655,7 @@ public void testAudioSettingsToMainSettings() {
*/
@Test
public void testClientStateSubStatesToMainSettings() {
// Implementation goes here
// todo Implementation goes here
}
}

View File

@@ -42,6 +42,7 @@ public class ServerStateTest {
private SelectCard selectCard;
private SelectedPieces selectedPieces;
private SelectTSK selectTSK;
private Disconnected disconnect;
//declare state-machines here
private CeremonyState ceremonyState;
@@ -229,7 +230,10 @@ public void testServerGameSubStatesToInterrupt() {
serverGameLogic.setCurrentState(gameState);
assertEquals(serverGameLogic.getCurrentState(),gameState);
//TODO create interrupt
//Todo
//sends the interrupt
serverGameLogic.received(disconnect,from);
//tests if the server is in the Interrupt-state
assertEquals(serverGameLogic.getInterruptState(),interruptState);
@@ -242,12 +246,12 @@ public void testServerGameSubStatesToInterrupt() {
public void testServerGameToCeremony() {
//sends the server in the gameState
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//Todo game is finished
//tests if the server is in the Ceremony-state
assertTrue(serverGameLogic.getCurrentState() instanceof CeremonyState);
assertEquals(serverGameLogic.getCurrentState() ,ceremonyState);
}
/**
@@ -257,13 +261,15 @@ public void testServerGameToCeremony() {
public void testInterruptToGameContinue() {
//sends the server in the Interrupt-State
serverGameLogic.setCurrentState(interruptState);
assertTrue(serverGameLogic.getCurrentState() instanceof InterruptState);
assertEquals(serverGameLogic.getCurrentState() ,interruptState);
//Todo send all other messages except forceContinue
//sends the continue-message to the server
serverGameLogic.received(forceContinueGame, from);
//tests if new Stet is in GameState
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
}
/**
@@ -273,12 +279,12 @@ public void testInterruptToGameContinue() {
public void testInterruptToGameReconnect() {
//sends the server in the Interrupt-State
serverGameLogic.setCurrentState(interruptState);
assertTrue(serverGameLogic.getCurrentState() instanceof InterruptState);
assertEquals(serverGameLogic.getCurrentState() ,interruptState);
//todo implement the timer
//tests if new Stet is in GameState
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
}
/**
@@ -288,12 +294,12 @@ public void testInterruptToGameReconnect() {
public void testInterruptToGameTimer() {
//sends the server in the Interrupt-State
serverGameLogic.setCurrentState(interruptState);
assertTrue(serverGameLogic.getCurrentState() instanceof InterruptState);
assertEquals(serverGameLogic.getCurrentState() ,interruptState);
//Todo implement the timer
//tests if new Stet is in GameState
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
}
/**
@@ -312,17 +318,17 @@ public void testCeremonyToServerStateEndState() {
public void testDetermineStartPlayerToDetermineStartPlayer1() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in DSP-state
gameState.setCurrentState(determineStartPlayerState);
assertTrue(gameState.getCurrentState() instanceof DetermineStartPlayerState);
assertEquals(gameState.getCurrentState() ,determineStartPlayerState);
//TODO sends messages to the server
//tests if the server is still in DSP-state
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof DetermineStartPlayerState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,determineStartPlayerState);
}
/**
@@ -332,17 +338,26 @@ public void testDetermineStartPlayerToDetermineStartPlayer1() {
public void testDetermineStartPlayerToDetermineStartPlayer2() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in DSP-state
gameState.setCurrentState(determineStartPlayerState);
assertTrue(gameState.getCurrentState() instanceof DetermineStartPlayerState);
assertEquals(gameState.getCurrentState() ,determineStartPlayerState);
//TODO sends messages 2 RequestDiceMessage, die gleich geränkt werden to the server
//sends the requestDiceMessage to the server
gameState.received(requestDice, from);
//tests if the server is still in DSP-state
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof DetermineStartPlayerState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,determineStartPlayerState);
//sends the requestDiceMessage to the server
gameState.received(requestMove, fromHost);
//tests if the server is still in DSP-state
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,determineStartPlayerState);
}
/**
@@ -352,17 +367,17 @@ public void testDetermineStartPlayerToDetermineStartPlayer2() {
public void testDetermineStartPlayerToAnimation() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in DSP-state
gameState.setCurrentState(determineStartPlayerState);
assertTrue(gameState.getCurrentState() instanceof DetermineStartPlayerState);
assertEquals(gameState.getCurrentState() ,determineStartPlayerState);
//TODO sends messages 2 RequestDiceMessage, die ungleich geränkt werden, sodass der server weitergeht
//tests if the Server is in animationState
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof Animation);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,animation);
}
/**
@@ -373,26 +388,24 @@ public void testDetermineStartPlayerToAnimation() {
public void testAnimationToPowerCard() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in Animation
gameState.setCurrentState(animation);
assertTrue(gameState.getCurrentState() instanceof Animation);
assertEquals(gameState.getCurrentState() ,animation);
//receives one animation endMessage and tests if the server is still in the Animation-state
serverGameLogic.received(animationEnd, fromHost);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof Animation);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,animation);
//receives another animation endMessage
serverGameLogic.received(animationEnd, from);
//tests if the server is in the PowerCard-state
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
TurnState turnState1 = (TurnState) gameState.getCurrentState();
TurnState turnState = (TurnState) turnState1.getTurnState();
assertTrue(turnState.getCurrentState() instanceof PowerCardState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,powerCardState);
}
/**
@@ -403,17 +416,17 @@ public void testAnimationToPowerCard() {
public void testTurnToAnimation() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//todo set the turn finished and there are still two players left
//tests if the server is in the AnimationState
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof Animation);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,animation);
}
/**
@@ -424,16 +437,16 @@ public void testTurnToAnimation() {
public void testTurnToGameEndState() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//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(serverGameLogic.getCurrentState() instanceof CeremonyState);
assertEquals(serverGameLogic.getCurrentState() ,ceremonyState);
}
/**
@@ -444,22 +457,22 @@ public void testTurnToGameEndState() {
public void testStayInPowerCard() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the TurnState in PowerCard
turnState.setCurrentState(powerCardState);
assertTrue(turnState.getCurrentState() instanceof PowerCardState);
assertEquals(turnState.getCurrentState() ,powerCardState);
//Todo: receive messages which dont lead to a state change
//tests if the server is in PowerCard
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof PowerCardState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,powerCardState);
}
/**
@@ -470,22 +483,22 @@ public void testStayInPowerCard() {
public void testPowerCardToPlayPowerCard() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the TurnState in PowerCard
turnState.setCurrentState(powerCardState);
assertTrue(turnState.getCurrentState() instanceof PowerCardState);
assertEquals(turnState.getCurrentState() ,powerCardState);
//todo
//tests if the server is in PlayPowerCard
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof PlayPowerCard);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,playPowerCard);
}
/**
@@ -496,32 +509,30 @@ public void testPowerCardToPlayPowerCard() {
public void testPlayPowerCardToRollDice() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the TurnState in PowerCard
turnState.setCurrentState(playPowerCard);
assertTrue(turnState.getCurrentState() instanceof PlayPowerCard);
assertEquals(turnState.getCurrentState() ,playPowerCard);
//receive first AnimationEndMessage from the host
serverGameLogic.received(animationEnd, fromHost);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof PlayPowerCard);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,playPowerCard);
//receive second AnimationEndMessage
serverGameLogic.received(animationEnd, from);
//tests if the server is in RollDice and in FirstRoll
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof RollDiceState);
RollDiceState rollDiceState = (RollDiceState) turnState.getCurrentState();
RollDiceMachine rollDiceMachine1 = rollDiceState.getRollDiceStateMachine();
assertTrue(rollDiceMachine1.getCurrentState() instanceof FirstRollStateState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,rollDiceState);
assertEquals(rollDiceState.getCurrentState() ,firstRollState);
}
/**
@@ -532,21 +543,21 @@ public void testPlayPowerCardToRollDice() {
public void testChoosePieceToMovePiece() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the TurnState in ChoosePiece
turnState.setCurrentState(choosePieceState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
//Todo ???
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof MovePieceState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,movePieceState);
}
/**
@@ -557,15 +568,15 @@ public void testChoosePieceToMovePiece() {
public void testMovePieceToTurnEndState() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the TurnState in MovePiece
turnState.setCurrentState(movePieceState);
assertTrue(turnState.getCurrentState() instanceof MovePieceState);
assertEquals(turnState.getCurrentState() ,movePieceState);
//Todo no 6 was rolled, so the server looks, if there are 2 or less player are still in the game
//TODO
@@ -580,24 +591,22 @@ public void testMovePieceToTurnEndState() {
public void testMovePieceToFirstRoll() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the TurnState in MovePiece
turnState.setCurrentState(movePieceState);
assertTrue(turnState.getCurrentState() instanceof MovePieceState);
assertEquals(turnState.getCurrentState() ,movePieceState);
//Todo the player rolled a 6 and the player is not finished
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof RollDiceState);
RollDiceState rollDiceState = (RollDiceState) turnState.getCurrentState();
RollDiceMachine rollDiceMachine1 = rollDiceState.getRollDiceStateMachine();
assertTrue(rollDiceMachine1.getCurrentState() instanceof FirstRollStateState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,rollDiceState);
assertEquals(rollDiceState.getCurrentState() ,firstRollStateState);
}
/**
@@ -608,29 +617,27 @@ public void testMovePieceToFirstRoll() {
public void testFirstRollToRollDiceEndState() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the TurnState in RollDice
turnState.setCurrentState(rollDiceState);
assertTrue(turnState.getCurrentState() instanceof RollDiceState);
assertEquals(turnState.getCurrentState() ,rollDiceState);
//sends the RollDiceMachine in FirstRoll
rollDiceMachine.setCurrentState(firstRollState);
assertTrue(rollDiceMachine.getCurrentState() instanceof FirstRollStateState);
assertEquals(rollDiceMachine.getCurrentState() ,firstRollStateState);
//TODO 2 Möglichkeiten
//tests if the server is in NoPiece of ChoosePiece
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
ChoosePieceState choosePieceState1 = (ChoosePieceState) turnState.getCurrentState();
ChoosePieceStateMachine choosePieceState = choosePieceState1.getChoosePieceStateMachine();
assertTrue(choosePieceState.getCurrentState() instanceof NoPieceState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
assertEquals(choosePieceState.getCurrentState() ,noPieceState);
}
/**
@@ -641,27 +648,27 @@ public void testFirstRollToRollDiceEndState() {
public void testFirstRollToSecondRoll() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the TurnState in RollDice
turnState.setCurrentState(rollDiceState);
assertTrue(turnState.getCurrentState() instanceof RollDiceState);
assertEquals(turnState.getCurrentState() ,rollDiceState);
//sends the RollDiceMachine in FirstRoll
rollDiceMachine.setCurrentState(firstRollState);
assertTrue(rollDiceMachine.getCurrentState() instanceof FirstRollStateState);
assertEquals(rollDiceMachine.getCurrentState() ,firstRollStateState);
//Todo player has no figures to move and had no 6
//tests if the server is in the SecondRoll
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof RollDiceState);
assertTrue(rollDiceMachine.getCurrentState() instanceof SecondRollState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,rollDiceState);
assertEquals(rollDiceMachine.getCurrentState() ,secondRollState);
}
/**
@@ -672,29 +679,27 @@ public void testFirstRollToSecondRoll() {
public void testSecondRollToRollDiceEndState() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the TurnState in RollDice
turnState.setCurrentState(rollDiceState);
assertTrue(turnState.getCurrentState() instanceof RollDiceState);
assertEquals(turnState.getCurrentState() ,rollDiceState);
//sends the RollDiceMachine in SecondRoll
rollDiceMachine.setCurrentState(secondRoll);
assertTrue(rollDiceMachine.getCurrentState() instanceof SecondRollState);
assertEquals(rollDiceMachine.getCurrentState() ,secondRollState);
//Todo
//tests if the server is in NoPiece of ChoosePiece
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
ChoosePieceState choosePieceState1 = (ChoosePieceState) turnState.getCurrentState();
ChoosePieceStateMachine choosePieceState = choosePieceState1.getChoosePieceStateMachine();
assertTrue(choosePieceState.getCurrentState() instanceof NoPieceState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
assertEquals(choosePieceState.getCurrentState() ,noPieceState);
}
/**
@@ -705,27 +710,27 @@ public void testSecondRollToRollDiceEndState() {
public void testSecondRollToThirdRoll() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the TurnState in RollDice
turnState.setCurrentState(rollDiceState);
assertTrue(turnState.getCurrentState() instanceof RollDiceState);
assertEquals(turnState.getCurrentState() ,rollDiceState);
//sends the RollDiceMachine in SecondRoll
rollDiceMachine.setCurrentState(secondRoll);
assertTrue(rollDiceMachine.getCurrentState() instanceof SecondRollState);
assertEquals(rollDiceMachine.getCurrentState() ,secondRollState);
//Todo player has no figures to move and had no 6
//tests if the server is in the ThirdRoll
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof RollDiceState);
assertTrue(rollDiceMachine.getCurrentState() instanceof ThirdRollState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,rollDiceState);
assertEquals(rollDiceMachine.getCurrentState() ,thirdRollState);
}
/**
@@ -736,29 +741,27 @@ public void testSecondRollToThirdRoll() {
public void testThirdRollToRollDiceEndState() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the TurnState in RollDice
turnState.setCurrentState(rollDiceState);
assertTrue(turnState.getCurrentState() instanceof RollDiceState);
assertEquals(turnState.getCurrentState() ,rollDiceState);
//sends the RollDiceMachine in ThirdRoll
rollDiceMachine.setCurrentState(thirdRoll);
assertTrue(rollDiceMachine.getCurrentState() instanceof ThirdRollState);
assertEquals(rollDiceMachine.getCurrentState() ,thirdRollState);
//Todo
//tests if the server is in NoPiece of ChoosePiece
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
ChoosePieceState choosePieceState1 = (ChoosePieceState) turnState.getCurrentState();
ChoosePieceStateMachine choosePieceState = choosePieceState1.getChoosePieceStateMachine();
assertTrue(choosePieceState.getCurrentState() instanceof NoPieceState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
assertEquals(choosePieceState.getCurrentState() ,noPieceState);
}
/**
@@ -769,19 +772,19 @@ public void testThirdRollToRollDiceEndState() {
public void testThirdRollToTurnEndState() {
//sends the server in Game-State
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the gameState in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the TurnState in RollDice
turnState.setCurrentState(rollDiceState);
assertTrue(turnState.getCurrentState() instanceof RollDiceState);
assertEquals(turnState.getCurrentState() ,rollDiceState);
//sends the RollDiceMachine in ThirdRoll
rollDiceMachine.setCurrentState(thirdRoll);
assertTrue(rollDiceMachine.getCurrentState() instanceof ThirdRollState);
assertEquals(rollDiceMachine.getCurrentState() ,thirdRollState);
//Todo
}
@@ -794,27 +797,27 @@ public void testThirdRollToTurnEndState() {
public void testNoPieceToWaitingPiece() {
//sends the server in GameState
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the server in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the server in ChoosePiece
turnState.setCurrentState(choosePieceState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
//sends the server in NoPiece
choosePieceState.setCurrentState(noPiece);
assertTrue(choosePieceState.getCurrentState() instanceof NoPieceState);
assertEquals(choosePieceState.getCurrentState() ,noPieceState);
//TODO
//tests if the server is in WaitingPiece
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertTrue(choosePieceState.getCurrentState() instanceof WaitingPieceState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
assertEquals(choosePieceState.getCurrentState() ,waitingPieceState);
}
@@ -826,27 +829,27 @@ public void testNoPieceToWaitingPiece() {
public void testNoPieceToNoTurn() {
//sends the server in GameState
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the server in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the server in ChoosePiece
turnState.setCurrentState(choosePieceState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
//sends the server in NoPiece
choosePieceState.setCurrentState(noPiece);
assertTrue(choosePieceState.getCurrentState() instanceof NoPieceState);
assertEquals(choosePieceState.getCurrentState() ,noPieceState);
//TODO
//tests if the server is in NoTurn
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertTrue(choosePieceState.getCurrentState() instanceof NoTurnState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
assertEquals(choosePieceState.getCurrentState() ,noTurnState);
}
/**
@@ -857,19 +860,19 @@ public void testNoPieceToNoTurn() {
public void testNoTurnToTurnEndState() {
//sends the server in GameState
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the server in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the server in ChoosePiece
turnState.setCurrentState(choosePieceState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
//sends the server in NoTurn
choosePieceState.setCurrentState(noTurnState);
assertTrue(choosePieceState.getCurrentState() instanceof NoTurnState);
assertEquals(choosePieceState.getCurrentState() ,noTurnState);
//TODO
}
@@ -882,27 +885,27 @@ public void testNoTurnToTurnEndState() {
public void testStayInWaitingPiece() {
//sends the server in GameState
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the server in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the server in ChoosePiece
turnState.setCurrentState(choosePieceState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
//sends the server in WaitingPiece
choosePieceState.setCurrentState(waitingPiece);
assertTrue(choosePieceState.getCurrentState() instanceof WaitingPieceState);
assertEquals(choosePieceState.getCurrentState() ,waitingPieceState);
//TODO
//tests if the server is in WaitingPiece
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertTrue(choosePieceState.getCurrentState() instanceof WaitingPieceState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
assertEquals(choosePieceState.getCurrentState() ,waitingPieceState);
}
/**
@@ -913,19 +916,19 @@ public void testStayInWaitingPiece() {
public void testWaitingPieceToMovePiece() {
//sends the server in GameState
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the server in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the server in ChoosePiece
turnState.setCurrentState(choosePieceState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
//sends the server in WaitingPiece
choosePieceState.setCurrentState(waitingPiece);
assertTrue(choosePieceState.getCurrentState() instanceof WaitingPieceState);
assertEquals(choosePieceState.getCurrentState() ,waitingPieceState);
//TODO
}
@@ -938,27 +941,27 @@ public void testWaitingPieceToMovePiece() {
public void testNoPieceToSelectPiece() {
//sends the server in GameState
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the server in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the server in ChoosePiece
turnState.setCurrentState(choosePieceState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
//sends the server in NoPiece
choosePieceState.setCurrentState(noPiece);
assertTrue(choosePieceState.getCurrentState() instanceof NoPieceState);
assertEquals(choosePieceState.getCurrentState() ,noPieceState);
//TODO
//tests if the server is in SelectPiece
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertTrue(choosePieceState.getCurrentState() instanceof SelectPieceState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
assertEquals(choosePieceState.getCurrentState() ,selectPieceState);
}
/**
@@ -969,27 +972,27 @@ public void testNoPieceToSelectPiece() {
public void testNoPieceToStartPiece() {
//sends the server in GameState
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the server in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the server in ChoosePiece
turnState.setCurrentState(choosePieceState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
//sends the server in NoPiece
choosePieceState.setCurrentState(noPiece);
assertTrue(choosePieceState.getCurrentState() instanceof NoPieceState);
assertEquals(choosePieceState.getCurrentState() ,noPieceState);
//TODO
//tests if the server is in StartPiece
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertTrue(choosePieceState.getCurrentState() instanceof StartPieceState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
assertEquals(choosePieceState.getCurrentState() ,startPieceState);
}
/**
@@ -1000,27 +1003,27 @@ public void testNoPieceToStartPiece() {
public void testStayInSelectPiece() {
//sends the server in GameState
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the server in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the server in ChoosePiece
turnState.setCurrentState(choosePieceState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
//sends the server in SelectPiece
choosePieceState.setCurrentState(selectPiece);
assertTrue(choosePieceState.getCurrentState() instanceof SelectPieceState);
assertEquals(choosePieceState.getCurrentState() ,selectPieceState);
//TODO
//tests if the server is in SelectPiece
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertTrue(choosePieceState.getCurrentState() instanceof SelectPieceState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
assertEquals(choosePieceState.getCurrentState() ,selectPieceState);
}
/**
@@ -1031,21 +1034,26 @@ public void testStayInSelectPiece() {
public void testSelectPieceToMovePiece() {
//sends the server in GameState
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the server in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the server in ChoosePiece
turnState.setCurrentState(choosePieceState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
//sends the server in SelectPiece
choosePieceState.setCurrentState(selectPiece);
assertTrue(choosePieceState.getCurrentState() instanceof SelectPieceState);
assertEquals(choosePieceState.getCurrentState() ,selectPieceState);
//TODO
//tests if the server is in movePiece-state
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,movePieceState);
}
/**
@@ -1056,27 +1064,27 @@ public void testSelectPieceToMovePiece() {
public void testStayInStartPiece() {
//sends the server in GameState
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the server in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the server in ChoosePiece
turnState.setCurrentState(choosePieceState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
//sends the server in StartPiece
choosePieceState.setCurrentState(startPiece);
assertTrue(choosePieceState.getCurrentState() instanceof StartPieceState);
assertEquals(choosePieceState.getCurrentState() ,startPieceState);
//TODO
//tests if the server is in StartPiece
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertTrue(choosePieceState.getCurrentState() instanceof StartPieceState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
assertEquals(choosePieceState.getCurrentState() ,startPieceState);
}
/**
@@ -1087,20 +1095,25 @@ public void testStayInStartPiece() {
public void testStartPieceToMovePiece() {
//sends the server in GameState
serverGameLogic.setCurrentState(gameState);
assertTrue(serverGameLogic.getCurrentState() instanceof GameState);
assertEquals(serverGameLogic.getCurrentState() ,gameState);
//sends the server in Turn
gameState.setCurrentState(turnState);
assertTrue(gameState.getCurrentState() instanceof TurnState);
assertEquals(gameState.getCurrentState() ,turnState);
//sends the server in ChoosePiece
turnState.setCurrentState(choosePieceState);
assertTrue(turnState.getCurrentState() instanceof ChoosePieceState);
assertEquals(turnState.getCurrentState() ,choosePieceState);
//sends the server in StartPiece
choosePieceState.setCurrentState(startPiece);
assertTrue(choosePieceState.getCurrentState() instanceof StartPieceState);
assertEquals(choosePieceState.getCurrentState() ,startPieceState);
//TODO
//tests if the server is in movePiece-state
assertEquals(serverGameLogic.getCurrentState() ,gameState);
assertEquals(gameState.getCurrentState() ,turnState);
assertEquals(turnState.getCurrentState() ,movePieceState);
}
}