コード例 #1
0
ファイル: EpoxyConnectionTests.cs プロジェクト: ikvm/bond
        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.");
        }
コード例 #2
0
ファイル: EpoxyConnectionTests.cs プロジェクト: ikvm/bond
        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();
        }
コード例 #3
0
ファイル: EpoxyConnectionTests.cs プロジェクト: ikvm/bond
        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);
        }