SendMessage() публичный Метод

public SendMessage ( string message ) : Task
message string
Результат Task
        public async Task TestLargeSizeMessage()
        {
            _testService = new TestServer(_port);
            Assert.AreEqual(true, _testService.StartService());

            _testServiceClient = new TestServiceClient(_serverAddress, _port);
            bool clientConnected = await _testServiceClient.StartConnection();
            Assert.AreEqual(true, clientConnected);

            const int length = 100000;
            var charArray = new char[length];
            charArray[0] = 'a';
            for (int i = 1; i < length-1; ++i) charArray[i] = 'b';
            charArray[length-1] = 'c';
            var testString = new string(charArray);

            // how to set a timeout? 

            var response = (await _testServiceClient.SendMessage(testString)) as TestServiceResponse;
            Assert.IsNotNull(response);
            Assert.AreEqual(TestServiceConstants.ServicePrefix + testString, response.Message);

            _testServiceClient.StopClient();
            // assert client is stopped?
            _testService.StopService();
        }
        public async Task TestWebSocketOODSSService()
        {
            _testService = new TestServer(_port);
            Assert.AreEqual(true, _testService.StartService());

            _testServiceClient = new TestServiceClient(_serverAddress, _port);
            bool clientConnected = await _testServiceClient.StartConnection();
            Assert.AreEqual(true, clientConnected);

            const string testString = "Hello world!";
            var response = (await _testServiceClient.SendMessage(testString)) as TestServiceResponse;
            Assert.IsNotNull(response);
            Assert.AreEqual(TestServiceConstants.ServicePrefix + testString, response.Message);

            response = (await _testServiceClient.SendMessage(testString)) as TestServiceResponse;
            Assert.IsNotNull(response);
            Assert.AreEqual(TestServiceConstants.ServicePrefix + testString, response.Message);

            _testServiceClient.StopClient();
            // assert client is stopped?
            _testService.StopService();
        }
Пример #3
0
        private async void TestLargeSizeMessageButton_OnClick(object sender, RoutedEventArgs e)
        {
            InfoLabel.Text = "Running...";
            _testServiceClient = new TestServiceClient(_serverAddress, _port);
            bool clientConnected = await _testServiceClient.StartConnection();

            const int length = 30000;
            var charArray = new char[length];
            charArray[0] = 'a';
            for (int i = 1; i < length - 1; ++i) charArray[i] = 'b';
            charArray[length - 1] = 'c';
            var testString = new string(charArray);

            var response = (await _testServiceClient.SendMessage(testString)) as TestServiceResponse;

            if (response != null && response.Message.Equals(TestServiceConstants.ServicePrefix + testString))
                InfoLabel.Text = "Pass";
            else
                InfoLabel.Text = "Fail";
            _testServiceClient.StopClient();
        }
Пример #4
0
        private async void TestReconnectionButton_OnClick(object sender, RoutedEventArgs e)
        {
            InfoLabel.Text = "Running...";
            _testServiceClient = new TestServiceClient(_serverAddress, _port);
            bool clientConnected = await _testServiceClient.StartConnection();
            if (!clientConnected)
            {
                InfoLabel.Text = "Fail";
                return;
            }
            var testString = "Hello world!";
            var response = (await _testServiceClient.SendMessage(testString)) as TestServiceResponse;
            _testServiceClient.StopClient();

            clientConnected = await _testServiceClient.StartConnection();
            if (!clientConnected)
            {
                InfoLabel.Text = "Fail";
                return;
            }
            response = (await _testServiceClient.SendMessage(testString)) as TestServiceResponse;

            if (response != null && response.Message.Equals(TestServiceConstants.ServicePrefix + testString))
                InfoLabel.Text = "Pass";
            else
                InfoLabel.Text = "Fail";

            _testServiceClient.StopClient();
        }
Пример #5
0
 private async Task<bool> SendAndReceive(TestServiceClient client, int i)
 {
     string testString = i.ToString();
     var response = (await client.SendMessage(testString)) as TestServiceResponse;
     return response != null && response.Message.Equals(TestServiceConstants.ServicePrefix + testString);
 }
 private async Task SendAndReceive(TestServiceClient client, int i)
 {
         string testString = i.ToString();
         var response = (await client.SendMessage(testString)) as TestServiceResponse;
         Assert.IsNotNull(response);
         Assert.AreEqual(TestServiceConstants.ServicePrefix + testString, response.Message);
 }