GameEngine.instance().getUsers().clear();
}
@Test //TODO add description of what the test should do
public final void testAddDetective() throws GameException{
final User creator = new UserImpl("user1", "user1@game.com");
Game game;
try{
game = GameImpl.getNewInstance("game1", creator, boardMap);
Assert.assertTrue(false);
}catch(GameException ex){
Assert.assertTrue(true);
}
Assert.assertEquals(GameEngine.instance().getLobby().getAvailableGames().size(),0);
GameEngine.instance().loginUser(creator);
Assert.assertNotNull(GameEngine.instance().getUser(creator.getEmail()));
Assert.assertEquals(GameEngine.instance().getUser(creator.getEmail()), creator);
game = GameImpl.getNewInstance("game1", creator, boardMap);
Assert.assertEquals(GameEngine.instance().getLobby().getAvailableGames().size(),1);
Assert.assertEquals(game.getDetectives().size(),0);
Assert.assertEquals(game.getPlayers().size(),0);
final Player player = Detective.getNewInstance(game, creator);
Assert.assertEquals(game.getDetectives().size(),1);
Assert.assertEquals(game.getPlayers().size(),1);
Assert.assertEquals(game.getPlayer(creator.getEmail()),player);
Assert.assertEquals(game.getPlayer(player.getEmail()),player);
Assert.assertEquals(creator.getEmail(),player.getEmail());
Assert.assertEquals(creator.getName(),player.getName());
Assert.assertNotNull(creator);
Assert.assertNotNull(creator.getEmail());
Assert.assertNull(game.getMrX());
GameEngine.instance().logoutUser(creator.getEmail());
try{
game.removePlayer(creator.getEmail());
Assert.assertFalse(true);
}catch(GameException ex){
Assert.assertTrue(true);
}
GameEngine.instance().getLobby().removeGame(game.getIdentifier());