| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | using System.Net.Http; |
| | using System.Threading; |
| | using System.Threading.Tasks; |
| |
|
| | namespace Google.Apis.Tests.Apis.Http |
| | { |
| | |
| | |
| | |
| | internal static class HandlerTestHelper |
| | { |
| | |
| | |
| | |
| | |
| | internal static Task<HttpResponseMessage> ProcessRequestAsync( |
| | HttpMessageHandler handler, HttpRequestMessage request, CancellationToken cancellationToken = default(CancellationToken)) |
| | { |
| | var trampoline = new TestHandler(handler); |
| | return trampoline.ExposedSendAync(request, cancellationToken); |
| | } |
| |
|
| | |
| | |
| | |
| | internal static HttpMessageHandler CreateHandler(HttpResponseMessage response) => |
| | new SingleResponseHandler(response); |
| |
|
| | private class TestHandler : DelegatingHandler |
| | { |
| | internal TestHandler(HttpMessageHandler handler) : base(handler) |
| | { |
| | } |
| |
|
| | internal Task<HttpResponseMessage> ExposedSendAync( |
| | HttpRequestMessage request, CancellationToken cancellationToken) => |
| | base.SendAsync(request, cancellationToken); |
| | } |
| |
|
| | private class SingleResponseHandler : HttpMessageHandler |
| | { |
| | private readonly HttpResponseMessage _response; |
| |
|
| | internal SingleResponseHandler(HttpResponseMessage response) |
| | { |
| | _response = response; |
| | } |
| |
|
| | protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) |
| | => Task.FromResult(_response); |
| | } |
| | } |
| | } |
| |
|