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); }
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); }
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); }
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); }
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); }
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); }