fixed some tests
This commit is contained in:
@@ -76,4 +76,13 @@ public StatisticsState getStatisticsState(){
|
||||
public CeremonyStates getState(){
|
||||
return currentState;
|
||||
}
|
||||
|
||||
/**
|
||||
* this method is used to parse the selectNext from the clientGameLogic
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void selectNext(){
|
||||
currentState.selectNext();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ public class ClientStateTest {
|
||||
//private todo
|
||||
|
||||
//declare server-messages here
|
||||
private ShutdownMessage shutdownMessage;
|
||||
private ActivePlayerMessage activePlayer;
|
||||
private AnyPieceMessage anyPiece;
|
||||
private BriefingMessage briefing;
|
||||
@@ -110,6 +111,7 @@ public class ClientStateTest {
|
||||
private SpectatorMessage spectatorMessage;
|
||||
private SelectPieceMessage selectPieceMessage;
|
||||
|
||||
private Color enemyColor;
|
||||
private int from;
|
||||
private String name;
|
||||
private Color color;
|
||||
@@ -176,6 +178,9 @@ public void accept(Visitor visitor) {
|
||||
//declare other player
|
||||
enemy= new Player(name);
|
||||
enemy.setColor(Color.CYBER);
|
||||
enemyColor=Color.CYBER;
|
||||
game.addPlayer(2345,enemy);
|
||||
enemy.initialize();
|
||||
|
||||
//sets the player in the game
|
||||
|
||||
@@ -186,6 +191,7 @@ public void accept(Visitor visitor) {
|
||||
|
||||
|
||||
//initialize the messages from the server
|
||||
shutdownMessage = new ShutdownMessage();
|
||||
activePlayer = new ActivePlayerMessage(color);
|
||||
anyPiece = new AnyPieceMessage();
|
||||
briefing = new BriefingMessage();
|
||||
@@ -258,6 +264,11 @@ public void accept(Visitor visitor) {
|
||||
waitingPiece = choosePiece.getWaitingPiece();
|
||||
selectPiece = choosePiece.getSelectPiece();
|
||||
startPiece = choosePiece.getStartPiece();
|
||||
|
||||
|
||||
player.initialize();
|
||||
game.addPlayer(1234,player);
|
||||
game.setActiveColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -433,7 +444,7 @@ public void testGameToDialogs() {
|
||||
assertEquals(clientGameLogic.getState(), gameState);
|
||||
|
||||
//receives a GameClosedMessage
|
||||
//clientGameLogic.received();//TODO
|
||||
clientGameLogic.received(shutdownMessage);
|
||||
|
||||
assertEquals(clientGameLogic.getState(), dialogs);
|
||||
assertEquals(dialogs.getState(), startDialog);
|
||||
@@ -493,6 +504,7 @@ public void testClientInterruptToGame() {
|
||||
//sends the ClientGameLogic in Interrupt
|
||||
clientGameLogic.setState(interrupt);
|
||||
assertEquals(clientGameLogic.getState(), interrupt);
|
||||
interrupt.setPreviousState(gameState);
|
||||
|
||||
//sends the continue message
|
||||
clientGameLogic.received(resumeGame);
|
||||
@@ -510,8 +522,8 @@ public void testInterruptToDialogs() {
|
||||
clientGameLogic.setState(interrupt);
|
||||
assertEquals(clientGameLogic.getState(), interrupt);
|
||||
|
||||
//Todo send the server-closed
|
||||
//clientGameLogic.received();
|
||||
//send the server-closed
|
||||
clientGameLogic.received(shutdownMessage);
|
||||
|
||||
//tests if the client is in the startDialog
|
||||
assertEquals(clientGameLogic.getState(), dialogs);
|
||||
@@ -553,7 +565,7 @@ public void testStartDialogToNetworkDialog1() {
|
||||
assertEquals(dialogs.getState(), startDialog);
|
||||
|
||||
//simulate the button-push for the join-Button
|
||||
clientGameLogic.selectJoin(name);
|
||||
clientGameLogic.selectName(name);
|
||||
|
||||
//tests if the client is in the network-dialog
|
||||
assertEquals(clientGameLogic.getState(), dialogs);
|
||||
@@ -578,12 +590,14 @@ public void testStartDialogToNetworkDialog2() {
|
||||
assertEquals(dialogs.getState(), startDialog);
|
||||
|
||||
//simulate the button-push for the host-Button
|
||||
clientGameLogic.selectHost(name);
|
||||
clientGameLogic.selectName(name);
|
||||
|
||||
//tests if the client is in the network-dialog
|
||||
assertEquals(clientGameLogic.getState(), dialogs);
|
||||
assertEquals(dialogs.getState(), networkDialog);
|
||||
|
||||
clientGameLogic.received(new LobbyAcceptMessage(1234));
|
||||
|
||||
//tests if the client is host
|
||||
assertTrue(clientGameLogic.isHost());
|
||||
}
|
||||
@@ -680,6 +694,7 @@ public void testNetworkDialogToNetworkDialog2() {
|
||||
assertEquals(dialogs.getState(), networkDialog);
|
||||
|
||||
//todo simulate try connect to server with send: join-lobby and received lobby-refuse-message
|
||||
clientGameLogic.received(new LobbyDenyMessage());
|
||||
|
||||
assertEquals(clientGameLogic.getState(), dialogs);
|
||||
assertEquals(dialogs.getState(), networkDialog);
|
||||
@@ -698,7 +713,9 @@ public void testNetworkDialogToLobby() {
|
||||
dialogs.setState(networkDialog);
|
||||
assertEquals(dialogs.getState(), networkDialog);
|
||||
|
||||
//todo simulate connect to server with send lobby request
|
||||
//simulate connect to server with send lobby request
|
||||
clientGameLogic.selectJoin("IP");
|
||||
clientGameLogic.received(new LobbyAcceptMessage(1234) );
|
||||
|
||||
assertEquals(clientGameLogic.getState(), dialogs);
|
||||
assertEquals(dialogs.getState(), lobby);
|
||||
@@ -827,8 +844,18 @@ public void testDetermineStartPlayerToWait() {
|
||||
gameState.setState(determineStartPlayer);
|
||||
assertEquals(gameState.getState(), determineStartPlayer);
|
||||
|
||||
//sends the determineStartPlayer into WaitRanking
|
||||
determineStartPlayer.setState(waitRanking);
|
||||
assertEquals(determineStartPlayer.getState(), waitRanking);
|
||||
|
||||
//sends the message, that indicate a statechange to wait
|
||||
clientGameLogic.received(noTurn);
|
||||
clientGameLogic.received(activePlayer);
|
||||
clientGameLogic.selectAnimationEnd();
|
||||
|
||||
//tests if the
|
||||
assertEquals(clientGameLogic.getState(), gameState);
|
||||
assertEquals(gameState.getState(), determineStartPlayer);
|
||||
assertEquals(determineStartPlayer.getState(),determineStartPlayer.getIntro());
|
||||
|
||||
//tests if the client is in the Wait-State
|
||||
assertEquals(clientGameLogic.getState(), gameState);
|
||||
@@ -895,6 +922,7 @@ public void testWaitToAnimation() {
|
||||
@Test
|
||||
public void testWaitToTurn() {
|
||||
//sends client in gameState
|
||||
game.setActiveColor(enemyColor);
|
||||
clientGameLogic.setState(gameState);
|
||||
assertEquals(clientGameLogic.getState(), gameState);
|
||||
|
||||
@@ -2721,7 +2749,6 @@ public void testRollRankingDiceToWaitRanking() {
|
||||
clientGameLogic.received(activePlayer);
|
||||
clientGameLogic.received(anyPiece);
|
||||
clientGameLogic.received(briefing);
|
||||
clientGameLogic.received(ceremonyMessage);
|
||||
//clientGameLogic.received(die);
|
||||
clientGameLogic.received(diceAgain);
|
||||
clientGameLogic.received(diceNow);
|
||||
@@ -2785,25 +2812,19 @@ public void testWaitRankingToRollRankingDice() {
|
||||
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(rankingResponse);
|
||||
//clientGameLogic.received(rankingRollAgain);
|
||||
clientGameLogic.received(reconnectBriefing);
|
||||
clientGameLogic.received(resumeGame);
|
||||
clientGameLogic.received(startGame);
|
||||
@@ -2820,7 +2841,7 @@ public void testWaitRankingToRollRankingDice() {
|
||||
assertEquals(determineStartPlayer.getState(), waitRanking);
|
||||
|
||||
//sends rankingRollAgain-message
|
||||
clientGameLogic.received(rankingRollAgain);
|
||||
clientGameLogic.received(diceNow);
|
||||
|
||||
//test if the client is in rollRankingDice
|
||||
assertEquals(clientGameLogic.getState(), gameState);
|
||||
@@ -2846,13 +2867,9 @@ public void testWaitRankingToEndStateDetermineStartingPlayer() {
|
||||
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);
|
||||
@@ -2860,21 +2877,18 @@ public void testWaitRankingToEndStateDetermineStartingPlayer() {
|
||||
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(rankingResponse);
|
||||
//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);
|
||||
clientGameLogic.received(selectPieceMessage);
|
||||
|
||||
@@ -2883,8 +2897,8 @@ public void testWaitRankingToEndStateDetermineStartingPlayer() {
|
||||
assertEquals(gameState.getState(), determineStartPlayer);
|
||||
assertEquals(determineStartPlayer.getState(), waitRanking);
|
||||
|
||||
//sends endOfTurn-message
|
||||
clientGameLogic.received(endOfTurn);
|
||||
//sends endOfTurn-message todo intro
|
||||
clientGameLogic.received(activePlayer);
|
||||
|
||||
//test if the client is in wait
|
||||
assertEquals(clientGameLogic.getState(), gameState);
|
||||
|
||||
Reference in New Issue
Block a user