public void TestGetLobbies() { var lobbyService = new LobbyService(); lobbyService.CreateLobby("apples", null); lobbyService.CreateLobby("pears", null); var lobbies = lobbyService.GetLobbies(); Assert.Equal(2, lobbies.Count()); }
public void SucceedWhenGivenUniqueName() { //assert var options = Utils.GetDbOptions("CreateLobbyShould_SucceedWhenGivenUniqueName"); Lobby lobby; using (var context = new ApplicationDbContext(options)) { context.Users.Add(new User() { Id = "test_user" }); context.SaveChanges(); } //act using (var context = new ApplicationDbContext(options)) { var service = new LobbyService(context, null, null); lobby = service.CreateLobby("test_user", "new_lobby", true); } //assert using (var context = new ApplicationDbContext(options)) { Assert.NotNull(lobby); Assert.Equal("new_lobby", lobby.Name); Assert.Equal("test_user", lobby.OwnerID); Assert.True(lobby.Private); } }
public LobbyDto CreateLobby(LobbyPlayer creator) { var lobby = _lobbyService.CreateLobby(Lobbies.Select(l => l.Code), creator); Lobbies.Add(lobby); return(_mapper.Map <LobbyDto>(lobby)); }
public void TestGetLobby() { var lobbyService = new LobbyService(); var createdLobby = lobbyService.CreateLobby("apples", null); var lobby = lobbyService.GetLobby("apples"); Assert.Same(createdLobby, lobby); }
public void TestCreateLobby() { var lobbyService = new LobbyService(); var lobby = lobbyService.CreateLobby("apples", null); Assert.Equal("apples", lobby.Name); Assert.Equal(0, lobby.Id); Assert.Empty(lobby.Players); }
public async void CreateNewLobby() { CreateLobbyResponse createNewLobbyResponse = await lobbyService.CreateLobby(lobbyName.text); if (createNewLobbyResponse.IsSuccess) { networkManager.GetComponent <UserLobbyObject>().SetJoinedLobby(createNewLobbyResponse.LobbyDto); scene.ChangeScene(Scenes.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 TestGetJoinedLobbyNotJoined() { var lobbyService = new LobbyService(); lobbyService.CreateLobby("apples", null); var lobby = lobbyService.GetJoinedLobby("2"); Assert.Null(lobby); }
public void TestGetJoinedLobby() { var lobbyService = new LobbyService(); var lobby = lobbyService.CreateLobby("apples", null); lobby.AddPlayer("name", Color.Blue); var joinedLobby = lobbyService.GetJoinedLobby("name"); Assert.NotNull(joinedLobby); }
public void ThrowInvalidOperationExceptionWhenLobbyWithThisNameExists() { //arrange var options = Utils.GetDbOptions("CreateLobbyShould_ThrowInvalidOperationExceptionWhenLobbyWithThisNameExists"); using (var context = new ApplicationDbContext(options)) { context.Lobbies.Add(new Lobby() { Name = "new_lobby" }); context.Users.Add(new User() { Id = "test_user" }); context.SaveChanges(); } //act & assert using (var context = new ApplicationDbContext(options)) { var service = new LobbyService(context, null, null); Assert.Throws <InvalidOperationException>(() => service.CreateLobby("test_user", "new_lobby", true)); } }