Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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")));
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        public void AddPlayer_ShouldWork()
        {
            var lobby = new LobbyClient();

            lobby.AddPlayer(new PlayerClient("Some Player"));
            Assert.NotEmpty(lobby.Players);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        public void ChangeConnectionForPlayer_NonexistentPlayerPassed_ThrowError()
        {
            var lobby  = new LobbyClient();
            var player = new PlayerClient("player");

            lobby.AddPlayer(player);

            Assert.Throws <ArgumentException>(() => lobby.ChangeConnectionForPlayer("nonexistent", true));
        }
Esempio n. 9
0
        public void SetDrawingPlayer_NonexistentPlayerPassed_ThrowError()
        {
            var lobby  = new LobbyClient();
            var player = new PlayerClient("player");

            lobby.AddPlayer(player);

            Assert.Throws <ArgumentException>(() => lobby.SetDrawingPlayer("nonexistent"));
        }
Esempio n. 10
0
        public void GetPlayerByName_NullPlayerShouldThrowException()
        {
            var lobby  = new LobbyClient();
            var player = new PlayerClient("player");

            lobby.AddPlayer(player);

            Assert.Throws <ArgumentException>(() => lobby.GetPlayerByName(null));
        }
Esempio n. 11
0
        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"));
        }
Esempio n. 12
0
        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"));
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        public void GetHostPlayer_NoHostShouldReturnNull()
        {
            var lobby   = new LobbyClient();
            var player1 = new PlayerClient("player1");

            lobby.AddPlayer(player1);

            var actualHost = lobby.GetHostPlayer();

            Assert.Null(actualHost);
        }
Esempio n. 15
0
        public void GetDrawingPlayer_NoDrawingPlayerShouldReturnNull()
        {
            var lobby   = new LobbyClient();
            var player1 = new PlayerClient("player1");

            lobby.AddPlayer(player1);

            var actualDrawingPlayer = lobby.GetDrawingPlayer();

            Assert.Null(actualDrawingPlayer);
        }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        public void AddPlayer_NullPlayerShouldThrowException()
        {
            var lobby = new LobbyClient();

            Assert.Throws <ArgumentNullException>(() => lobby.AddPlayer(null));
        }