Exemplo n.º 1
0
        public async Task ApplicationLifetimeIsHookedUp()
        {
            var appLifetime       = new TestApplicationLifetime();
            var connectionManager = CreateConnectionManager(appLifetime);

            appLifetime.Start();

            var connection = connectionManager.CreateConnection();

            appLifetime.StopApplication();

            // Connection should be disposed so this should complete immediately
            Assert.False(await connection.Application.Writer.WaitToWriteAsync().OrTimeout());
        }
Exemplo n.º 2
0
        public async Task ApplicationLifetimeIsHookedUp()
        {
            var appLifetime       = new TestApplicationLifetime();
            var connectionManager = CreateConnectionManager(appLifetime);
            var tcs = new TaskCompletionSource <object>();

            appLifetime.Start();

            var connection = connectionManager.CreateConnection();

            connection.Application.Output.OnReaderCompleted((error, state) =>
            {
                tcs.TrySetResult(null);
            },
                                                            null);

            appLifetime.StopApplication();

            // Connection should be disposed so this should complete immediately
            await tcs.Task.OrTimeout();
        }