diff --git a/DD.Persistence.Client/IRefitClientFactory.cs b/DD.Persistence.Client/IRefitClientFactory.cs
index 0b41a9a..0015a95 100644
--- a/DD.Persistence.Client/IRefitClientFactory.cs
+++ b/DD.Persistence.Client/IRefitClientFactory.cs
@@ -1,9 +1,4 @@
using DD.Persistence.Client.Clients.Interfaces.Refit;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace DD.Persistence.Client;
diff --git a/DD.Persistence.Client/PersistenceClientFactory.cs b/DD.Persistence.Client/PersistenceClientFactory.cs
deleted file mode 100644
index 99660e9..0000000
--- a/DD.Persistence.Client/PersistenceClientFactory.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-//using Microsoft.Extensions.Configuration;
-//using DD.Persistence.Client.Clients.Interfaces;
-//using DD.Persistence.Client.Clients;
-//using DD.Persistence.Client.Helpers;
-//using Refit;
-//using DD.Persistence.Factories;
-//using DD.Persistence.Client.Clients.Interfaces.Refit;
-//using Microsoft.Extensions.Logging;
-//using Microsoft.Extensions.DependencyInjection;
-//using System.Text.Json;
-
-//namespace DD.Persistence.Client
-//{
-// ///
-// /// Фабрика клиентов для доступа к Persistence - сервису
-// ///
-// public class PersistenceClientFactory
-// {
-// private static readonly JsonSerializerOptions JsonSerializerOptions = new()
-// {
-// PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
-// PropertyNameCaseInsensitive = true
-// };
-// private static readonly RefitSettings RefitSettings = new(new SystemTextJsonContentSerializer(JsonSerializerOptions));
-// private readonly IServiceProvider provider;
-// private HttpClient httpClient;
-// public PersistenceClientFactory(IHttpClientFactory httpClientFactory, IServiceProvider provider, IConfiguration configuration)
-// {
-// this.provider = provider;
-
-// httpClient = httpClientFactory.CreateClient();
-
-// httpClient.Authorize(configuration);
-// }
-
-// public PersistenceClientFactory(IHttpClientFactory httpClientFactory, IAuthTokenFactory authTokenFactory, IServiceProvider provider, IConfiguration configuration)
-// {
-// this.provider = provider;
-
-// httpClient = httpClientFactory.CreateClient();
-
-// var token = authTokenFactory.GetToken();
-// httpClient.Authorize(token);
-// }
-
-// ///
-// /// Получить клиент для работы с уставками
-// ///
-// ///
-// //public ISetpointClient GetSetpointClient()
-// //{
-// // var logger = provider.GetRequiredService>();
-
-// // var restClient = RestService.For(httpClient, RefitSettings);
-// // var client = new SetpointClient(restClient, logger);
-
-// // return client;
-// //}
-
-// ///
-// /// Получить клиент для работы с технологическими сообщениями
-// ///
-// ///
-// //public ITechMessagesClient GetTechMessagesClient()
-// //{
-// // var logger = provider.GetRequiredService>();
-
-// // var restClient = RestService.For(httpClient, RefitSettings);
-// // var client = new TechMessagesClient(restClient, logger);
-
-// // return client;
-// //}
-
-// ///
-// /// Получить клиент для работы с временными данными
-// ///
-// ///
-// ///
-// //public ITimeSeriesClient GetTimeSeriesClient()
-// // where TDto : class, new()
-// //{
-// // var logger = provider.GetRequiredService>>();
-
-// // var restClient = RestService.For>(httpClient, RefitSettings);
-// // var client = new TimeSeriesClient(restClient, logger);
-
-// // return client;
-// //}
-
-// ///
-// /// Получить клиент для работы с данными с отметкой времени
-// ///
-// ///
-// //public ITimestampedSetClient GetTimestampedSetClient()
-// //{
-// // var logger = provider.GetRequiredService>();
-
-// // var restClient = RestService.For(httpClient, RefitSettings);
-// // var client = new TimestampedSetClient(restClient, logger);
-
-// // return client;
-// //}
-
-// ///
-// /// Получить клиент для работы с записями ChangeLog
-// ///
-// ///
-// //public IChangeLogClient GetChangeLogClient()
-// //{
-// // var logger = provider.GetRequiredService>();
-
-// // var restClient = RestService.For(httpClient, RefitSettings);
-// // var client = new ChangeLogClient(restClient, logger);
-
-// // return client;
-// //}
-
-// ///
-// /// Получить клиент для работы c параметрами Wits
-// ///
-// ///
-// //public IWitsDataClient GetWitsDataClient()
-// //{
-// // var logger = provider.GetRequiredService>();
-
-// // var restClient = RestService.For(httpClient, RefitSettings);
-// // var client = new WitsDataClient(restClient, logger);
-
-// // return client;
-// //}
-
-// ///
-// /// Получить клиент для работы c системами
-// ///
-// ///
-// //public IDataSourceSystemClient GetDataSourceSystemClient()
-// //{
-// // var logger = provider.GetRequiredService>();
-
-// // var restClient = RestService.For(httpClient, RefitSettings);
-// // var client = new DataSourceSystemClient(restClient, logger);
-
-// // return client;
-// //}
-// }
-//}
diff --git a/DD.Persistence.Client/RefitClientFactory.cs b/DD.Persistence.Client/RefitClientFactory.cs
index 758f79d..9cd0bef 100644
--- a/DD.Persistence.Client/RefitClientFactory.cs
+++ b/DD.Persistence.Client/RefitClientFactory.cs
@@ -17,9 +17,7 @@ public class RefitClientFactory : IRefitClientFactory where T : IRefitClie
private HttpClient client;
private RefitSettings refitSettings;
- ///
- ///
- ///
+ ///
public RefitClientFactory(IConfiguration configuration, ILogger> logger, HttpClient client)
{
//this.client = factory.CreateClient();
@@ -35,7 +33,6 @@ public class RefitClientFactory : IRefitClientFactory where T : IRefitClie
throw exception;
}
client.BaseAddress = new Uri(baseUrl);
- client.Authorize(configuration);
JsonSerializerOptions JsonSerializerOptions = new()
{
diff --git a/DD.Persistence.IntegrationTests/TestHttpClientFactory.cs b/DD.Persistence.IntegrationTests/TestHttpClientFactory.cs
index b0f86c8..51b8783 100644
--- a/DD.Persistence.IntegrationTests/TestHttpClientFactory.cs
+++ b/DD.Persistence.IntegrationTests/TestHttpClientFactory.cs
@@ -1,4 +1,7 @@
-namespace DD.Persistence.IntegrationTests
+using DD.Persistence.Client.Helpers;
+using Microsoft.Extensions.Configuration;
+
+namespace DD.Persistence.IntegrationTests
{
///
/// Фабрика HTTP клиентов для интеграционных тестов
@@ -6,14 +9,19 @@
public class TestHttpClientFactory : IHttpClientFactory
{
private readonly WebAppFactoryFixture factory;
+ private readonly IConfiguration configuration;
- public TestHttpClientFactory(WebAppFactoryFixture factory)
+ public TestHttpClientFactory(WebAppFactoryFixture factory, IConfiguration configuration)
{
this.factory = factory;
+ this.configuration = configuration;
}
public HttpClient CreateClient(string name)
{
- return factory.CreateClient();
+ var client = factory.CreateClient();
+ client.Authorize(configuration);
+
+ return client;
}
}
}
diff --git a/DD.Persistence.IntegrationTests/WebAppFactoryFixture.cs b/DD.Persistence.IntegrationTests/WebAppFactoryFixture.cs
index df6deb1..0d680b3 100644
--- a/DD.Persistence.IntegrationTests/WebAppFactoryFixture.cs
+++ b/DD.Persistence.IntegrationTests/WebAppFactoryFixture.cs
@@ -11,6 +11,9 @@ using DD.Persistence.Database.Model;
using DD.Persistence.Database.Postgres;
using RestSharp;
using DD.Persistence.App;
+using DD.Persistence.Client.Helpers;
+using DD.Persistence.Factories;
+using System.Net;
namespace DD.Persistence.IntegrationTests;
public class WebAppFactoryFixture : WebApplicationFactory
@@ -40,13 +43,11 @@ public class WebAppFactoryFixture : WebApplicationFactory
services.AddLogging(builder => builder.AddConsole());
services.RemoveAll();
- services.AddSingleton(provider =>
- {
- return new TestHttpClientFactory(this);
- });
-
+ services.AddSingleton((provider) =>
+ {
+ return new TestHttpClientFactory(this, provider.GetRequiredService());
+ });
services.AddHttpClient();
- //services.AddSingleton();
services.AddPersistenceClients();
var serviceProvider = services.BuildServiceProvider();