public void AcquireConnection_should_throw_an_ObjectDisposedException_after_disposing(
            [Values(false, true)]
            bool async)
        {
            _capturedEvents.Clear();
            _subject.Dispose();

            Action act;

            if (async)
            {
                act = () => _subject.AcquireConnectionAsync(CancellationToken.None).GetAwaiter().GetResult();
            }
            else
            {
                act = () => _subject.AcquireConnection(CancellationToken.None);
            }

            act.ShouldThrow <ObjectDisposedException>();
            _capturedEvents.Next().Should().BeOfType <ConnectionPoolClosingEvent>();
            _capturedEvents.Next().Should().BeOfType <ConnectionPoolClosedEvent>();
            _capturedEvents.Next().Should().BeOfType <ConnectionPoolCheckingOutConnectionEvent>();
            var connectionPoolCheckingOutConnectionFailedEvent = _capturedEvents.Next();
            var e = connectionPoolCheckingOutConnectionFailedEvent.Should().BeOfType <ConnectionPoolCheckingOutConnectionFailedEvent>().Subject;

            e.Reason.Should().Be(ConnectionCheckOutFailedReason.PoolClosed);
            _capturedEvents.Any().Should().BeFalse();
        }
예제 #2
0
        public void AcquireConnectionAsync_should_throw_an_ObjectDisposedException_after_disposing()
        {
            _subject.Dispose();

            Action act = () => _subject.AcquireConnectionAsync(CancellationToken.None).Wait();

            act.ShouldThrow <ObjectDisposedException>();
        }
        public void AcquireConnection_should_throw_an_ObjectDisposedException_after_disposing(
            [Values(false, true)]
            bool async)
        {
            _subject.Dispose();

            Action act;

            if (async)
            {
                act = () => _subject.AcquireConnectionAsync(CancellationToken.None).GetAwaiter().GetResult();
            }
            else
            {
                act = () => _subject.AcquireConnection(CancellationToken.None);
            }

            act.ShouldThrow <ObjectDisposedException>();
        }