added the game-test 6/7 (T008-T009)
This commit is contained in:
@@ -203,13 +203,106 @@ public void testGameTerminates() {
|
|||||||
// UC-Game-06
|
// UC-Game-06
|
||||||
@Test
|
@Test
|
||||||
public void testStartingOrder() {
|
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
|
// UC-Game-07
|
||||||
@Test
|
@Test
|
||||||
public void testDouble() {
|
public void testDouble() {
|
||||||
// TODO: Implement test logic for testing the double rule
|
//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);
|
||||||
|
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());
|
||||||
|
|
||||||
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
// UC-Game-08
|
// UC-Game-08
|
||||||
@@ -277,7 +370,6 @@ public void testChangeActivePlayer() {
|
|||||||
assertEquals(game.getActiveColor(), playerClient.getColor());
|
assertEquals(game.getActiveColor(), playerClient.getColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUseTurbo() {
|
public void testUseTurbo() {
|
||||||
//TODO
|
//TODO
|
||||||
|
|||||||
Reference in New Issue
Block a user