public void AddPlayer_UsernameAlreadyInLobbyShouldThrowException() { var lobby = new LobbyClient(); var player = new PlayerClient("player"); var player2 = new PlayerClient("player"); lobby.AddPlayer(player); Assert.Throws <UserNameAlreadyExistsException>(() => lobby.AddPlayer(player2)); }
public void AddPlayer_FullLobbyShouldThrowException() { var lobby = new LobbyClient(); lobby.MaxPlayers = 2; lobby.AddPlayer(new PlayerClient("player1")); lobby.AddPlayer(new PlayerClient("player2")); Assert.Throws <MaxPlayersReachedException>(() => lobby.AddPlayer(new PlayerClient("player3"))); }
public void GetPlayerByName_MultiplePlayersShouldWork() { var lobby = new LobbyClient(); var player = new PlayerClient("player"); var player2 = new PlayerClient("player22"); lobby.AddPlayer(player); lobby.AddPlayer(player2); var actualPlayer = lobby.GetPlayerByName("player"); Assert.Equal(player, actualPlayer); }
public void AddPlayer_ShouldWork() { var lobby = new LobbyClient(); lobby.AddPlayer(new PlayerClient("Some Player")); Assert.NotEmpty(lobby.Players); }
public void SetHostPlayer_SwitchHost() { var lobby = new LobbyClient(); var player1 = new PlayerClient("player1"); var player2 = new PlayerClient("player2"); lobby.AddPlayer(player1); lobby.AddPlayer(player2); player1.IsConnected = true; player2.IsConnected = true; lobby.SetHostPlayer("player1"); lobby.SetHostPlayer("player2"); Assert.False(player1.IsHost); Assert.True(player2.IsHost); }
public void SetDrawingPlayer_ChangingBetweenPlayersShouldWork() { var lobby = new LobbyClient(); var player1 = new PlayerClient("player1"); var player2 = new PlayerClient("player2"); lobby.AddPlayer(player1); lobby.AddPlayer(player2); player1.IsConnected = true; player2.IsConnected = true; lobby.SetDrawingPlayer("player1"); lobby.SetDrawingPlayer("player2"); Assert.False(player1.IsDrawing); Assert.True(player2.IsDrawing); }
public void GetHostPlayer_ShouldWork() { var lobby = new LobbyClient(); var player1 = new PlayerClient("player1"); var player2 = new PlayerClient("player2"); lobby.AddPlayer(player1); lobby.AddPlayer(player2); player1.IsConnected = true; player2.IsConnected = true; lobby.SetHostPlayer("player1"); var actualHost = lobby.GetHostPlayer(); Assert.Equal(player1, actualHost); }
public void ChangeConnectionForPlayer_NonexistentPlayerPassed_ThrowError() { var lobby = new LobbyClient(); var player = new PlayerClient("player"); lobby.AddPlayer(player); Assert.Throws <ArgumentException>(() => lobby.ChangeConnectionForPlayer("nonexistent", true)); }
public void SetDrawingPlayer_NonexistentPlayerPassed_ThrowError() { var lobby = new LobbyClient(); var player = new PlayerClient("player"); lobby.AddPlayer(player); Assert.Throws <ArgumentException>(() => lobby.SetDrawingPlayer("nonexistent")); }
public void GetPlayerByName_NullPlayerShouldThrowException() { var lobby = new LobbyClient(); var player = new PlayerClient("player"); lobby.AddPlayer(player); Assert.Throws <ArgumentException>(() => lobby.GetPlayerByName(null)); }
public void SetHostPlayer_NonexistentPlayer_ThrowError() { var lobby = new LobbyClient(); var player = new PlayerClient("player"); lobby.AddPlayer(player); player.IsConnected = true; Assert.Throws <ArgumentException>(() => lobby.SetHostPlayer("nonexistent")); }
public void SetHostPlayer_DisconnectedPlayer_ThrowError() { var lobby = new LobbyClient(); var player = new PlayerClient("player"); lobby.AddPlayer(player); player.IsConnected = false; Assert.Throws <DisconnectedPlayerException>(() => lobby.SetHostPlayer("player")); }
public void ChangeConnectionForPlayer_ShouldWork(bool newState) { var lobby = new LobbyClient(); var player = new PlayerClient("player"); lobby.AddPlayer(player); lobby.ChangeConnectionForPlayer("player", newState); Assert.Equal(newState, player.IsConnected); }
public void GetHostPlayer_NoHostShouldReturnNull() { var lobby = new LobbyClient(); var player1 = new PlayerClient("player1"); lobby.AddPlayer(player1); var actualHost = lobby.GetHostPlayer(); Assert.Null(actualHost); }
public void GetDrawingPlayer_NoDrawingPlayerShouldReturnNull() { var lobby = new LobbyClient(); var player1 = new PlayerClient("player1"); lobby.AddPlayer(player1); var actualDrawingPlayer = lobby.GetDrawingPlayer(); Assert.Null(actualDrawingPlayer); }
public void SetHostPlayer_ShouldWork() { var lobby = new LobbyClient(); var player = new PlayerClient("player"); lobby.AddPlayer(player); player.IsConnected = true; lobby.SetHostPlayer("player"); Assert.True(player.IsHost); }
public void GetDrawingPlayer_ShouldWork() { var lobby = new LobbyClient(); var player = new PlayerClient("player"); lobby.AddPlayer(player); player.IsConnected = true; lobby.SetDrawingPlayer(player.Name); var actualDrawingPlayer = lobby.GetDrawingPlayer(); Assert.Equal(player, actualDrawingPlayer); }
public void AddPlayer_NullPlayerShouldThrowException() { var lobby = new LobbyClient(); Assert.Throws <ArgumentNullException>(() => lobby.AddPlayer(null)); }