diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/game/GameTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/game/GameTest.java index a8819bca..1a22d83a 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/game/GameTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/game/GameTest.java @@ -6,7 +6,11 @@ import pp.mdga.game.card.ShieldCard; import pp.mdga.game.card.SwapCard; import pp.mdga.game.card.TurboCard; +import pp.mdga.message.client.AnimationEndMessage; import pp.mdga.message.client.LobbyReadyMessage; +import pp.mdga.message.client.NoPowerCardMessage; +import pp.mdga.message.client.RequestDieMessage; +import pp.mdga.message.client.RequestMoveMessage; import pp.mdga.message.client.SelectTSKMessage; import pp.mdga.message.client.StartGameMessage; import pp.mdga.message.server.PlayCardMessage; @@ -211,7 +215,66 @@ public void testDouble() { // UC-Game-08 @Test public void testChangeActivePlayer() { - // TODO: Implement test logic for changing the active player + //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()); }