added some logic to the tests
This commit is contained in:
@@ -234,7 +234,9 @@ public void testInitialStateClientState() {
|
||||
public void testDialogsToGame() {
|
||||
//tests if the client is in Dialogs
|
||||
clientGameLogic.setState(dialogs);
|
||||
dialogs.setState(lobby);
|
||||
assertEquals(clientGameLogic.getState(), dialogs);
|
||||
assertEquals(dialogs.getState(), lobby);
|
||||
|
||||
//sends all messages, which don't indicate a statechange
|
||||
clientGameLogic.received(activePlayer);
|
||||
@@ -263,8 +265,8 @@ public void testDialogsToGame() {
|
||||
clientGameLogic.received(resumeGame);
|
||||
//clientGameLogic.received(startGame);
|
||||
clientGameLogic.received(startPieceMessage);
|
||||
clientGameLogic.received(updateReady);
|
||||
clientGameLogic.received(updateTSK);
|
||||
//clientGameLogic.received(updateReady);todo
|
||||
//clientGameLogic.received(updateTSK);
|
||||
clientGameLogic.received(waitPiece);
|
||||
clientGameLogic.received(spectatorMessage);
|
||||
clientGameLogic.received(selectPieceMessage);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package pp.mdga.server.serverstate;
|
||||
|
||||
//TODO important: set activePlayer, setPlayers, setPieces, setBonusCards
|
||||
|
||||
import org.junit.*;
|
||||
import pp.mdga.game.*;
|
||||
import pp.mdga.message.server.ServerMessage;
|
||||
@@ -200,6 +202,11 @@ public void disconnectClient(int id) {
|
||||
waitingPieceState = choosePieceState.getWaitingPieceState();
|
||||
startPieceState = choosePieceState.getStartPieceState();
|
||||
selectPieceState = choosePieceState.getSelectPieceState();
|
||||
|
||||
/*
|
||||
* this attribute is used, so the server knows, that always it's the host's turn
|
||||
*/
|
||||
game.setActiveColor(playerHostColor);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,7 +461,13 @@ public void testDetermineStartPlayerToDetermineStartPlayer2() {
|
||||
gameState.setCurrentState(determineStartPlayerState);
|
||||
assertEquals(gameState.getCurrentState(), determineStartPlayerState);
|
||||
|
||||
//TODO sends messages 2 requestDieMessage, die gleich geränkt werden to the server
|
||||
//set die to 6
|
||||
game.setDie(new Die(6));
|
||||
|
||||
//sends the two requestDiceMessages
|
||||
serverGameLogic.received(requestDie, IDPlayerClient);
|
||||
serverGameLogic.received(requestDie, IDPlayerHost);
|
||||
|
||||
//sends the requestDieMessage to the server
|
||||
gameState.received(requestDie, IDPlayerClient);
|
||||
|
||||
@@ -483,7 +496,17 @@ public void testDetermineStartPlayerToAnimation() {
|
||||
gameState.setCurrentState(determineStartPlayerState);
|
||||
assertEquals(gameState.getCurrentState(), determineStartPlayerState);
|
||||
|
||||
//TODO sends messages 2 requestDieMessage, die ungleich geränkt werden, sodass der server weitergeht
|
||||
//set die to 6
|
||||
game.setDie(new Die(6));
|
||||
|
||||
//sends the two requestDiceMessages
|
||||
serverGameLogic.received(requestDie, IDPlayerClient);
|
||||
|
||||
//set die to 6
|
||||
game.setDie(new Die(5));
|
||||
|
||||
//sends the two requestDiceMessages
|
||||
serverGameLogic.received(requestDie, IDPlayerClient);
|
||||
|
||||
//tests if the Server is in animationState
|
||||
assertEquals(serverGameLogic.getCurrentState(), gameState);
|
||||
@@ -637,6 +660,7 @@ public void testPowerCardToPlayPowerCard() {
|
||||
assertEquals(turnState.getCurrentState(), powerCardState);
|
||||
|
||||
//todo
|
||||
serverGameLogic.received(selectCard, IDPlayerClient);
|
||||
|
||||
//tests if the server is in PlayPowerCard
|
||||
assertEquals(serverGameLogic.getCurrentState(), gameState);
|
||||
@@ -732,6 +756,9 @@ public void testMovePieceToTurnEndState() {
|
||||
*/
|
||||
@Test
|
||||
public void testMovePieceToFirstRoll() {
|
||||
//sets the die to 6
|
||||
game.setDie(new Die(6));
|
||||
|
||||
//sends the server in Game-State
|
||||
serverGameLogic.setCurrentState(gameState);
|
||||
assertEquals(serverGameLogic.getCurrentState(), gameState);
|
||||
@@ -744,12 +771,18 @@ public void testMovePieceToFirstRoll() {
|
||||
turnState.setCurrentState(movePieceState);
|
||||
assertEquals(turnState.getCurrentState(), movePieceState);
|
||||
|
||||
//Todo the player rolled a 6 and the player is not finished
|
||||
//sends the animationEndMessage
|
||||
serverGameLogic.received(animationEnd, IDPlayerClient);
|
||||
serverGameLogic.received(animationEnd, IDPlayerHost);
|
||||
|
||||
//tests if the server is in firstRoll
|
||||
assertEquals(serverGameLogic.getCurrentState(), gameState);
|
||||
assertEquals(gameState.getCurrentState(), turnState);
|
||||
assertEquals(turnState.getCurrentState(), rollDiceState);
|
||||
assertEquals(rollDiceState.getCurrentState(), firstRollState);
|
||||
|
||||
//tests if the activeColor is still Host
|
||||
assertEquals(game.getActiveColor(),playerHostColor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user