示例#1
0
 public void SetResponseFactory(Func <HttpRetryHandlerRequest, Task <HttpResponseMessage> > responseFactory)
 {
     HttpSource.RetryHandler = RetryHandlerMock.Object;
     RetryHandlerMock
     .Setup(x => x.SendAsync(
                It.IsAny <HttpRetryHandlerRequest>(),
                It.IsAny <ILogger>(),
                It.IsAny <CancellationToken>()))
     .Returns <HttpRetryHandlerRequest, ILogger, CancellationToken>((r, _, __) => responseFactory(r));
 }
示例#2
0
            public void SetResponseSequence(HttpResponseMessage[] responses)
            {
                HttpSource.RetryHandler = RetryHandlerMock.Object;
                int index = 0;

                RetryHandlerMock
                .Setup(x => x.SendAsync(
                           It.IsAny <HttpRetryHandlerRequest>(),
                           It.IsAny <ILogger>(),
                           It.IsAny <CancellationToken>()))
                .Returns(() => Task.FromResult(responses[index++ % responses.Length]));
            }