Esempio n. 1
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.");
        }
Esempio 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();
        }
Esempio n. 3
0
        public async Task Connection_OutstandingRequestsThenShutdown_CompletedWithError()
        {
            var testClientServer = await EpoxyTransportTests.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.ConnectionShutDown, err.error_code);
        }