public async Task Connection_CanBeStoppedMultipleTimes()
        {
            var testClientServer = await SetupTestClientServer <TestService>();

            EpoxyConnection connection = testClientServer.ClientConnection;

            var stopTasks   = Task.WhenAll(connection.StopAsync(), connection.StopAsync());
            var timeoutTask = Task.Delay(TimeSpan.FromSeconds(10));

            var completedTask = await Task.WhenAny(stopTasks, timeoutTask);

            Assert.AreNotSame(timeoutTask, completedTask, "Timed out waiting for connection to be shutdown.");
        }
Exemplo n.º 2
0
        public async Task Connection_CanBeStoppedMultipleTimes()
        {
            var testClientServer = await EpoxyTransportTests.SetupTestClientServer <EpoxyTransportTests.TestService>();

            EpoxyConnection connection = testClientServer.ClientConnection;

            var stopTasks   = new[] { connection.StopAsync(), connection.StopAsync() };
            var timeoutTask = Task.Delay(TimeSpan.FromSeconds(10));
            var allTasks    = new List <Task>(stopTasks)
            {
                timeoutTask
            };

            var completedTask = await Task.WhenAny(allTasks);

            Assert.AreNotSame(timeoutTask, completedTask, "Timed out waiting for connection to be shutdown.");

            await connection.StopAsync();
        }
Exemplo n.º 3
0
        public async Task Connection_StartStop()
        {
            var testClientServer = await EpoxyTransportTests.SetupTestClientServer <EpoxyTransportTests.TestService>();

            EpoxyConnection connection = testClientServer.ClientConnection;

            var timeoutTask   = Task.Delay(TimeSpan.FromSeconds(10));
            var completedTask = await Task.WhenAny(connection.StopAsync(), timeoutTask);

            Assert.AreNotSame(timeoutTask, completedTask, "Timed out waiting for connection to be shutdown.");
        }
        public async Task Connection_OutstandingRequestsThenShutdown_CompletedWithError()
        {
            var testClientServer = await SetupTestClientServer <TestServiceNeverResponds>();

            EpoxyConnection connection = testClientServer.ClientConnection;

            IMessage <SomePayload>         anyPayload   = Message.FromPayload(new SomePayload());
            Task <IMessage <SomePayload> > responseTask = connection
                                                          .RequestResponseAsync <SomePayload, SomePayload>(
                "TestService", "NeverRespond", anyPayload, CancellationToken.None);

            await connection.StopAsync();

            IMessage <SomePayload> response = await responseTask;

            Assert.IsTrue(response.IsError);
            Error err = response.Error.Deserialize();

            Assert.AreEqual((int)ErrorCode.CONNECTION_SHUT_DOWN, err.error_code);
        }
Exemplo n.º 5
0
 private static void Shutdown(Transport transport)
 {
     Task.WaitAll(transport.StopAsync(), s_pingConnection.StopAsync(), s_reverseConnection.StopAsync());
 }