From 702154c018f2a906e8762b22cdc5b94584ea0310 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Fri, 13 Dec 2024 02:52:11 +0100 Subject: [PATCH] fixed PieceTest18 --- .../src/test/java/pp/mdga/game/PieceTest.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/game/PieceTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/game/PieceTest.java index af7920c5..a84f80b2 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/game/PieceTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/game/PieceTest.java @@ -327,7 +327,7 @@ public void testMove() { * Use Case UC-Piece-02: Ensure that a piece cannot move if blocked by others. *

*/ - @Test + @Test (expected = RuntimeException.class) public void testCantMove() { //set active player to army game.setActiveColor(clientColor); @@ -349,6 +349,7 @@ public void testCantMove() { //send request Die-message serverGameLogic.received(new RequestDieMessage(),IDClient); + serverGameLogic.received(new AnimationEndMessage(),IDClient); //send requestMove-Message serverGameLogic.received(new RequestMoveMessage(pieceClient2),IDClient); @@ -896,7 +897,7 @@ public void testOnlyEnterOwnHouse() { serverGameLogic.received(new RequestMoveMessage(pieceHost1),IDHost); System.out.println(game.getBoard().getInfieldIndexOfPiece(pieceHost1)); - //tests if hostPiece1 is at idx 20 TODO false positive + //tests if hostPiece1 is at idx 20 assertTrue(game.getBoard().getInfield()[31].isOccupied()); assertEquals(game.getBoard().getInfield()[31].getOccupant(),pieceHost1); } @@ -1293,12 +1294,25 @@ public void testLoseShield() { public void testFinishedPiece() { //sets the active color to client game.setActiveColor(clientColor); + playerClient.setHandCards(new ArrayList<>()); - //sends the server in selectPiece + + //sends the server in RollDicePiece serverGameLogic.setCurrentState(gameState); serverGameLogic.getGameState().setCurrentState(turnState); - serverGameLogic.getGameState().getTurnState().setCurrentState(choosePieceState); - serverGameLogic.getGameState().getTurnState().getChoosePieceState().setCurrentState(selectPieceState); + + //tests if the server is in firstRoll-state + assertEquals(serverGameLogic.getCurrentState(),gameState); + assertEquals(gameState.getCurrentState(), turnState); + assertEquals(turnState.getCurrentState(),rollDiceState); + assertEquals(rollDiceState.getCurrentState(),firstRollState); + + //set the dice to 2 + game.setDie(die2); + + //sends the requestDie-Message + serverGameLogic.received(new RequestDieMessage(),IDClient); + serverGameLogic.received(new AnimationEndMessage(),IDClient); //tests if the server is in selectPieces assertEquals(serverGameLogic.getCurrentState(),gameState); @@ -1306,12 +1320,6 @@ public void testFinishedPiece() { assertEquals(turnState.getCurrentState(),choosePieceState); assertEquals(choosePieceState.getCurrentState(),selectPieceState); - //set the dice to 2 - game.setDie(die2); - //sends the requestDie-Message - serverGameLogic.received(new RequestDieMessage(),IDClient); - serverGameLogic.received(new AnimationEndMessage(),IDClient); - //sends the requestMove-Message serverGameLogic.received(new RequestMoveMessage(pieceClient1),IDClient);