added the game-test 6/7 (T008-T009)
This commit is contained in:
@@ -203,18 +203,54 @@ public void testGameTerminates() {
|
||||
// UC-Game-06
|
||||
@Test
|
||||
public void testStartingOrder() {
|
||||
// TODO: Implement test logic for verifying starting order of players
|
||||
//tests if both player have no color and are not ready
|
||||
assertFalse(playerClient.isReady());
|
||||
assertFalse(playerHost.isReady());
|
||||
assertEquals(playerClient.getColor(), Color.NONE);
|
||||
assertEquals(playerHost.getColor(), Color.NONE);
|
||||
|
||||
//send the selectTSK-message
|
||||
logic.received(new SelectTSKMessage(Color.CYBER), IDClient);
|
||||
logic.received(new SelectTSKMessage(Color.ARMY), IDHost);
|
||||
|
||||
//sends and tests the readyMessage for the client
|
||||
logic.received(new LobbyReadyMessage(), IDClient);
|
||||
logic.received(new LobbyReadyMessage(), IDHost);
|
||||
assertTrue(playerClient.isReady());
|
||||
assertTrue(playerHost.isReady());
|
||||
|
||||
//tests if the game has started after the determineStartPlayerState
|
||||
logic.received(new StartGameMessage(), IDHost);
|
||||
assertEquals(logic.getCurrentState(), logic.getGameState());
|
||||
assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getDetermineStartPlayerState());
|
||||
|
||||
//roll the order
|
||||
game.setDie(new Die(4));
|
||||
logic.received(new RequestDieMessage(), IDHost);
|
||||
game.setDie(new Die(3));
|
||||
logic.received(new RequestDieMessage(), IDClient);
|
||||
logic.received(new AnimationEndMessage(), IDClient);
|
||||
logic.received(new AnimationEndMessage(), IDHost);
|
||||
|
||||
//tests that the server is in the animation-state
|
||||
assertEquals(logic.getCurrentState(), logic.getGameState());
|
||||
assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getAnimationState());
|
||||
|
||||
logic.received(new AnimationEndMessage(), IDClient);
|
||||
logic.received(new AnimationEndMessage(), IDHost);
|
||||
|
||||
assertEquals(logic.getCurrentState(), logic.getGameState());
|
||||
assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getTurnState());
|
||||
|
||||
//tests if the host is the active player
|
||||
assertEquals(game.getActiveColor(), playerHost.getColor());
|
||||
|
||||
assertEquals(playerHost.getColor().next(game), playerClient.getColor());
|
||||
}
|
||||
|
||||
// UC-Game-07
|
||||
@Test
|
||||
public void testDouble() {
|
||||
// TODO: Implement test logic for testing the double rule
|
||||
}
|
||||
|
||||
// UC-Game-08
|
||||
@Test
|
||||
public void testChangeActivePlayer() {
|
||||
//tests if both player have no color and are not ready
|
||||
assertFalse(playerClient.isReady());
|
||||
assertFalse(playerHost.isReady());
|
||||
@@ -239,14 +275,25 @@ public void testChangeActivePlayer() {
|
||||
//roll the order
|
||||
game.setDie(new Die(4));
|
||||
logic.received(new RequestDieMessage(),IDHost);
|
||||
game.setDie(new Die(3));
|
||||
logic.received(new RequestDieMessage(),IDClient);
|
||||
logic.received(new AnimationEndMessage(),IDClient);
|
||||
logic.received(new AnimationEndMessage(),IDHost);
|
||||
|
||||
//tests that the server is in the determineStartPlayer-state
|
||||
assertEquals(logic.getCurrentState(), logic.getGameState());
|
||||
assertEquals(logic.getGameState().getCurrentState(),logic.getGameState().getDetermineStartPlayerState());
|
||||
|
||||
//roll the order the second time
|
||||
game.setDie(new Die(4));
|
||||
logic.received(new RequestDieMessage(), IDHost);
|
||||
game.setDie(new Die(3));
|
||||
logic.received(new RequestDieMessage(), IDClient);
|
||||
logic.received(new AnimationEndMessage(), IDClient);
|
||||
logic.received(new AnimationEndMessage(), IDHost);
|
||||
|
||||
//tests that the server is in the animation-state
|
||||
assertEquals(logic.getCurrentState(), logic.getGameState());
|
||||
assertEquals(logic.getGameState().getCurrentState(),logic.getGameState().getAnimationState());
|
||||
assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getAnimationState());
|
||||
|
||||
logic.received(new AnimationEndMessage(),IDClient);
|
||||
logic.received(new AnimationEndMessage(),IDHost);
|
||||
@@ -256,27 +303,72 @@ public void testChangeActivePlayer() {
|
||||
|
||||
//tests if the host is the active player
|
||||
assertEquals(game.getActiveColor(),playerHost.getColor());
|
||||
|
||||
//hosts plays no power-card
|
||||
logic.received(new NoPowerCardMessage(),IDHost);
|
||||
|
||||
//simulates a roll and the move of a piece for the host
|
||||
logic.received(new RequestDieMessage(),IDHost);
|
||||
logic.received(new AnimationEndMessage(),IDHost);
|
||||
logic.received(new RequestMoveMessage(game.getBoard().getInfield()[playerHost.getStartNodeIndex()].getOccupant()),IDHost);
|
||||
|
||||
//tests if the server is in movePiece
|
||||
assertEquals(logic.getGameState().getCurrentState(),logic.getGameState().getTurnState());
|
||||
assertEquals(logic.getGameState().getTurnState().getCurrentState(),logic.getGameState().getTurnState().getMovePieceState());
|
||||
|
||||
//sends the animationEndMessages
|
||||
logic.received(new AnimationEndMessage(),IDClient);
|
||||
logic.received(new AnimationEndMessage(),IDHost);
|
||||
|
||||
//tests if there is a new active Player
|
||||
assertEquals(game.getActiveColor(),playerClient.getColor());
|
||||
}
|
||||
|
||||
// UC-Game-08
|
||||
@Test
|
||||
public void testChangeActivePlayer() {
|
||||
//tests if both player have no color and are not ready
|
||||
assertFalse(playerClient.isReady());
|
||||
assertFalse(playerHost.isReady());
|
||||
assertEquals(playerClient.getColor(), Color.NONE);
|
||||
assertEquals(playerHost.getColor(), Color.NONE);
|
||||
|
||||
//send the selectTSK-message
|
||||
logic.received(new SelectTSKMessage(Color.CYBER), IDClient);
|
||||
logic.received(new SelectTSKMessage(Color.ARMY), IDHost);
|
||||
|
||||
//sends and tests the readyMessage for the client
|
||||
logic.received(new LobbyReadyMessage(), IDClient);
|
||||
logic.received(new LobbyReadyMessage(), IDHost);
|
||||
assertTrue(playerClient.isReady());
|
||||
assertTrue(playerHost.isReady());
|
||||
|
||||
//tests if the game has started after the determineStartPlayerState
|
||||
logic.received(new StartGameMessage(), IDHost);
|
||||
assertEquals(logic.getCurrentState(), logic.getGameState());
|
||||
assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getDetermineStartPlayerState());
|
||||
|
||||
//roll the order
|
||||
game.setDie(new Die(4));
|
||||
logic.received(new RequestDieMessage(), IDHost);
|
||||
game.setDie(new Die(3));
|
||||
logic.received(new RequestDieMessage(), IDClient);
|
||||
logic.received(new AnimationEndMessage(), IDClient);
|
||||
logic.received(new AnimationEndMessage(), IDHost);
|
||||
|
||||
//tests that the server is in the animation-state
|
||||
assertEquals(logic.getCurrentState(), logic.getGameState());
|
||||
assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getAnimationState());
|
||||
|
||||
logic.received(new AnimationEndMessage(), IDClient);
|
||||
logic.received(new AnimationEndMessage(), IDHost);
|
||||
|
||||
assertEquals(logic.getCurrentState(), logic.getGameState());
|
||||
assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getTurnState());
|
||||
|
||||
//tests if the host is the active player
|
||||
assertEquals(game.getActiveColor(), playerHost.getColor());
|
||||
|
||||
//hosts plays no power-card
|
||||
logic.received(new NoPowerCardMessage(), IDHost);
|
||||
|
||||
//simulates a roll and the move of a piece for the host
|
||||
logic.received(new RequestDieMessage(), IDHost);
|
||||
logic.received(new AnimationEndMessage(), IDHost);
|
||||
logic.received(new RequestMoveMessage(game.getBoard().getInfield()[playerHost.getStartNodeIndex()].getOccupant()), IDHost);
|
||||
|
||||
//tests if the server is in movePiece
|
||||
assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getTurnState());
|
||||
assertEquals(logic.getGameState().getTurnState().getCurrentState(), logic.getGameState().getTurnState().getMovePieceState());
|
||||
|
||||
//sends the animationEndMessages
|
||||
logic.received(new AnimationEndMessage(), IDClient);
|
||||
logic.received(new AnimationEndMessage(), IDHost);
|
||||
|
||||
//tests if there is a new active Player
|
||||
assertEquals(game.getActiveColor(), playerClient.getColor());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUseTurbo() {
|
||||
|
||||
Reference in New Issue
Block a user