Esempio n. 1
0
        public void MessageReceivedFromOneUserIsSentToTheOtherUser(string incomingMessage)
        {
            var chatListener = new FakeServerChatListener();
            var sut = new ChatServerApplication(chatListener);
            sut.Start();
            var messageSource = new FakeCommunicationChannel();
            var messageRecipient = new FakeCommunicationChannel();
            chatListener.SimulateConnectToServer(messageRecipient);
            chatListener.SimulateConnectToServer(messageSource);
            messageSource.SimulateMessageReceived(incomingMessage);

            Assert.Equal(incomingMessage, messageRecipient.LastMessageSent);
        }
Esempio n. 2
0
        public void DalbajobusAtjungiamNuoServako()
        {
            var chatListener = new FakeServerChatListener();
            var sut = new ChatServerApplication(chatListener);
            sut.Start();
            var messageSource = new FakeCommunicationChannel();
            var messageLoxasRecipient = new FakeDalbajobasCommunicationChannel();
            chatListener.SimulateConnectToServer(messageLoxasRecipient);
            chatListener.SimulateConnectToServer(messageSource);

            messageSource.SimulateMessageReceived("foo");
            messageSource.SimulateMessageReceived("bar");
            Assert.Equal("foo", messageLoxasRecipient.LastMessageSent);
        }
Esempio n. 3
0
        public void ReceivedMessagesAreIgnoredAfterSourceClientDisconnects()
        {
            var chatListener = new FakeServerChatListener();
            var sut = new ChatServerApplication(chatListener);
            sut.Start();
            var messageSource = new FakeCommunicationChannel();
            var messageRecipient = new FakeCommunicationChannel();
            chatListener.SimulateConnectToServer(messageRecipient);
            chatListener.SimulateConnectToServer(messageSource);
            chatListener.SimulateDisconnectFromServer(messageSource);

            messageSource.SimulateMessageReceived("foo");

            Assert.Null(messageRecipient.LastMessageSent);
        }
Esempio n. 4
0
        public void TheNumberOfConnectionsAfterOneDisconnect(int initialNumberOfConnections, int expected)
        {
            var serverChannel = new FakeServerChatListener();
            var sut = new ChatServerApplication(serverChannel);
            sut.Start();

            var connectedClients = new List<FakeCommunicationChannel>();

            for (int i = 0; i < initialNumberOfConnections; ++i)
            {
                connectedClients.Add(new FakeCommunicationChannel());
            }

            foreach(var client in connectedClients)
            {
                serverChannel.SimulateConnectToServer(client);
            }

            serverChannel.SimulateDisconnectFromServer(connectedClients[0]);
            Assert.Equal(expected, sut.NumberOfUsers);
        }
Esempio n. 5
0
        public void ZinuteIssiustaNormaliemsNetJeiServakeYraDalbajobu()
        {
            var chatListener = new FakeServerChatListener();
            var sut = new ChatServerApplication(chatListener);
            sut.Start();
            var messageSource = new FakeCommunicationChannel();
            var messageLoxasRecipient = new FakeDalbajobasCommunicationChannel();
            var messageRecipient = new FakeCommunicationChannel();
            chatListener.SimulateConnectToServer(messageLoxasRecipient);
            chatListener.SimulateConnectToServer(messageRecipient);
            chatListener.SimulateConnectToServer(messageSource);

            messageSource.SimulateMessageReceived("foo");

            Assert.Equal("foo", messageRecipient.LastMessageSent);
        }
Esempio n. 6
0
        public void WhenFirstUserConnectsToServerChatApplicationIncreasesUserCounter(int result, int numberOfConnections)
        {
            var serverChannel = new FakeServerChatListener();
            var sut = new ChatServerApplication(serverChannel);
            sut.Start();

            for (int i = 0; i < numberOfConnections; ++i)
            {
                serverChannel.SimulateConnectToServer(new FakeCommunicationChannel());
            }

            Assert.Equal(result, sut.NumberOfUsers);
        }