added Piecetest T005/T006
This commit is contained in:
		@@ -17,6 +17,8 @@
 | 
			
		||||
import pp.mdga.message.server.ServerMessage;
 | 
			
		||||
import pp.mdga.server.ServerGameLogic;
 | 
			
		||||
import pp.mdga.server.ServerSender;
 | 
			
		||||
import pp.mdga.server.automaton.game.TurnState;
 | 
			
		||||
import pp.mdga.server.automaton.game.turn.RollDiceState;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 | 
			
		||||
@@ -183,15 +185,160 @@ public void testPlayerFinishes() {
 | 
			
		||||
        // TODO: Implement test logic for player finishes
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // UC-Game-04
 | 
			
		||||
    /**
 | 
			
		||||
     * * this test-method tests that the player has 3 chances to roll a 6, if all his pieces are in the waiting-area
 | 
			
		||||
     * <p>
 | 
			
		||||
     * T005
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testAllPiecesInWaitingArea() {
 | 
			
		||||
        // TODO: Implement test logic for checking if all pieces are in the waiting area
 | 
			
		||||
        //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 gameStartMessage
 | 
			
		||||
        logic.received(new StartGameMessage(), IDHost);
 | 
			
		||||
        assertEquals(logic.getCurrentState(), logic.getGameState());
 | 
			
		||||
 | 
			
		||||
        //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());
 | 
			
		||||
 | 
			
		||||
        //set all pieces of host in waiting-field
 | 
			
		||||
        game.getBoard().getInfield()[playerHost.getStartNodeIndex()].getOccupant().setState(PieceState.WAITING);
 | 
			
		||||
        playerHost.addWaitingPiece(game.getBoard().getInfield()[playerHost.getStartNodeIndex()].getOccupant());
 | 
			
		||||
        game.getBoard().getInfield()[playerHost.getStartNodeIndex()].clearOccupant();
 | 
			
		||||
 | 
			
		||||
        logic.received(new AnimationEndMessage(), IDHost);
 | 
			
		||||
        logic.received(new AnimationEndMessage(), IDClient);
 | 
			
		||||
 | 
			
		||||
        logic.received(new NoPowerCardMessage(), IDHost);
 | 
			
		||||
 | 
			
		||||
        //tests if the server is in first-roll
 | 
			
		||||
        assertEquals(logic.getCurrentState(), logic.getGameState());
 | 
			
		||||
        assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getTurnState());
 | 
			
		||||
        TurnState turn = logic.getGameState().getTurnState();
 | 
			
		||||
        assertEquals(turn.getCurrentState(), turn.getRollDiceState());
 | 
			
		||||
        RollDiceState rollDiceState = turn.getRollDiceState();
 | 
			
		||||
        assertEquals(rollDiceState.getCurrentState(), rollDiceState.getFirstRollState());
 | 
			
		||||
 | 
			
		||||
        game.setDie(new Die(5));
 | 
			
		||||
        logic.received(new RequestDieMessage(), IDHost);
 | 
			
		||||
        logic.received(new AnimationEndMessage(), IDHost);
 | 
			
		||||
 | 
			
		||||
        //tests if the server is in second-roll-state
 | 
			
		||||
        assertEquals(logic.getCurrentState(), logic.getGameState());
 | 
			
		||||
        assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getTurnState());
 | 
			
		||||
        assertEquals(turn.getCurrentState(), turn.getRollDiceState());
 | 
			
		||||
        assertEquals(rollDiceState.getCurrentState(), rollDiceState.getSecondRollState());
 | 
			
		||||
 | 
			
		||||
        game.setDie(new Die(5));
 | 
			
		||||
        logic.received(new RequestDieMessage(), IDHost);
 | 
			
		||||
        logic.received(new AnimationEndMessage(), IDHost);
 | 
			
		||||
 | 
			
		||||
        //tests if the server is in second-roll-state
 | 
			
		||||
        assertEquals(logic.getCurrentState(), logic.getGameState());
 | 
			
		||||
        assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getTurnState());
 | 
			
		||||
        assertEquals(turn.getCurrentState(), turn.getRollDiceState());
 | 
			
		||||
        assertEquals(rollDiceState.getCurrentState(), rollDiceState.getThirdRollState());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * this test-method tests that the player has 3 chances to roll a 6, if all his pieces are in the waiting-area
 | 
			
		||||
     * and if he rolls a 6, he can choose a piece out of the waiting-area
 | 
			
		||||
     * T006
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void test3TriesFor6() {
 | 
			
		||||
        // TODO: Implement test logic for checking 3 tries for rolling a 6
 | 
			
		||||
        //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 gameStartMessage
 | 
			
		||||
        logic.received(new StartGameMessage(), IDHost);
 | 
			
		||||
        assertEquals(logic.getCurrentState(), logic.getGameState());
 | 
			
		||||
 | 
			
		||||
        //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());
 | 
			
		||||
 | 
			
		||||
        //set all pieces of host in waiting-field
 | 
			
		||||
        game.getBoard().getInfield()[playerHost.getStartNodeIndex()].getOccupant().setState(PieceState.WAITING);
 | 
			
		||||
        playerHost.addWaitingPiece(game.getBoard().getInfield()[playerHost.getStartNodeIndex()].getOccupant());
 | 
			
		||||
        game.getBoard().getInfield()[playerHost.getStartNodeIndex()].clearOccupant();
 | 
			
		||||
 | 
			
		||||
        logic.received(new AnimationEndMessage(), IDHost);
 | 
			
		||||
        logic.received(new AnimationEndMessage(), IDClient);
 | 
			
		||||
 | 
			
		||||
        logic.received(new NoPowerCardMessage(), IDHost);
 | 
			
		||||
 | 
			
		||||
        //tests if the server is in first-roll
 | 
			
		||||
        assertEquals(logic.getCurrentState(), logic.getGameState());
 | 
			
		||||
        assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getTurnState());
 | 
			
		||||
        TurnState turn = logic.getGameState().getTurnState();
 | 
			
		||||
        assertEquals(turn.getCurrentState(), turn.getRollDiceState());
 | 
			
		||||
        RollDiceState rollDiceState = turn.getRollDiceState();
 | 
			
		||||
        assertEquals(rollDiceState.getCurrentState(), rollDiceState.getFirstRollState());
 | 
			
		||||
 | 
			
		||||
        game.setDie(new Die(5));
 | 
			
		||||
        logic.received(new RequestDieMessage(), IDHost);
 | 
			
		||||
        logic.received(new AnimationEndMessage(), IDHost);
 | 
			
		||||
 | 
			
		||||
        //tests if the server is in second-roll-state
 | 
			
		||||
        assertEquals(logic.getCurrentState(), logic.getGameState());
 | 
			
		||||
        assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getTurnState());
 | 
			
		||||
        assertEquals(turn.getCurrentState(), turn.getRollDiceState());
 | 
			
		||||
        assertEquals(rollDiceState.getCurrentState(), rollDiceState.getSecondRollState());
 | 
			
		||||
 | 
			
		||||
        game.setDie(new Die(6));
 | 
			
		||||
        logic.received(new RequestDieMessage(), IDHost);
 | 
			
		||||
        logic.received(new AnimationEndMessage(), IDHost);
 | 
			
		||||
 | 
			
		||||
        //tests if the server is in second-roll-state
 | 
			
		||||
        assertEquals(logic.getCurrentState(), logic.getGameState());
 | 
			
		||||
        assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getTurnState());
 | 
			
		||||
        assertEquals(turn.getCurrentState(), turn.getChoosePieceState());
 | 
			
		||||
        assertEquals(turn.getChoosePieceState().getWaitingPieceState(), turn.getChoosePieceState().getCurrentState());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // UC-Game-05
 | 
			
		||||
@@ -305,7 +452,12 @@ public void testDouble() {
 | 
			
		||||
        assertEquals(game.getActiveColor(), playerHost.getColor());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // UC-Game-08
 | 
			
		||||
    /**
 | 
			
		||||
     *
 | 
			
		||||
     * this test-method tests that the next Player is set, after the current player has finished his turn
 | 
			
		||||
     * <p>
 | 
			
		||||
     * T010
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testChangeActivePlayer() {
 | 
			
		||||
        //tests if both player have no color and are not ready
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user