Beispiel #1
0
        public async Task Retry_CloseAsyncSuccessDisposesHandler_Throws()
        {
            var contextMock       = Substitute.For <IPipelineContext>();
            var innerHandlerMock  = Substitute.For <IDelegatingHandler>();
            var cancellationToken = new CancellationToken();

            innerHandlerMock.OpenAsync(cancellationToken).Returns(t => TaskHelpers.CompletedTask);
            innerHandlerMock.CloseAsync(cancellationToken).Returns(t => TaskHelpers.CompletedTask);

            var sut = new RetryDelegatingHandler(contextMock, innerHandlerMock);
            await sut.OpenAsync(cancellationToken).ConfigureAwait(false);

            await sut.CloseAsync(cancellationToken).ConfigureAwait(false);

            await((Func <Task>)(() => sut.OpenAsync(cancellationToken))).ExpectedAsync <ObjectDisposedException>().ConfigureAwait(false);
        }