implemented more tests for the clientstatetests
This commit is contained in:
@@ -101,6 +101,7 @@ public class ClientStateTest {
|
|||||||
private UpdateReadyMessage updateReady;
|
private UpdateReadyMessage updateReady;
|
||||||
private UpdateTSKMessage updateTSK;
|
private UpdateTSKMessage updateTSK;
|
||||||
private WaitPieceMessage waitPiece;
|
private WaitPieceMessage waitPiece;
|
||||||
|
private SpectatorMessage spectatorMessage = new SpectatorMessage();
|
||||||
|
|
||||||
private int from;
|
private int from;
|
||||||
private String name;
|
private String name;
|
||||||
@@ -256,6 +257,7 @@ public void testDialogsToGame() {
|
|||||||
clientGameLogic.received(updateReady);
|
clientGameLogic.received(updateReady);
|
||||||
clientGameLogic.received(updateTSK);
|
clientGameLogic.received(updateTSK);
|
||||||
clientGameLogic.received(waitPiece);
|
clientGameLogic.received(waitPiece);
|
||||||
|
clientGameLogic.received(spectatorMessage);
|
||||||
|
|
||||||
//tests if the client is still in lobby
|
//tests if the client is still in lobby
|
||||||
assertEquals(clientGameLogic.getState(), dialogs);
|
assertEquals(clientGameLogic.getState(), dialogs);
|
||||||
@@ -321,6 +323,7 @@ public void testClientGameToCeremony() {
|
|||||||
clientGameLogic.received(updateReady);
|
clientGameLogic.received(updateReady);
|
||||||
clientGameLogic.received(updateTSK);
|
clientGameLogic.received(updateTSK);
|
||||||
clientGameLogic.received(waitPiece);
|
clientGameLogic.received(waitPiece);
|
||||||
|
clientGameLogic.received(spectatorMessage);
|
||||||
|
|
||||||
//tests if the client is still in game-state
|
//tests if the client is still in game-state
|
||||||
assertEquals(clientGameLogic.getState(), gameState);
|
assertEquals(clientGameLogic.getState(), gameState);
|
||||||
@@ -405,6 +408,7 @@ public void testStayInInterrupt() {
|
|||||||
clientGameLogic.received(updateReady);
|
clientGameLogic.received(updateReady);
|
||||||
clientGameLogic.received(updateTSK);
|
clientGameLogic.received(updateTSK);
|
||||||
clientGameLogic.received(waitPiece);
|
clientGameLogic.received(waitPiece);
|
||||||
|
clientGameLogic.received(spectatorMessage);
|
||||||
|
|
||||||
//tests if the client is in the interrupt
|
//tests if the client is in the interrupt
|
||||||
assertEquals(clientGameLogic.getState(), interrupt);
|
assertEquals(clientGameLogic.getState(), interrupt);
|
||||||
@@ -651,6 +655,7 @@ public void testStayInLobby() {
|
|||||||
clientGameLogic.received(updateReady);
|
clientGameLogic.received(updateReady);
|
||||||
clientGameLogic.received(updateTSK);
|
clientGameLogic.received(updateTSK);
|
||||||
clientGameLogic.received(waitPiece);
|
clientGameLogic.received(waitPiece);
|
||||||
|
clientGameLogic.received(spectatorMessage);
|
||||||
|
|
||||||
assertEquals(clientGameLogic.getState(), dialogs);
|
assertEquals(clientGameLogic.getState(), dialogs);
|
||||||
assertEquals(dialogs.getState(), lobby);
|
assertEquals(dialogs.getState(), lobby);
|
||||||
@@ -978,6 +983,7 @@ public void testStayInPlayPowerCard() {
|
|||||||
clientGameLogic.received(updateReady);
|
clientGameLogic.received(updateReady);
|
||||||
clientGameLogic.received(updateTSK);
|
clientGameLogic.received(updateTSK);
|
||||||
clientGameLogic.received(waitPiece);
|
clientGameLogic.received(waitPiece);
|
||||||
|
clientGameLogic.received(spectatorMessage);
|
||||||
|
|
||||||
//tests if the client is in PlayPowerCard
|
//tests if the client is in PlayPowerCard
|
||||||
assertEquals(clientGameLogic.getState(), gameState);
|
assertEquals(clientGameLogic.getState(), gameState);
|
||||||
@@ -1032,6 +1038,7 @@ public void testPlayPowerCardToRollDice() {
|
|||||||
clientGameLogic.received(updateReady);
|
clientGameLogic.received(updateReady);
|
||||||
clientGameLogic.received(updateTSK);
|
clientGameLogic.received(updateTSK);
|
||||||
clientGameLogic.received(waitPiece);
|
clientGameLogic.received(waitPiece);
|
||||||
|
clientGameLogic.received(spectatorMessage);
|
||||||
|
|
||||||
//tests if the client is in RollDice
|
//tests if the client is in RollDice
|
||||||
assertEquals(clientGameLogic.getState(), gameState);
|
assertEquals(clientGameLogic.getState(), gameState);
|
||||||
@@ -1094,6 +1101,7 @@ public void testStayInRollDice() {
|
|||||||
clientGameLogic.received(updateReady);
|
clientGameLogic.received(updateReady);
|
||||||
clientGameLogic.received(updateTSK);
|
clientGameLogic.received(updateTSK);
|
||||||
clientGameLogic.received(waitPiece);
|
clientGameLogic.received(waitPiece);
|
||||||
|
clientGameLogic.received(spectatorMessage);
|
||||||
|
|
||||||
//tests if the client is in RollDice
|
//tests if the client is in RollDice
|
||||||
assertEquals(clientGameLogic.getState(), gameState);
|
assertEquals(clientGameLogic.getState(), gameState);
|
||||||
@@ -1118,7 +1126,8 @@ public void testRollDiceToChoosePiece() {
|
|||||||
turnState.setState(rollDice);
|
turnState.setState(rollDice);
|
||||||
assertEquals(turnState.getState(), rollDice);
|
assertEquals(turnState.getState(), rollDice);
|
||||||
|
|
||||||
//TODO
|
//sends the die-message
|
||||||
|
clientGameLogic.received(die);
|
||||||
|
|
||||||
//tests if the client is in ChoosePiece-state
|
//tests if the client is in ChoosePiece-state
|
||||||
assertEquals(clientGameLogic.getState(), gameState);
|
assertEquals(clientGameLogic.getState(), gameState);
|
||||||
@@ -1143,15 +1152,17 @@ public void testRollDiceToWait() {
|
|||||||
turnState.setState(rollDice);
|
turnState.setState(rollDice);
|
||||||
assertEquals(turnState.getState(), rollDice);
|
assertEquals(turnState.getState(), rollDice);
|
||||||
|
|
||||||
//TODO
|
//sends the noTurn-message
|
||||||
|
clientGameLogic.received(noTurn);
|
||||||
|
|
||||||
|
//tests if the client is in wait
|
||||||
assertEquals(clientGameLogic.getState(), gameState);
|
assertEquals(clientGameLogic.getState(), gameState);
|
||||||
assertEquals(gameState.getState(), waiting);
|
assertEquals(gameState.getState(), waiting);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UC-ClientState-36: Test the transition from ChoosePiece to Wait.
|
* UC-ClientState-36: Test the transition from ChoosePiece to Wait.
|
||||||
* <p>
|
*
|
||||||
* this method tests the transition from noPiece to Wait
|
* this method tests the transition from noPiece to Wait
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@@ -1196,6 +1207,9 @@ public void testChoosePieceToMovePiece() {
|
|||||||
|
|
||||||
//Todo
|
//Todo
|
||||||
|
|
||||||
|
//sends the movePieceMessage
|
||||||
|
clientGameLogic.received(moveMessage);
|
||||||
|
|
||||||
//tests if the client is in the movePiece-state
|
//tests if the client is in the movePiece-state
|
||||||
assertEquals(clientGameLogic.getState(), gameState);
|
assertEquals(clientGameLogic.getState(), gameState);
|
||||||
assertEquals(gameState.getState(), turnState);
|
assertEquals(gameState.getState(), turnState);
|
||||||
@@ -1207,7 +1221,27 @@ public void testChoosePieceToMovePiece() {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMovePieceToWait() {
|
public void testMovePieceToWait() {
|
||||||
|
//sends the client into noPiece
|
||||||
|
clientGameLogic.setState(gameState);
|
||||||
|
assertEquals(clientGameLogic.getState(), gameState);
|
||||||
|
|
||||||
|
//sends the gameState into Turn
|
||||||
|
gameState.setState(turnState);
|
||||||
|
assertEquals(gameState.getState(), turnState);
|
||||||
|
|
||||||
|
//sends the turnState into movePiece
|
||||||
|
turnState.setState(choosePiece);
|
||||||
|
assertEquals(turnState.getState(), movePiece);
|
||||||
|
|
||||||
// Todo Implementation goes here
|
// Todo Implementation goes here
|
||||||
|
|
||||||
|
//sends the noTurnMessage
|
||||||
|
clientGameLogic.received(noTurn);
|
||||||
|
|
||||||
|
//tests if the client is in the movePiece-state
|
||||||
|
assertEquals(clientGameLogic.getState(), gameState);
|
||||||
|
assertEquals(gameState.getState(), turnState);
|
||||||
|
assertEquals(turnState.getState(), movePiece);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1215,7 +1249,26 @@ public void testMovePieceToWait() {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMovePieceToSpectator() {
|
public void testMovePieceToSpectator() {
|
||||||
|
//sends the client into noPiece
|
||||||
|
clientGameLogic.setState(gameState);
|
||||||
|
assertEquals(clientGameLogic.getState(), gameState);
|
||||||
|
|
||||||
|
//sends the gameState into Turn
|
||||||
|
gameState.setState(turnState);
|
||||||
|
assertEquals(gameState.getState(), turnState);
|
||||||
|
|
||||||
|
//sends the turnState into movePiece
|
||||||
|
turnState.setState(choosePiece);
|
||||||
|
assertEquals(turnState.getState(), movePiece);
|
||||||
|
|
||||||
// Todo Implementation goes here
|
// Todo Implementation goes here
|
||||||
|
|
||||||
|
//sends the spectator-message
|
||||||
|
clientGameLogic.received(spectatorMessage);
|
||||||
|
|
||||||
|
//tests if the client is in Spectator
|
||||||
|
assertEquals(clientGameLogic.getState(), gameState);
|
||||||
|
assertEquals(gameState.getState(),spectator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1223,7 +1276,26 @@ public void testMovePieceToSpectator() {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMovePieceToCeremony() {
|
public void testMovePieceToCeremony() {
|
||||||
|
//sends the client into noPiece
|
||||||
|
clientGameLogic.setState(gameState);
|
||||||
|
assertEquals(clientGameLogic.getState(), gameState);
|
||||||
|
|
||||||
|
//sends the gameState into Turn
|
||||||
|
gameState.setState(turnState);
|
||||||
|
assertEquals(gameState.getState(), turnState);
|
||||||
|
|
||||||
|
//sends the turnState into movePiece
|
||||||
|
turnState.setState(choosePiece);
|
||||||
|
assertEquals(turnState.getState(), movePiece);
|
||||||
|
|
||||||
// Todo Implementation goes here
|
// Todo Implementation goes here
|
||||||
|
|
||||||
|
//sends the spectator-message
|
||||||
|
clientGameLogic.received(ceremonyMessage);
|
||||||
|
|
||||||
|
//tests if the client is in Spectator
|
||||||
|
assertEquals(clientGameLogic.getState(), gameState);
|
||||||
|
assertEquals(gameState.getState(),spectator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1231,7 +1303,23 @@ public void testMovePieceToCeremony() {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testStayInChoosePowerCard() {
|
public void testStayInChoosePowerCard() {
|
||||||
|
//sends the client into noPiece
|
||||||
|
clientGameLogic.setState(gameState);
|
||||||
|
assertEquals(clientGameLogic.getState(), gameState);
|
||||||
|
|
||||||
|
//sends the gameState into Turn
|
||||||
|
gameState.setState(turnState);
|
||||||
|
assertEquals(gameState.getState(), turnState);
|
||||||
|
|
||||||
|
//sends the turnState into movePiece
|
||||||
|
turnState.setState(choosePiece);
|
||||||
|
assertEquals(turnState.getState(), choosePowerCard);
|
||||||
// Todo Implementation goes here
|
// Todo Implementation goes here
|
||||||
|
|
||||||
|
//tests if the client is still in the choosePowercard-State
|
||||||
|
assertEquals(clientGameLogic.getState(), gameState);
|
||||||
|
assertEquals(gameState.getState(),turnState);
|
||||||
|
assertEquals(turnState.getState(),choosePowerCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user