From eff011f69f9f8ec1074afe57971479e1f2bcf223 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Fri, 29 Nov 2024 00:13:06 +0100 Subject: [PATCH] implemented more tests for the clientStartgame --- .../client/clientState/ClientStateTest.java | 185 +++++++++++++++++- 1 file changed, 180 insertions(+), 5 deletions(-) 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 36d28410..57c19de5 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 @@ -1802,7 +1802,62 @@ public void testStartPieceToChoosePieceEndState() { */ @Test public void testRollRankingDiceToWaitRanking() { - // Todo Implementation goes here + //sends the ClientAutomaton in GameState + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState(), gameState); + + //sends the gameState in the determineStartPlayer + gameState.setState(determineStartPlayer); + assertEquals(gameState.getState(), determineStartPlayer); + + //sends the turnStatemachine in ChoosePiece + determineStartPlayer.setState(rollRankingDice); + assertEquals(determineStartPlayer.getState(), rollRankingDice); + + //sends all messages that don't indicate a state-change + clientGameLogic.received(activePlayer); + clientGameLogic.received(anyPiece); + clientGameLogic.received(briefing); + clientGameLogic.received(ceremonyMessage); + //clientGameLogic.received(die); + clientGameLogic.received(diceAgain); + clientGameLogic.received(diceNow); + clientGameLogic.received(endOfTurn); + clientGameLogic.received(lobbyAccept); + clientGameLogic.received(lobbyDeny); + clientGameLogic.received(lobbyPlayerJoin); + clientGameLogic.received(lobbyPlayerLeave); + clientGameLogic.received(moveMessage); + clientGameLogic.received(noTurn); + clientGameLogic.received(interruptMessage); + clientGameLogic.received(playCardSwap); + clientGameLogic.received(playCardShield); + clientGameLogic.received(playCardTurbo); + clientGameLogic.received(possibleCard); + clientGameLogic.received(possiblePiece); + clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingRollAgain); + clientGameLogic.received(reconnectBriefing); + clientGameLogic.received(resumeGame); + clientGameLogic.received(startGame); + clientGameLogic.received(startPieceMessage); + clientGameLogic.received(updateReady); + clientGameLogic.received(updateTSK); + clientGameLogic.received(waitPiece); + clientGameLogic.received(spectatorMessage); + + //test if the client is still in rollRankingDice + assertEquals(clientGameLogic.getState(), gameState); + assertEquals(gameState.getLogic(),determineStartPlayer); + assertEquals(determineStartPlayer.getState(),rollRankingDice); + + //sends die-message + clientGameLogic.received(die); + + //test if the client is in waitRanking + assertEquals(clientGameLogic.getState(), gameState); + assertEquals(gameState.getLogic(),determineStartPlayer); + assertEquals(determineStartPlayer.getState(),waitRanking); } /** @@ -1810,7 +1865,62 @@ public void testRollRankingDiceToWaitRanking() { */ @Test public void testWaitRankingToRollRankingDice() { - // Todo Implementation goes here + //sends the ClientAutomaton in GameState + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState(), gameState); + + //sends the gameState in the determineStartPlayer + gameState.setState(determineStartPlayer); + assertEquals(gameState.getState(), determineStartPlayer); + + //sends the turnStatemachine in ChoosePiece + determineStartPlayer.setState(waitRanking); + assertEquals(determineStartPlayer.getState(), waitRanking); + + //sends all messages that don't indicate a state-change + clientGameLogic.received(activePlayer); + clientGameLogic.received(anyPiece); + clientGameLogic.received(briefing); + clientGameLogic.received(ceremonyMessage); + clientGameLogic.received(die); + clientGameLogic.received(diceAgain); + clientGameLogic.received(diceNow); + //clientGameLogic.received(endOfTurn); + clientGameLogic.received(lobbyAccept); + clientGameLogic.received(lobbyDeny); + clientGameLogic.received(lobbyPlayerJoin); + clientGameLogic.received(lobbyPlayerLeave); + clientGameLogic.received(moveMessage); + clientGameLogic.received(noTurn); + clientGameLogic.received(interruptMessage); + clientGameLogic.received(playCardSwap); + clientGameLogic.received(playCardShield); + clientGameLogic.received(playCardTurbo); + clientGameLogic.received(possibleCard); + clientGameLogic.received(possiblePiece); + clientGameLogic.received(rankingResponce); + //clientGameLogic.received(rankingRollAgain); + clientGameLogic.received(reconnectBriefing); + clientGameLogic.received(resumeGame); + clientGameLogic.received(startGame); + clientGameLogic.received(startPieceMessage); + clientGameLogic.received(updateReady); + clientGameLogic.received(updateTSK); + clientGameLogic.received(waitPiece); + clientGameLogic.received(spectatorMessage); + + //test if the client is still in waitRanking + assertEquals(clientGameLogic.getState(), gameState); + assertEquals(gameState.getLogic(),determineStartPlayer); + assertEquals(determineStartPlayer.getState(),waitRanking); + + //sends rankingRollAgain-message + clientGameLogic.received(rankingRollAgain); + + //test if the client is in rollRankingDice + assertEquals(clientGameLogic.getState(), gameState); + assertEquals(gameState.getLogic(),determineStartPlayer); + assertEquals(determineStartPlayer.getState(),rollRankingDice); } /** @@ -1818,7 +1928,61 @@ public void testWaitRankingToRollRankingDice() { */ @Test public void testWaitRankingToEndStateDetermineStartingPlayer() { - // Todo Implementation goes here + //sends the ClientAutomaton in GameState + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState(), gameState); + + //sends the gameState in the determineStartPlayer + gameState.setState(determineStartPlayer); + assertEquals(gameState.getState(), determineStartPlayer); + + //sends the turnStatemachine in ChoosePiece + determineStartPlayer.setState(waitRanking); + assertEquals(determineStartPlayer.getState(), waitRanking); + + //sends all messages that don't indicate a state-change + clientGameLogic.received(activePlayer); + clientGameLogic.received(anyPiece); + clientGameLogic.received(briefing); + clientGameLogic.received(ceremonyMessage); + clientGameLogic.received(die); + clientGameLogic.received(diceAgain); + clientGameLogic.received(diceNow); + //clientGameLogic.received(endOfTurn); + clientGameLogic.received(lobbyAccept); + clientGameLogic.received(lobbyDeny); + clientGameLogic.received(lobbyPlayerJoin); + clientGameLogic.received(lobbyPlayerLeave); + clientGameLogic.received(moveMessage); + clientGameLogic.received(noTurn); + clientGameLogic.received(interruptMessage); + clientGameLogic.received(playCardSwap); + clientGameLogic.received(playCardShield); + clientGameLogic.received(playCardTurbo); + clientGameLogic.received(possibleCard); + clientGameLogic.received(possiblePiece); + clientGameLogic.received(rankingResponce); + //clientGameLogic.received(rankingRollAgain); + clientGameLogic.received(reconnectBriefing); + clientGameLogic.received(resumeGame); + clientGameLogic.received(startGame); + clientGameLogic.received(startPieceMessage); + clientGameLogic.received(updateReady); + clientGameLogic.received(updateTSK); + clientGameLogic.received(waitPiece); + clientGameLogic.received(spectatorMessage); + + //test if the client is still in waitRanking + assertEquals(clientGameLogic.getState(), gameState); + assertEquals(gameState.getLogic(),determineStartPlayer); + assertEquals(determineStartPlayer.getState(),waitRanking); + + //sends endOfTurn-message + clientGameLogic.received(endOfTurn); + + //test if the client is in wait + assertEquals(clientGameLogic.getState(), gameState); + assertEquals(gameState.getLogic(),waiting); } /** @@ -1846,8 +2010,19 @@ public void testPodiumToStatistics() { */ @Test public void testStatisticsToCeremonyEndState() { - // Implementation goes here - //TODO + //sends the client in ceremony + clientGameLogic.setState(ceremony); + assertEquals(clientGameLogic.getState(), ceremony); + + //sends the ceremony in statistics + ceremony.setState(statistics); + assertEquals(ceremony.getState(),statistics); + + //TODO simulate button-push + + //tests if client is in startDialog + assertEquals(clientGameLogic.getState(), dialogs); + assertEquals(dialogs.getState(),startDialog); } /**