Exemple #1
0
        public async Task Retry_CancellationTokenCanceled_Abandon()
        {
            var innerHandlerMock = Substitute.For <IDelegatingHandler>();

            innerHandlerMock.AbandonAsync(Arg.Any <string>(), Arg.Any <CancellationToken>()).Returns(TaskConstants.Completed);

            var sut = new RetryDelegatingHandler(innerHandlerMock);
            var cancellationTokenSource = new CancellationTokenSource();

            cancellationTokenSource.Cancel();
            await sut.AbandonAsync(Arg.Any <string>(), cancellationTokenSource.Token).ExpectedAsync <TaskCanceledException>();
        }
Exemple #2
0
        public async Task RetryCancellationTokenCanceledAbandon()
        {
            var innerHandlerMock = Substitute.For <IDelegatingHandler>();

            innerHandlerMock.AbandonAsync(null, CancellationToken.None).ReturnsForAnyArgs(TaskHelpers.CompletedTask);

            var contextMock = Substitute.For <IPipelineContext>();
            var sut         = new RetryDelegatingHandler(contextMock, innerHandlerMock);

            using var cancellationTokenSource = new CancellationTokenSource();
            cancellationTokenSource.Cancel();
            await sut.AbandonAsync(Arg.Any <string>(), cancellationTokenSource.Token).ExpectedAsync <TaskCanceledException>().ConfigureAwait(false);
        }
Exemple #3
0
        public async Task Retry_CancellationTokenCanceled_Abandon()
        {
            var innerHandlerMock = Substitute.For <IDelegatingHandler>();

            innerHandlerMock.AbandonAsync(null, CancellationToken.None).ReturnsForAnyArgs(TaskConstants.Completed);

            var contextMock = Substitute.For <IPipelineContext>();
            var sut         = new RetryDelegatingHandler(contextMock);

            sut.ContinuationFactory = c => innerHandlerMock;
            var cancellationTokenSource = new CancellationTokenSource();

            cancellationTokenSource.Cancel();
            await sut.AbandonAsync(Arg.Any <string>(), cancellationTokenSource.Token).ExpectedAsync <TaskCanceledException>();
        }