49 lines
2.0 KiB
C#
49 lines
2.0 KiB
C#
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;
|
|
}
|
|
} |