Created
April 1, 2019 05:09
-
-
Save romeshniriella/aa894d0a71c9c0c3b325214d9178ebf7 to your computer and use it in GitHub Desktop.
Register a Decorated HttpClient Dependency
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 static class ServiceCollectionExtensions | |
{ | |
public static IServiceCollection AddAdapterApiTestClient(this IServiceCollection services, string apiUri, ConcurrentBag<DaResponse> receivedResponses) | |
{ | |
services.AddHttpClient<ApiClient>(client => client.BaseAddress = new Uri(apiUri)); | |
services | |
.AddSingleton<IAdapterApiClient, ApiClientSpy>(provider => | |
new ApiClientSpy(provider.GetRequiredService<ApiClient>(), receivedResponses)); | |
return services; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment