Created
November 21, 2017 22:55
-
-
Save GeorgDangl/0e128bfb3fff96e51a0bbc89ea331e89 to your computer and use it in GitHub Desktop.
How to not implement your HttpMessageHandler when using the Asp.Net Core TestHost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IntegrationTestsHttpMessageHandler : HttpMessageHandler | |
{ | |
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | |
{ | |
var handler = TestServer.CreateHandler(); | |
return handler.SendAsync(request, cancellationToken); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IntegrationTestsHttpMessageHandler : HttpMessageHandler | |
{ | |
private HttpClient Client => TestServer.CreateClient(); | |
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | |
{ | |
return Client.SendAsync(request, cancellationToken); | |
} | |
} | |
Action<JwtBearerOptions> additionalJwtOptions = options => | |
{ | |
options.BackchannelHttpHandler = new IntegrationTestsHttpMessageHandler(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment