public void TestGetLobby() { var lobbyService = new LobbyService(); var createdLobby = lobbyService.CreateLobby("apples", null); var lobby = lobbyService.GetLobby("apples"); Assert.Same(createdLobby, lobby); }
public void TestGetLobbyNonExisting() { var lobbyService = new LobbyService(); var createdLobby = lobbyService.CreateLobby("apples", null); var lobby = lobbyService.GetLobby("pears"); Assert.NotSame(createdLobby, lobby); Assert.Null(lobby); }
public void StartNewGame(string lobbyId) { var lobby = lobbyService.GetLobby(lobbyId); if (lobby == null) { throw new NullReferenceException("Lobby could not be found"); } else { CardGame cardGame = cardGameRepository.CreateNewGame(lobbyId, lobby.Players); cardGame.Players.ForEach(player => { player.Phase = phaseService.CreateNewPhase(player.Id, PhaseType.One); player.Stage = Stage.Waiting; }); cardGame.Players[0].Stage = Stage.Draw; cardGame.DealRound(); cardGame.SetActivePlayer(cardGame.Players[0].Id); cardGame.StartPlayerId = cardGame.Players[0].Id; cardGameRepository.UpdateGame(cardGame); lobbyHub.Clients.Group(lobbyId).StartGame(); } }