}
@Test //TODO add description of what the test should do
public final void testRemove() throws GameException{
final GameEngine engine = GameEngine.instance();
User user1,user2;
user1 = new UserImpl("user1","user1");
user2 = new UserImpl("user2","user2");
Assert.assertEquals(engine.getUsers().size(), 0);
engine.loginUser(user1);
engine.loginUser(user2);
Assert.assertEquals(engine.getLobby().getAvailableGames().size(), 0);
final Game game = GameImpl.getNewInstance("game1", user1, boardMap);
Assert.assertEquals(engine.getLobby().getAvailableGames().size(), 1);
final Player player1 = new Detective(user1);
final Player player2 = new MrX(user2);
Assert.assertEquals(engine.getUsers().size(), 2);
Assert.assertEquals(game.getDetectives().size(), 0);
game.setMrX(player2);
try{
engine.startGame(game);
Assert.assertFalse(true);
}catch(Exception ex){
Assert.assertTrue(true);
}
try{
game.addDetective((Detective)player2);
Assert.assertFalse(true);
}catch(Exception ex){
Assert.assertTrue(true);
}
game.addDetective((Detective)player1);
Assert.assertNotNull(game.getPlayer(user1.getEmail()));
Assert.assertNotNull(game.getPlayer(user2.getEmail()));
Assert.assertEquals(game.getDetectives().size(), 1);
Assert.assertEquals(game.getPlayers().size(),2);
Assert.assertTrue(engine.logoutUser(user1.getEmail()));
Assert.assertFalse(engine.logoutUser(user1.getEmail()));
Assert.assertEquals(game.getPlayers().size(),1);
try{
engine.startGame(game);
Assert.assertFalse(true);
}catch(Exception ex){
Assert.assertTrue(true);
}
engine.getUsers().put(user1.getEmail(), user1);
try{
game.setMrX(player1); // should not allow to override existing mrX
Assert.assertFalse(true);
}catch(Exception ex){
Assert.assertTrue(true);
}
Assert.assertEquals(game.getDetectives().size(), 0);
game.addDetective((Detective)player1);
Assert.assertEquals(game.getDetectives().size(), 1);
Assert.assertEquals(game.getPlayers().size(), 2);
Assert.assertSame(game.getMrX(),player2);
Assert.assertTrue(game.getDetectives().contains(player1));
Assert.assertFalse(game.getDetectives().contains(player2));
try{
game.addDetective((Detective)player2); //should not allow player to be both mrx and detective in the same game
Assert.assertFalse(true);
}catch(Exception ex){
Assert.assertTrue(true);
}
try{
game.addDetective((Detective)player1); //should not allow player to be added as detective twice
Assert.assertFalse(true);
}catch(Exception ex){
Assert.assertTrue(true);
}
Assert.assertEquals(game.getDetectives().size(),1);
Assert.assertEquals(game.getPlayers().size(),2);
engine.startGame(game);
Assert.assertEquals(engine.startGame(game), "done");
Assert.assertEquals(game.getGameStatus().toString(),GameStatus.STARTED.toString());
Assert.assertTrue(game.removePlayer(user1.getEmail()));
Assert.assertTrue(game.removePlayer(user2.getEmail()));
try{
game.removePlayer(user2.getEmail());
Assert.assertFalse(true);
}catch(GameException ex){