added one testmethod

This commit is contained in:
Benjamin Feyer
2024-12-02 22:43:11 +01:00
parent 50ac201277
commit 2434ede556

View File

@@ -2,6 +2,7 @@
import org.junit.Before;
import org.junit.Test;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.client.RequestDieMessage;
import pp.mdga.message.client.RequestMoveMessage;
import pp.mdga.message.client.RequestPlayCardMessage;
@@ -1079,7 +1080,47 @@ public void testUseShield() {
*/
@Test
public void testLoseShield() {
// TODO: Implement test logic for when a piece loses its shield
//sets activePlayer to client
game.setActiveColor(clientColor);
//set shieldState.ACTIVE im pieceHost1
pieceHost1.setShield(ShieldState.ACTIVE);
//set die to 5
game.setDie(die5);
//sends the server in selectPiece
serverGameLogic.setCurrentState(gameState);
serverGameLogic.getGameState().setCurrentState(turnState);
serverGameLogic.getGameState().getTurnState().setCurrentState(choosePieceState);
serverGameLogic.getGameState().getTurnState().getChoosePieceState().setCurrentState(selectPieceState);
//tests if the server is in selectPieces
assertEquals(serverGameLogic.getCurrentState(),gameState);
assertEquals(gameState.getCurrentState(), turnState);
assertEquals(turnState.getCurrentState(),choosePieceState);
assertEquals(choosePieceState.getCurrentState(),selectPieceState);
//send requestDice-message
serverGameLogic.received(new RequestDieMessage(),IDClient);
//send requestMove-message for clientPiece0
serverGameLogic.received(new RequestMoveMessage(pieceClient0.getUuid()),IDClient);
//tests if the server is in animation-state
assertEquals(serverGameLogic.getCurrentState(),gameState);
assertEquals(gameState.getCurrentState(), gameState.getAnimationState());
//send 3 animationEndMessage
serverGameLogic.received(new AnimationEndMessage(),IDClient);
serverGameLogic.received(new AnimationEndMessage(),IDHost);
serverGameLogic.received(new AnimationEndMessage(),IDCyber);
//test for new Player
assertEquals(serverGameLogic.getGame().getActiveColor(),hostColor);
//tests, if the shieldState is NONE
assertEquals(pieceHost1.getShield(),ShieldState.NONE);
}
/**