added testcase T004
This commit is contained in:
		@@ -269,10 +269,98 @@ public void testGameFinishes() {
 | 
			
		||||
        assertEquals(logic.getCurrentState(), logic.getCeremonyState());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // UC-Game-03
 | 
			
		||||
    /**
 | 
			
		||||
     * this test-method is used to test, when a player finishes
 | 
			
		||||
     * <p>
 | 
			
		||||
     * T003
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testPlayerFinishes() {
 | 
			
		||||
        // TODO: Implement test logic for player finishes
 | 
			
		||||
        //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());
 | 
			
		||||
 | 
			
		||||
        logic.received(new AnimationEndMessage(), IDHost);
 | 
			
		||||
        logic.received(new AnimationEndMessage(), IDClient);
 | 
			
		||||
 | 
			
		||||
        //set all pieces except one in the home, the other direct in front of the home
 | 
			
		||||
        Piece piece1 = game.getBoard().getInfield()[playerHost.getStartNodeIndex()].getOccupant();
 | 
			
		||||
        Piece piece2 = playerHost.getWaitingArea()[1];
 | 
			
		||||
        Piece piece3 = playerHost.getWaitingArea()[2];
 | 
			
		||||
        Piece piece4 = playerHost.getWaitingArea()[3];
 | 
			
		||||
        piece1.setState(PieceState.HOMEFINISHED);
 | 
			
		||||
        piece2.setState(PieceState.HOMEFINISHED);
 | 
			
		||||
        piece3.setState(PieceState.HOMEFINISHED);
 | 
			
		||||
        piece4.setState(PieceState.ACTIVE);
 | 
			
		||||
        playerHost.removeWaitingPiece(piece1);
 | 
			
		||||
        playerHost.removeWaitingPiece(piece2);
 | 
			
		||||
        playerHost.removeWaitingPiece(piece3);
 | 
			
		||||
        playerHost.removeWaitingPiece(piece4);
 | 
			
		||||
        playerHost.setPieceInHome(3,piece1);
 | 
			
		||||
        playerHost.setPieceInHome(2,piece2);
 | 
			
		||||
        playerHost.setPieceInHome(1,piece3);
 | 
			
		||||
 | 
			
		||||
        game.getBoard().getInfield()[playerHost.getStartNodeIndex()-1].setOccupant(piece4);
 | 
			
		||||
 | 
			
		||||
        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(1));
 | 
			
		||||
        logic.received(new RequestDieMessage(), IDHost);
 | 
			
		||||
        logic.received(new AnimationEndMessage(), IDHost);
 | 
			
		||||
 | 
			
		||||
        //tests if the server is in choose-piece-state
 | 
			
		||||
        assertEquals(logic.getCurrentState(), logic.getGameState());
 | 
			
		||||
        assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getTurnState());
 | 
			
		||||
        assertEquals(turn.getCurrentState(), turn.getChoosePieceState());
 | 
			
		||||
        assertEquals(turn.getChoosePieceState().getSelectPieceState(), turn.getChoosePieceState().getCurrentState());
 | 
			
		||||
 | 
			
		||||
        logic.received(new RequestMoveMessage(piece4),IDHost);
 | 
			
		||||
        //tests if the server is in choose-piece-state
 | 
			
		||||
        assertEquals(logic.getCurrentState(), logic.getGameState());
 | 
			
		||||
        assertEquals(logic.getGameState().getCurrentState(), logic.getGameState().getTurnState());
 | 
			
		||||
        assertEquals(turn.getCurrentState(), turn.getMovePieceState());
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        logic.received(new AnimationEndMessage(),IDHost);
 | 
			
		||||
        logic.received(new AnimationEndMessage(),IDClient);
 | 
			
		||||
 | 
			
		||||
        assertTrue(playerHost.isFinished());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user