persistence/DD.Persistence.IntegrationTests/TestHttpClientFactory.cs

28 lines
838 B
C#

using DD.Persistence.Client.Helpers;
using Microsoft.Extensions.Configuration;
namespace DD.Persistence.IntegrationTests
{
/// <summary>
/// Фабрика HTTP клиентов для интеграционных тестов
/// </summary>
public class TestHttpClientFactory : IHttpClientFactory
{
private readonly WebAppFactoryFixture factory;
private readonly IConfiguration configuration;
public TestHttpClientFactory(WebAppFactoryFixture factory, IConfiguration configuration)
{
this.factory = factory;
this.configuration = configuration;
}
public HttpClient CreateClient(string name)
{
var client = factory.CreateClient();
client.Authorize(configuration);
return client;
}
}
}