adding
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
namespace LCU.API.Internal.Document.PerformanceTest.API;
|
||||
|
||||
public static class ApiFactory
|
||||
{
|
||||
public static IDocumentApi Api => Environment.Type switch
|
||||
{
|
||||
EnvironmentType.Local => new DirectInMemoryDocumentApi(),
|
||||
EnvironmentType.Azure => new DirectInMemoryDocumentApi(),
|
||||
_ => throw new NotImplementedException()
|
||||
};
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
using LCU.API.Internal.Document.Configurations;
|
||||
using LCU.API.Internal.Document.Controllers;
|
||||
using LCU.API.Internal.Document.PerformanceTest.DB;
|
||||
using LCU.API.Internal.DocumentLib.Configurations;
|
||||
using LCU.API.Internal.DocumentLib.DataAccess;
|
||||
using LCU.Library.Internal.DocumentModels.Requests.Search;
|
||||
using LCU.Library.Internal.DocumentModels.Responses;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LCU.API.Internal.Document.PerformanceTest.API;
|
||||
|
||||
public class DirectInMemoryDocumentApi : IDocumentApi
|
||||
{
|
||||
private IServiceProvider? _services;
|
||||
|
||||
public Task SpinUp(DatabaseConfiguration databaseConfiguration)
|
||||
{
|
||||
if (_services is not null) return Task.CompletedTask;
|
||||
|
||||
var services = new ServiceCollection();
|
||||
ServiceRegistrations.AddDocumentServices(services);
|
||||
ServiceRegistrations.AddDocumentDataAccesses(services);
|
||||
ServiceRegistrations.AddDocumentRepositories(services);
|
||||
services.AddTransient<DocumentController>();
|
||||
services.TryAddSingleton(databaseConfiguration);
|
||||
services.AddSingleton<IBlobStorageClient, NullBlobStorageClient>();
|
||||
services.AddSingleton<ApiConfiguration>();
|
||||
services.AddSingleton<NotificationApiConfiguration>();
|
||||
_services = services.BuildServiceProvider();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task<IList<DocumentInformationResponse>> GetDocumentInformationByFilter(DocumentInformationFilter filter)
|
||||
{
|
||||
var controller = _services?.GetRequiredService<DocumentController>() ?? throw new InvalidOperationException();
|
||||
var response = await controller.PostDocumentInformationByFilter(new DocumentInformationFilteredSearch{ Filter = filter });
|
||||
|
||||
return (response as OkObjectResult)?.Value as IList<DocumentInformationResponse> ?? throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public Task TearDown()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using LCU.API.Internal.DocumentLib.Configurations;
|
||||
using LCU.Library.Internal.DocumentModels.Requests.Search;
|
||||
using LCU.Library.Internal.DocumentModels.Responses;
|
||||
|
||||
namespace LCU.API.Internal.Document.PerformanceTest.API;
|
||||
|
||||
public interface IDocumentApi
|
||||
{
|
||||
Task SpinUp(DatabaseConfiguration databaseConfiguration);
|
||||
Task<IList<DocumentInformationResponse>> GetDocumentInformationByFilter(DocumentInformationFilter filter);
|
||||
Task TearDown();
|
||||
}
|
||||
Reference in New Issue
Block a user