public void ClientExchangeDataWithTheServerTest_RecivedMessagesIsProcessedInClientAndConvertedMessageIsSendToLisForProcessingIsUsedLambdaExpression_CorrectMessageFromTheServerWillBePlacedInTheList(string retMessage, string expected)
        {
            List <string> list         = new List <string>();
            Client        client       = new Client("Valera", correctServerPort, localIp, "Я пришёл с миром", null, (str) => { list.Add(MessageConverter.ConvertRussianToTranslit(str)); });
            Server        server       = new Server(correctServerPort, localIp, retMessage, null, null);
            Thread        serverThread = new Thread(new ThreadStart(() => { server.Start(300); }));

            serverThread.Start();
            Thread.Sleep(5000);
            client.ConnectToTheServer();
            client.ExchangeDataWithTheServer();

            string actual = list[0];

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void ConvertRussianToTranslitTest_StringWithRussianLetters_ConvertedString(string data, string expected)
        {
            string actual = MessageConverter.ConvertRussianToTranslit(data);

            Assert.AreEqual(actual, expected);
        }
        public void ClientExchangeDataWithTheServerTest_TheServerIsRunningOnDifferentPort_SocketExceptionThrown(int port)
        {
            List <string> list   = new List <string>();
            bool          actual = false;

            Client client       = new Client("Valera", port, localIp, "Я пришёл с миром", null, (str) => { list.Add(MessageConverter.ConvertRussianToTranslit(str)); });
            Server server       = new Server(port + 1, localIp, "Всё понял. Остовайтесь на связи, i'll be back", null, null);
            Thread serverThread = new Thread(new ThreadStart(() => { server.Start(3000); }));

            serverThread.Start();

            try
            {
                client.ConnectToTheServer();
                client.ExchangeDataWithTheServer();
            }
            catch (SocketException)
            {
                actual = true;
            }

            Assert.IsTrue(actual);
        }