diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 7d6b8d52..b973fe54 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -154,7 +154,7 @@ public void send(ClientMessage msg) { endOfTurn = new EndOfTurnMessage(); lobbyAccept = new LobbyAcceptMessage(); lobbyDeny = new LobbyDenyMessage(); - lobbyPlayerJoin = new LobbyPlayerJoinedMessage(from, player); + lobbyPlayerJoin = new LobbyPlayerJoinedMessage(from, player,true); lobbyPlayerLeave = new LobbyPlayerLeaveMessage(from); moveMessage = new MoveMessage(ownPiece.getUuid(), false, 25); noTurn = new NoTurnMessage(); 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 f5aa68c6..5c75b3d4 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 @@ -16,6 +16,9 @@ import pp.mdga.server.automaton.game.turn.choosepiece.SelectPieceState; import pp.mdga.server.automaton.game.turn.rolldice.FirstRollState; +import java.sql.SQLOutput; +import java.util.Map; + import static org.junit.Assert.*; /** @@ -63,6 +66,14 @@ public class PieceTest { ChoosePieceState choosePieceState; SelectPieceState selectPieceState; + //declare dies + private Die die1; + private Die die2; + private Die die3; + private Die die4; + private Die die5; + private Die die6; + //declare messages here @@ -89,11 +100,30 @@ public void disconnectClient(int id) { } }, game); + //declare player-Client here playerClient = new Player(nameClient); clientColor = Color.ARMY; + playerClient.setColor(clientColor); game.addPlayer(IDClient, playerClient); + //declare player-host here + playerHost = new Player(nameHost); + hostColor = Color.NAVY; + playerHost.setColor(hostColor); + game.addPlayer(IDHost, playerHost); + + System.out.println(game.getPlayers().get(IDClient)); + System.out.println(game.getPlayers().get(IDHost)); + + //initialize the playerData + for(Map.Entry entry : game.getPlayers().entrySet()){ + game.getBoard().addPlayerData(entry.getValue().getColor(),new PlayerData(entry.getValue().getColor())); + } + + System.out.println(game.getBoard().getPlayerData().get(clientColor)); + System.out.println(game.getBoard().getPlayerData().get(hostColor)); + //declare pieces of client here pieceClient0 = game.getBoard().getPlayerData().get(clientColor).getPieces()[0]; pieceClient1 = game.getBoard().getPlayerData().get(clientColor).getPieces()[1]; @@ -105,10 +135,6 @@ public void disconnectClient(int id) { game.getBoard().getPlayerData().get(clientColor).removePieceFromWaitingArea(); } - //declare player-host here - playerHost = new Player(nameHost); - hostColor = Color.NAVY; - game.addPlayer(IDHost, playerHost); //declare pieces of host here pieceHost0 = game.getBoard().getPlayerData().get(hostColor).getPieces()[0]; @@ -148,6 +174,15 @@ public void disconnectClient(int id) { firstRollState= rollDiceState.getFirstRollState(); choosePieceState= turnState.getChoosePieceState(); selectPieceState= choosePieceState.getSelectPieceState(); + + //initialize dies + die1 = new Die(1); + die2= new Die(2); + die3 = new Die(3); + die4 = new Die(4); + die5 = new Die(5); + die6 = new Die(6); + } /** @@ -173,7 +208,9 @@ public void testMove() { //sets the active Player to host game.setActiveColor(hostColor); - //sets the die-class todo + //sets the die-class, to roll 4's + Die die = new Die(4); + game.setDie(die4); //sends the request-die-message serverGameLogic.received(new RequestDieMessage(),IDHost); @@ -195,17 +232,38 @@ public void testMove() { @Test public void testCantMove() { // TODO: Implement test logic for when a piece can't move - //send server in selectPiece-state + //sends the server in selectPiece + serverGameLogic.setCurrentState(gameState); + serverGameLogic.getGameState().setCurrentState(turnState); + serverGameLogic.getGameState().getTurnState().setCurrentState(choosePieceState); + serverGameLogic.getGameState().getTurnState().getChoosePieceState().setCurrentState(selectPieceState); - //set active player + //tests if the server is in selectPieces + assertEquals(serverGameLogic.getCurrentState(),gameState); + assertEquals(gameState.getCurrentState(), turnState); + assertEquals(turnState.getCurrentState(),choosePieceState); + assertEquals(choosePieceState.getCurrentState(),selectPieceState); + + //set active player to army + game.setActiveColor(hostColor); //set die-class + game.setDie(die2); //send request Die-message + serverGameLogic.received(new RequestDieMessage(),IDHost); - //send .......... + //send requestMove-Message + serverGameLogic.received(new RequestMoveMessage(pieceHost2.getUuid()),IDHost); - //test + //tests if the hostPiece2 is still at idx 19 and the server is still in selectable pieces + assertTrue(game.getBoard().getInfield()[19].isOccupied()); + assertEquals(game.getBoard().getInfield()[19].getOccupant(),pieceHost2); + + assertEquals(serverGameLogic.getCurrentState(),gameState); + assertEquals(gameState.getCurrentState(), turnState); + assertEquals(turnState.getCurrentState(),choosePieceState); + assertEquals(choosePieceState.getCurrentState(),selectPieceState); } /**