public void TestIntegration() { var timeout = 1000; ReadSettings(); var srv = new ChatServer(udpServerPort, tcpServerPort, backlogSize, serverIpAddress); Assert.IsTrue(srv.LaunchUdpServer()); Assert.IsTrue(srv.LaunchChatServer()); var clnt1 = new ChatClient(isServerKnown, serverAddress, serverPort); //clnt1.OnMessage += (msg) => { messageFromServer = msg; }; Assert.IsTrue(clnt1.ConnectToServer()); var validationMessage = string.Empty; var command1 = new ChatCommand(); Assert.IsTrue(command1.TryParse("register user1", false, out validationMessage)); clnt1.SendCommand(command1); Thread.Sleep(timeout); Assert.IsTrue(clnt1.LastMessageReceivedFromServer == ChatCommand.msgYouAreSuccessfullyRegistered); Assert.IsTrue(command1.TryParse("listusers", false, out validationMessage)); clnt1.SendCommand(command1); Thread.Sleep(timeout); Assert.IsTrue(clnt1.LastMessageReceivedFromServer == "Подключенные пользователи: user1"); var clnt2 = new ChatClient(isServerKnown, serverAddress, serverPort); Assert.IsTrue(clnt2.ConnectToServer()); var command2 = new ChatCommand(); Assert.IsTrue(command2.TryParse("register user2", false, out validationMessage)); clnt2.SendCommand(command2); Thread.Sleep(timeout); Assert.IsTrue(clnt2.LastMessageReceivedFromServer == ChatCommand.msgYouAreSuccessfullyRegistered); Assert.IsTrue(command2.TryParse("listusers", false, out validationMessage)); clnt2.SendCommand(command2); Thread.Sleep(timeout); Assert.IsTrue(clnt2.LastMessageReceivedFromServer == "Подключенные пользователи: user1, user2"); Assert.IsTrue(command1.TryParse("message user2 123", false, out validationMessage)); clnt1.SendCommand(command1); Thread.Sleep(timeout); Assert.IsTrue(clnt2.LastMessageReceivedFromServer == "Пользователь 'user1' прислал вам сообщение: '123'"); Assert.IsTrue(command2.TryParse("message user1 456", false, out validationMessage)); clnt2.SendCommand(command2); Thread.Sleep(timeout); Assert.IsTrue(clnt1.LastMessageReceivedFromServer == "Пользователь 'user2' прислал вам сообщение: '456'"); srv.ShutDown(); }