Adds Presentation Api layer integration tests for file system browser dialog

This commit is contained in:
BinaryAlley committed 2024-10-11 21:03:21 +03:00
1 parent 2550bf8a3f
commit b94c299180
20 files changed
+2414 -24

No files matched your search

@@ -37,6 +37,8 @@ public static class PresentationApiLayerServices
// add services to the container
services.AddControllers().AddJsonOptions(options =>
{
options.JsonSerializerOptions.MaxDepth = 256;
options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; // needed because file system API responses can have very nested structures
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
options.JsonSerializerOptions.Converters.Add(new OptionalJsonConverterFactory());
});
@@ -49,7 +49,7 @@ public class DirectoriesController : ApiController
[FromQuery] bool includeFiles, [FromQuery] bool includeHiddenElements, [EnumeratorCancellation] CancellationToken cancellationToken)
{
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _mediator.Send(new GetDirectoryTreeQuery(path, includeFiles, includeHiddenElements), cancellationToken).ConfigureAwait(false);
if (!result.IsError && result.Value is not null)
if (!result.IsError)
{
foreach (FileSystemTreeNodeResponse treeNode in result.Value)
{
@@ -71,7 +71,7 @@ public class DirectoriesController : ApiController
[FromQuery] bool includeHiddenElements, [EnumeratorCancellation] CancellationToken cancellationToken)
{
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _mediator.Send(new GetTreeDirectoriesQuery(path,includeHiddenElements), cancellationToken).ConfigureAwait(false);
if (!result.IsError && result.Value is not null)
if (!result.IsError)
{
foreach (FileSystemTreeNodeResponse directory in result.Value)
{
@@ -93,7 +93,7 @@ public class DirectoriesController : ApiController
[FromQuery] bool includeHiddenElements, [EnumeratorCancellation] CancellationToken cancellationToken)
{
ErrorOr<IEnumerable<DirectoryResponse>> result = await _mediator.Send(new GetDirectoriesQuery(path, includeHiddenElements), cancellationToken).ConfigureAwait(false);
if (!result.IsError && result.Value is not null)
if (!result.IsError)
{
foreach (DirectoryResponse directory in result.Value)
{
@@ -48,7 +48,7 @@ public class FilesController : ApiController
[FromQuery] bool includeHiddenElements, [EnumeratorCancellation] CancellationToken cancellationToken)
{
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _mediator.Send(new GetTreeFilesQuery(path, includeHiddenElements), cancellationToken).ConfigureAwait(false);
if (!result.IsError && result.Value is not null)
if (!result.IsError)
{
foreach (FileSystemTreeNodeResponse file in result.Value)
{
@@ -70,7 +70,7 @@ public class FilesController : ApiController
[FromQuery] bool includeHiddenElements, [EnumeratorCancellation] CancellationToken cancellationToken)
{
ErrorOr<IEnumerable<FileResponse>> result = await _mediator.Send(new GetFilesQuery(path, includeHiddenElements), cancellationToken).ConfigureAwait(false);
if (!result.IsError && result.Value is not null)
if (!result.IsError)
{
foreach (FileResponse file in result.Value)
{
+1 -1
View File
@@ -54,4 +54,4 @@ public class Program
await app.RunAsync().ConfigureAwait(false);
}
#endregion
}
}
@@ -32,7 +32,12 @@ public static class PresentationWebLayerServices
public static IServiceCollection AddPresentationWebLayerServices(this IServiceCollection services)
{
services.AddControllersWithViews(options => options.Filters.Add(typeof(ApiExceptionFilter)))
.AddJsonOptions(options => options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()));
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.MaxDepth = 256;
options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; // needed because file system API responses can have very nested structures
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
});
// scan the current assembly for validators and register them to the DI container
services.AddValidatorsFromAssemblyContaining<Program>(ServiceLifetime.Singleton);