StartService() public méthode

public StartService ( ) : bool
Résultat bool
        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();
        }
Exemple #2
0
 static void Main(string[] args)
 {
     int port = 2018;
     string serverAddress = "localhost";
     TestServer server = new TestServer(port);
     server.StartService();
 }
        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();
        }
        public async Task TestMultipleClients()
        {
            _testService = new TestServer(_port);
            Assert.AreEqual(true, _testService.StartService());

            const int numClients = 5;
            TestServiceClient[] clients = new TestServiceClient[numClients];
            for (int i = 0; i < numClients; ++i)
            {
                clients[i] = new TestServiceClient(_serverAddress, _port);
                bool clientConnected = await clients[i].StartConnection();
                Assert.AreEqual(true, clientConnected);
            }

            for (int i = 0; i < numClients; ++i)
                await SendAndReceive(clients[i], i);

            for (int i = 0; i < numClients; ++i)
            {
                clients[i].StopClient();
            }
            _testService.StopService();
        }