2024-12-28 15:30:31 +05:00
|
|
|
|
using DD.Persistence.Client.Helpers;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
|
|
|
|
namespace DD.Persistence.IntegrationTests
|
2024-11-21 14:50:36 +05:00
|
|
|
|
{
|
2024-12-09 13:19:55 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Фабрика HTTP клиентов для интеграционных тестов
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class TestHttpClientFactory : IHttpClientFactory
|
|
|
|
|
{
|
|
|
|
|
private readonly WebAppFactoryFixture factory;
|
2024-12-28 15:30:31 +05:00
|
|
|
|
private readonly IConfiguration configuration;
|
2024-11-21 14:50:36 +05:00
|
|
|
|
|
2024-12-28 15:30:31 +05:00
|
|
|
|
public TestHttpClientFactory(WebAppFactoryFixture factory, IConfiguration configuration)
|
2024-12-09 13:19:55 +05:00
|
|
|
|
{
|
|
|
|
|
this.factory = factory;
|
2024-12-28 15:30:31 +05:00
|
|
|
|
this.configuration = configuration;
|
2024-12-09 13:19:55 +05:00
|
|
|
|
}
|
|
|
|
|
public HttpClient CreateClient(string name)
|
|
|
|
|
{
|
2024-12-28 15:30:31 +05:00
|
|
|
|
var client = factory.CreateClient();
|
|
|
|
|
client.Authorize(configuration);
|
|
|
|
|
|
|
|
|
|
return client;
|
2024-12-09 13:19:55 +05:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-21 14:50:36 +05:00
|
|
|
|
}
|