Пуш изменений в проекте с интеграционными тестами
Some checks failed
Unit tests / test (push) Failing after 1m11s
Some checks failed
Unit tests / test (push) Failing after 1m11s
This commit is contained in:
parent
d0cd647849
commit
4ec4ec17eb
@ -23,6 +23,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DD.Persistence.Client\DD.Persistence.Client.csproj" />
|
||||
<ProjectReference Include="..\DD.Persistence.Database.Postgres\DD.Persistence.Database.Postgres.csproj" />
|
||||
<ProjectReference Include="..\DD.Persistence.Database\DD.Persistence.Database.csproj" />
|
||||
<ProjectReference Include="..\DD.Persistence.Repository\DD.Persistence.Repository.csproj" />
|
||||
|
@ -9,9 +9,9 @@ public class DataSourceSystemClient : BaseClient, IDataSourceSystemClient
|
||||
{
|
||||
private readonly IRefitDataSourceSystemClient dataSourceSystemClient;
|
||||
|
||||
public DataSourceSystemClient(IRefitDataSourceSystemClient dataSourceSystemClient, ILogger<DataSourceSystemClient> logger) : base(logger)
|
||||
public DataSourceSystemClient(IRefitClientFactory<IRefitDataSourceSystemClient> dataSourceSystemClientFactory, ILogger<DataSourceSystemClient> logger) : base(logger)
|
||||
{
|
||||
this.dataSourceSystemClient = dataSourceSystemClient;
|
||||
this.dataSourceSystemClient = dataSourceSystemClientFactory.Create();
|
||||
}
|
||||
|
||||
public async Task Add(DataSourceSystemDto dataSourceSystemDto, CancellationToken token)
|
||||
|
@ -2,7 +2,7 @@
|
||||
using Refit;
|
||||
|
||||
namespace DD.Persistence.Client.Clients.Interfaces.Refit;
|
||||
public interface IRefitDataSourceSystemClient : IDisposable
|
||||
public interface IRefitDataSourceSystemClient : IRefitClient, IDisposable
|
||||
{
|
||||
private const string BaseRoute = "/api/dataSourceSystem";
|
||||
|
||||
|
@ -3,7 +3,7 @@ using Refit;
|
||||
|
||||
namespace DD.Persistence.Client.Clients.Interfaces.Refit;
|
||||
|
||||
public interface IRefitSetpointClient : IDisposable
|
||||
public interface IRefitSetpointClient : IRefitClient, IDisposable
|
||||
{
|
||||
private const string BaseRoute = "/api/setpoint";
|
||||
|
||||
|
@ -3,7 +3,7 @@ using DD.Persistence.Models;
|
||||
using Refit;
|
||||
|
||||
namespace DD.Persistence.Client.Clients.Interfaces.Refit;
|
||||
public interface IRefitWitsDataClient : IDisposable
|
||||
public interface IRefitWitsDataClient : IRefitClient, IDisposable
|
||||
{
|
||||
private const string BaseRoute = "/api/witsData";
|
||||
|
||||
|
@ -10,9 +10,9 @@ public class SetpointClient : BaseClient, ISetpointClient
|
||||
{
|
||||
private readonly IRefitSetpointClient refitSetpointClient;
|
||||
|
||||
public SetpointClient(IRefitSetpointClient refitSetpointClient, ILogger<SetpointClient> logger) : base(logger)
|
||||
public SetpointClient(IRefitClientFactory<IRefitSetpointClient> refitSetpointClientFactory, ILogger<SetpointClient> logger) : base(logger)
|
||||
{
|
||||
this.refitSetpointClient = refitSetpointClient;
|
||||
this.refitSetpointClient = refitSetpointClientFactory.Create();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SetpointValueDto>> GetCurrent(IEnumerable<Guid> setpointKeys, CancellationToken token)
|
||||
|
@ -18,11 +18,12 @@ public static class DependencyInjection
|
||||
{
|
||||
services.AddSingleton(typeof(IRefitClientFactory<>), typeof(RefitClientFactory<>));
|
||||
services.AddTransient<IChangeLogClient, ChangeLogClient>();
|
||||
//services.AddTransient<ISetpointClient, SetpointClient>();
|
||||
//services.AddTransient<ISetpointClient, SetpointClient>();
|
||||
//services.AddTransient<ISetpointClient, SetpointClient>();
|
||||
//services.AddTransient<ISetpointClient, SetpointClient>();
|
||||
//services.AddTransient<ISetpointClient, SetpointClient>();
|
||||
services.AddTransient<IDataSourceSystemClient, DataSourceSystemClient>();
|
||||
services.AddTransient<ISetpointClient, SetpointClient>();
|
||||
//services.AddTransient<ITechMessagesClient, TechMessagesClient>();
|
||||
//services.AddTransient<ITimeSeriesClient<>, TimeSeriesClient<>>();
|
||||
//services.AddTransient<ITimeSeriesClient, TimeSeriesClient>();
|
||||
//services.AddTransient<IWitsDataClient, WitsDataClient>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
@ -47,15 +47,15 @@ namespace DD.Persistence.Client
|
||||
/// Получить клиент для работы с уставками
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ISetpointClient GetSetpointClient()
|
||||
{
|
||||
var logger = provider.GetRequiredService<ILogger<SetpointClient>>();
|
||||
//public ISetpointClient GetSetpointClient()
|
||||
//{
|
||||
// var logger = provider.GetRequiredService<ILogger<SetpointClient>>();
|
||||
|
||||
var restClient = RestService.For<IRefitSetpointClient>(httpClient, RefitSettings);
|
||||
var client = new SetpointClient(restClient, logger);
|
||||
// var restClient = RestService.For<IRefitSetpointClient>(httpClient, RefitSettings);
|
||||
// var client = new SetpointClient(restClient, logger);
|
||||
|
||||
return client;
|
||||
}
|
||||
// return client;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Получить клиент для работы с технологическими сообщениями
|
||||
@ -133,14 +133,14 @@ namespace DD.Persistence.Client
|
||||
/// Получить клиент для работы c системами
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IDataSourceSystemClient GetDataSourceSystemClient()
|
||||
{
|
||||
var logger = provider.GetRequiredService<ILogger<DataSourceSystemClient>>();
|
||||
//public IDataSourceSystemClient GetDataSourceSystemClient()
|
||||
//{
|
||||
// var logger = provider.GetRequiredService<ILogger<DataSourceSystemClient>>();
|
||||
|
||||
var restClient = RestService.For<IRefitDataSourceSystemClient>(httpClient, RefitSettings);
|
||||
var client = new DataSourceSystemClient(restClient, logger);
|
||||
// var restClient = RestService.For<IRefitDataSourceSystemClient>(httpClient, RefitSettings);
|
||||
// var client = new DataSourceSystemClient(restClient, logger);
|
||||
|
||||
return client;
|
||||
}
|
||||
// return client;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,10 @@ public class RefitClientFactory<T> : IRefitClientFactory<T> where T : IRefitClie
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public RefitClientFactory(IConfiguration configuration, ILogger<IRefitClientFactory<T>> logger)
|
||||
public RefitClientFactory(IConfiguration configuration, ILogger<IRefitClientFactory<T>> logger, HttpClient client)
|
||||
{
|
||||
this.client = new HttpClient();
|
||||
//this.client = factory.CreateClient();
|
||||
this.client = client;
|
||||
|
||||
var baseUrl = configuration.GetSection("ClientUrl").Get<string>();
|
||||
if (String.IsNullOrEmpty(baseUrl))
|
||||
@ -49,8 +50,6 @@ public class RefitClientFactory<T> : IRefitClientFactory<T> where T : IRefitClie
|
||||
/// <returns></returns>
|
||||
public T Create()
|
||||
{
|
||||
|
||||
|
||||
return RestService.For<T>(client, refitSettings);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ using DD.Persistence.Client.Clients.Interfaces;
|
||||
using DD.Persistence.Database.Entity;
|
||||
using DD.Persistence.Models;
|
||||
using Xunit;
|
||||
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DD.Persistence.IntegrationTests.Controllers
|
||||
{
|
||||
@ -16,11 +18,12 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
||||
private readonly IMemoryCache memoryCache;
|
||||
public DataSourceSystemControllerTest(WebAppFactoryFixture factory) : base(factory)
|
||||
{
|
||||
var scope = factory.Services.CreateScope();
|
||||
var persistenceClientFactory = scope.ServiceProvider
|
||||
.GetRequiredService<PersistenceClientFactory>();
|
||||
var refitClientFactory = scope.ServiceProvider
|
||||
.GetRequiredService<IRefitClientFactory<IRefitDataSourceSystemClient>>();
|
||||
var logger = scope.ServiceProvider.GetRequiredService<ILogger<DataSourceSystemClient>>();
|
||||
|
||||
dataSourceSystemClient = persistenceClientFactory.GetDataSourceSystemClient();
|
||||
dataSourceSystemClient = scope.ServiceProvider
|
||||
.GetRequiredService<IDataSourceSystemClient>();
|
||||
memoryCache = scope.ServiceProvider.GetRequiredService<IMemoryCache>();
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,9 @@ using DD.Persistence.Client.Clients.Interfaces;
|
||||
using DD.Persistence.Database.Model;
|
||||
using System.Net;
|
||||
using Xunit;
|
||||
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
||||
using DD.Persistence.Client.Clients;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DD.Persistence.IntegrationTests.Controllers
|
||||
{
|
||||
@ -17,11 +20,12 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
||||
}
|
||||
public SetpointControllerTest(WebAppFactoryFixture factory) : base(factory)
|
||||
{
|
||||
var scope = factory.Services.CreateScope();
|
||||
var persistenceClientFactory = scope.ServiceProvider
|
||||
.GetRequiredService<PersistenceClientFactory>();
|
||||
var refitClientFactory = scope.ServiceProvider
|
||||
.GetRequiredService<IRefitClientFactory<IRefitSetpointClient>>();
|
||||
var logger = scope.ServiceProvider.GetRequiredService<ILogger<SetpointClient>>();
|
||||
|
||||
setpointClient = persistenceClientFactory.GetSetpointClient();
|
||||
setpointClient = scope.ServiceProvider
|
||||
.GetRequiredService<ISetpointClient>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -5,6 +5,9 @@ using System.Net;
|
||||
using Xunit;
|
||||
using DD.Persistence.Client.Clients.Interfaces;
|
||||
using DD.Persistence.Client;
|
||||
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
||||
using DD.Persistence.Client.Clients;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DD.Persistence.IntegrationTests.Controllers;
|
||||
public class WitsDataControllerTest : BaseIntegrationTest
|
||||
@ -13,11 +16,12 @@ public class WitsDataControllerTest : BaseIntegrationTest
|
||||
|
||||
public WitsDataControllerTest(WebAppFactoryFixture factory) : base(factory)
|
||||
{
|
||||
var scope = factory.Services.CreateScope();
|
||||
var persistenceClientFactory = scope.ServiceProvider
|
||||
.GetRequiredService<PersistenceClientFactory>();
|
||||
var refitClientFactory = scope.ServiceProvider
|
||||
.GetRequiredService<IRefitClientFactory<IRefitWitsDataClient>>();
|
||||
var logger = scope.ServiceProvider.GetRequiredService<ILogger<WitsDataClient>>();
|
||||
|
||||
witsDataClient = persistenceClientFactory.GetWitsDataClient();
|
||||
witsDataClient = scope.ServiceProvider
|
||||
.GetRequiredService<IWitsDataClient>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -45,7 +45,8 @@ public class WebAppFactoryFixture : WebApplicationFactory<Program>
|
||||
return new TestHttpClientFactory(this);
|
||||
});
|
||||
|
||||
services.AddSingleton<PersistenceClientFactory>();
|
||||
services.AddHttpClient();
|
||||
//services.AddSingleton<PersistenceClientFactory>();
|
||||
services.AddPersistenceClients();
|
||||
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
@ -57,9 +58,6 @@ public class WebAppFactoryFixture : WebApplicationFactory<Program>
|
||||
dbContext.Database.EnsureCreatedAndMigrated();
|
||||
dbContext.SaveChanges();
|
||||
});
|
||||
|
||||
builder.UseUrls("http://localhost:5000");
|
||||
|
||||
}
|
||||
|
||||
public override async ValueTask DisposeAsync()
|
||||
|
Loading…
Reference in New Issue
Block a user