Still fixing tests.

This commit is contained in:
lotodore
2012-09-21 23:53:25 +02:00
parent 8080fb6139
commit 09545d86a7
2 changed files with 49 additions and 33 deletions
+7 -5
View File
@@ -28,6 +28,11 @@ import java.util.Iterator;
import org.junit.Test; import org.junit.Test;
import de.pokerth.protocol.ProtoBuf.NetGameInfo;
import de.pokerth.protocol.ProtoBuf.NetGameInfo.EndRaiseMode;
import de.pokerth.protocol.ProtoBuf.NetGameInfo.NetGameType;
import de.pokerth.protocol.ProtoBuf.PokerTHMessage;
public class SeatStateTest extends TestBase { public class SeatStateTest extends TestBase {
@@ -35,14 +40,11 @@ public class SeatStateTest extends TestBase {
public void testSeatState() throws Exception { public void testSeatState() throws Exception {
long firstPlayerId = userInit(); long firstPlayerId = userInit();
Collection<InitialNonZeroAmountOfMoney> l = new ArrayList<InitialNonZeroAmountOfMoney>(); Collection<Integer> l = new ArrayList<Integer>();
String gameName = AuthUser + " run normal game for seatState"; String gameName = AuthUser + " run normal game for seatState";
NetGameInfo gameInfo = createGameInfo(5, EndRaiseModeEnumType.EnumType.doubleBlinds, 0, 200, gameName, l, 10, 0, 2, 10000); NetGameInfo gameInfo = createGameInfo(NetGameType.normalGame, 5, 7, 5, EndRaiseMode.doubleBlinds, 0, 200, gameName, l, 10, 0, 2, 10000);
sendMessage(createGameRequestMsg( sendMessage(createGameRequestMsg(
gameInfo, gameInfo,
NetGameTypeEnumType.EnumType.normalGame,
5,
7,
"", "",
false)); false));
@@ -24,66 +24,80 @@ import java.util.Collection;
import org.junit.Test; import org.junit.Test;
import de.pokerth.protocol.ProtoBuf.NetGameInfo;
import de.pokerth.protocol.ProtoBuf.NetGameInfo.EndRaiseMode;
import de.pokerth.protocol.ProtoBuf.NetGameInfo.NetGameType;
import de.pokerth.protocol.ProtoBuf.PokerTHMessage.PokerTHMessageType;
import de.pokerth.protocol.ProtoBuf.PokerTHMessage;
import de.pokerth.protocol.ProtoBuf.StartEventAckMessage;
import de.pokerth.protocol.ProtoBuf.StartEventMessage;
import de.pokerth.protocol.ProtoBuf.StartEventMessage.StartEventType;
public class StartNormalGameTest extends TestBase { public class StartNormalGameTest extends TestBase {
@Test @Test
public void testGameStartMessage() throws Exception { public void testGameStartMessage() throws Exception {
guestInit(); guestInit();
Collection<InitialNonZeroAmountOfMoney> l = new ArrayList<InitialNonZeroAmountOfMoney>(); Collection<Integer> l = new ArrayList<Integer>();
NetGameInfo gameInfo = createGameInfo(10, EndRaiseModeEnumType.EnumType.doubleBlinds, 0, 100, GuestUser + " start normal game", l, 10, 0, 11, 20000); NetGameInfo gameInfo = createGameInfo(NetGameType.normalGame, 10, 7, 10, EndRaiseMode.doubleBlinds, 0, 100, GuestUser + " start normal game", l, 10, 0, 11, 20000);
sendMessage(createGameRequestMsg( sendMessage(createGameRequestMsg(
gameInfo, gameInfo,
NetGameTypeEnumType.EnumType.normalGame,
10,
7,
"", "",
false)); false));
PokerTHMessage msg; PokerTHMessage msg;
// Waiting for player list update. // Waiting for player list update.
msg = receiveMessage(); msg = receiveMessage();
if (!msg.isPlayerListMessageSelected()) { if (!msg.hasPlayerListMessage()) {
failOnErrorMessage(msg); failOnErrorMessage(msg);
fail("Invalid message."); fail("Invalid message.");
} }
msg = receiveMessage(); msg = receiveMessage();
if (!msg.isGameListMessageSelected()) { if (!msg.hasGameListNewMessage()) {
failOnErrorMessage(msg); failOnErrorMessage(msg);
fail("Invalid message."); fail("Invalid message.");
} }
msg = receiveMessage(); msg = receiveMessage();
if (msg.isJoinGameReplyMessageSelected()) { if (!msg.hasJoinGameAckMessage()) {
if (!msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameAckSelected()) {
fail("Could not create game!");
}
}
else {
failOnErrorMessage(msg); failOnErrorMessage(msg);
fail("Invalid message."); fail("Could not create game!");
} }
long gameId = msg.getJoinGameReplyMessage().getValue().getGameId().getValue(); int gameId = msg.getJoinGameAckMessage().getGameId();
StartEvent startEvent = new StartEvent(); StartEventMessage startMsg = StartEventMessage.newBuilder()
startEvent.setFillWithComputerPlayers(true); .setGameId(gameId)
StartEventTypeChoiceType eventType = new StartEventTypeChoiceType(); .setFillWithComputerPlayers(true)
eventType.selectStartEvent(startEvent); .setStartEventType(StartEventType.startEvent)
StartEventMessageSequenceType gameStartType = new StartEventMessageSequenceType(); .build();
gameStartType.setGameId(new NonZeroId(gameId)); msg = PokerTHMessage.newBuilder()
gameStartType.setStartEventType(eventType); .setMessageType(PokerTHMessageType.Type_StartEventMessage)
StartEventMessage startMsg = new StartEventMessage(); .setStartEventMessage(startMsg)
startMsg.setValue(gameStartType); .build();
msg = new PokerTHMessage();
msg.selectStartEventMessage(startMsg);
sendMessage(msg); sendMessage(msg);
do { do {
msg = receiveMessage(); msg = receiveMessage();
} while (msg.isGameListMessageSelected()); } while (msg.hasGameListPlayerJoinedMessage() || msg.hasGamePlayerJoinedMessage());
if (msg.isGameStartMessageSelected()) { assertTrue(msg.hasStartEventMessage() && msg.getMessageType() == PokerTHMessageType.Type_StartEventMessage);
StartEventAckMessage startAck = StartEventAckMessage.newBuilder()
.setGameId(gameId)
.build();
msg = PokerTHMessage.newBuilder()
.setMessageType(PokerTHMessageType.Type_StartEventAckMessage)
.setStartEventAckMessage(startAck)
.build();
sendMessage(msg);
do {
msg = receiveMessage();
} while (msg.hasGameListUpdateMessage());
if (!msg.hasGameStartInitialMessage()) {
failOnErrorMessage(msg); failOnErrorMessage(msg);
fail("Invalid message."); fail("Invalid message.");
} }