fixed PieceTest18

This commit is contained in:
Benjamin Feyer
2024-12-13 02:52:11 +01:00
parent 032cd76ec2
commit 702154c018

View File

@@ -327,7 +327,7 @@ public void testMove() {
* Use Case UC-Piece-02: Ensure that a piece cannot move if blocked by others.
* </p>
*/
@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);