Improving test cases for rejoin.
This commit is contained in:
@@ -55,7 +55,7 @@ public class RejoinGameTest extends TestBase {
|
|||||||
NetGameInfo gameInfo = createGameInfo(5, EndRaiseModeEnumType.EnumType.doubleBlinds, 0, 50, gameName, l, 10, 0, 11, 10000);
|
NetGameInfo gameInfo = createGameInfo(5, EndRaiseModeEnumType.EnumType.doubleBlinds, 0, 50, gameName, l, 10, 0, 11, 10000);
|
||||||
sendMessage(createGameRequestMsg(
|
sendMessage(createGameRequestMsg(
|
||||||
gameInfo,
|
gameInfo,
|
||||||
NetGameTypeEnumType.EnumType.rankingGame,
|
NetGameTypeEnumType.EnumType.normalGame,
|
||||||
5,
|
5,
|
||||||
7,
|
7,
|
||||||
"",
|
"",
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import java.net.Socket;
|
|||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@@ -39,6 +41,11 @@ public class RejoinMultiGameTest extends TestBase {
|
|||||||
@Test
|
@Test
|
||||||
public void testRejoinMultiGame() throws Exception {
|
public void testRejoinMultiGame() throws Exception {
|
||||||
|
|
||||||
|
Statement dbStatement = dbConn.createStatement();
|
||||||
|
ResultSet countBeforeResult = dbStatement.executeQuery("SELECT COUNT(idgame) FROM game");
|
||||||
|
countBeforeResult.first();
|
||||||
|
long countBefore = countBeforeResult.getLong(1);
|
||||||
|
|
||||||
userInit();
|
userInit();
|
||||||
|
|
||||||
// Waiting for player list update.
|
// Waiting for player list update.
|
||||||
@@ -293,8 +300,41 @@ public class RejoinMultiGameTest extends TestBase {
|
|||||||
} while (!msg.isHandStartMessageSelected());
|
} while (!msg.isHandStartMessageSelected());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The game should continue to the end.
|
||||||
|
do {
|
||||||
|
msg = receiveMessage();
|
||||||
|
failOnErrorMessage(msg);
|
||||||
|
} while (!msg.isEndOfGameMessageSelected());
|
||||||
|
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
s[i].close();
|
s[i].close();
|
||||||
}
|
}
|
||||||
|
Thread.sleep(2000);
|
||||||
|
|
||||||
|
// Check database entry for the game.
|
||||||
|
ResultSet countAfterResult = dbStatement.executeQuery("SELECT COUNT(idgame) FROM game");
|
||||||
|
countAfterResult.first();
|
||||||
|
long countAfter = countAfterResult.getLong(1);
|
||||||
|
assertEquals(countBefore + 1, countAfter);
|
||||||
|
|
||||||
|
// Select the latest game.
|
||||||
|
ResultSet gameResult = dbStatement.executeQuery("SELECT idgame, name, start_time, end_time FROM game WHERE start_time = (SELECT MAX(start_time) from game)");
|
||||||
|
gameResult.first();
|
||||||
|
long idgame = gameResult.getLong(1);
|
||||||
|
|
||||||
|
// Check database entries for the players in the game.
|
||||||
|
// There should be exactly 10 entries, just as
|
||||||
|
ResultSet gamePlayerResult = dbStatement.executeQuery("SELECT COUNT(*) FROM game_has_player WHERE game_idgame = " + idgame);
|
||||||
|
gamePlayerResult.first();
|
||||||
|
assertEquals(10, gamePlayerResult.getLong(1));
|
||||||
|
// Each player should have a place in the range 1..10
|
||||||
|
ResultSet winnerResult = dbStatement.executeQuery(
|
||||||
|
"SELECT place FROM game_has_player LEFT JOIN player_login on (game_has_player.player_idplayer = player_login.id) WHERE game_idgame = " + idgame);
|
||||||
|
winnerResult.first();
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
assertTrue(winnerResult.getLong(1) >= 1);
|
||||||
|
assertTrue(winnerResult.getLong(1) <= 10);
|
||||||
|
winnerResult.next();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ public class RunRankingGameTest extends TestBase {
|
|||||||
assertTrue(gameDurationMsec < 60 * 60 * 1000); // game duration should be smaller than 1 hour.
|
assertTrue(gameDurationMsec < 60 * 60 * 1000); // game duration should be smaller than 1 hour.
|
||||||
|
|
||||||
// Check database entries for the players in the game.
|
// Check database entries for the players in the game.
|
||||||
ResultSet gamePlayerResult = dbStatement.executeQuery("SELECT COUNT(DISTINCT player_idplayer) FROM game_has_player WHERE game_idgame = " + idgame);
|
ResultSet gamePlayerResult = dbStatement.executeQuery("SELECT COUNT(*) FROM game_has_player WHERE game_idgame = " + idgame);
|
||||||
gamePlayerResult.first();
|
gamePlayerResult.first();
|
||||||
assertEquals(10, gamePlayerResult.getLong(1));
|
assertEquals(10, gamePlayerResult.getLong(1));
|
||||||
// The one who always went all in should have won!
|
// The one who always went all in should have won!
|
||||||
|
|||||||
Reference in New Issue
Block a user