Replaces ErrorOr library with a custom implementation.

This commit is contained in:
BinaryAlley committed 2026-08-14 03:04:28 -07:00
1 parent 8fe90a4dde
commit 3b772d68ca
436 files changed
+4234 -3922

No files matched your search

@@ -1,12 +1,12 @@
#region ========================================================================= USING =====================================================================================
using AutoFixture;
using AutoFixture.AutoNSubstitute;
using ErrorOr;
using FastEndpoints;
using Lumina.Application.Common.CQRS;
using Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectories;
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
using Lumina.Contracts.Responses.FileSystemManagement.Directories;
using Lumina.Domain.Common.Primitives;
using Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Directories.GetDirectories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
@@ -28,7 +28,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.
public class GetDirectoriesEndpointTests
{
private readonly IFixture _fixture;
private readonly IQueryHandler<GetDirectoriesQuery, ErrorOr<IEnumerable<DirectoryResponse>>> _mockHandler;
private readonly IQueryHandler<GetDirectoriesQuery, Result<IEnumerable<DirectoryResponse>>> _mockHandler;
private readonly GetDirectoriesEndpoint _sut;
/// <summary>
@@ -37,7 +37,7 @@ public class GetDirectoriesEndpointTests
public GetDirectoriesEndpointTests()
{
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
_mockHandler = Substitute.For<IQueryHandler<GetDirectoriesQuery, ErrorOr<IEnumerable<DirectoryResponse>>>>();
_mockHandler = Substitute.For<IQueryHandler<GetDirectoriesQuery, Result<IEnumerable<DirectoryResponse>>>>();
_sut = Factory.Create<GetDirectoriesEndpoint>(_mockHandler);
}
@@ -47,9 +47,9 @@ public class GetDirectoriesEndpointTests
// Arrange
GetDirectoriesRequest request = _fixture.Create<GetDirectoriesRequest>();
CancellationToken cancellationToken = CancellationToken.None;
List<DirectoryResponse> expectedResponses = _fixture.CreateMany<DirectoryResponse>(3).ToList();
List<DirectoryResponse> expectedResponses = [.. _fixture.CreateMany<DirectoryResponse>(3)];
_mockHandler.HandleAsync(Arg.Any<GetDirectoriesQuery>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(expectedResponses.AsEnumerable()));
.Returns(Result.From(expectedResponses.AsEnumerable()));
// Act
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
@@ -118,7 +118,7 @@ public class GetDirectoriesEndpointTests
GetDirectoriesRequest request = _fixture.Create<GetDirectoriesRequest>();
CancellationToken cancellationToken = CancellationToken.None;
_mockHandler.HandleAsync(Arg.Any<GetDirectoriesQuery>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(Enumerable.Empty<DirectoryResponse>()));
.Returns(Result.From(Enumerable.Empty<DirectoryResponse>()));
// Act
await _sut.ExecuteAsync(request, cancellationToken);
@@ -144,7 +144,7 @@ public class GetDirectoriesEndpointTests
operationStarted.SetResult(true);
await cancellationRequested.Task;
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
return ErrorOrFactory.From(_fixture.CreateMany<DirectoryResponse>(3).AsEnumerable());
return Result.From(_fixture.CreateMany<DirectoryResponse>(3).AsEnumerable());
}, callInfo.Arg<CancellationToken>()));
// Act
@@ -1,9 +1,9 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using Lumina.Application.Common.CQRS;
using Lumina.Application.Core.FileSystemManagement.Drives.Queries.GetDrives;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Lumina.Domain.Common.Primitives;
using Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Drives.GetDrives;
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.Fixtures;
using Microsoft.AspNetCore.Http;
@@ -25,7 +25,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.
[ExcludeFromCodeCoverage]
public class GetDrivesEndpointTests
{
private readonly IQueryHandler<GetDrivesQuery, ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>> _mockHandler;
private readonly IQueryHandler<GetDrivesQuery, Result<IEnumerable<FileSystemTreeNodeResponse>>> _mockHandler;
private readonly GetDrivesEndpoint _sut;
private readonly FileSystemTreeNodeResponseFixture _fileSystemTreeNodeResponseFixture;
@@ -34,7 +34,7 @@ public class GetDrivesEndpointTests
/// </summary>
public GetDrivesEndpointTests()
{
_mockHandler = Substitute.For<IQueryHandler<GetDrivesQuery, ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>>>();
_mockHandler = Substitute.For<IQueryHandler<GetDrivesQuery, Result<IEnumerable<FileSystemTreeNodeResponse>>>>();
_fileSystemTreeNodeResponseFixture = new FileSystemTreeNodeResponseFixture();
_sut = Factory.Create<GetDrivesEndpoint>(_mockHandler);
}
@@ -46,7 +46,7 @@ public class GetDrivesEndpointTests
CancellationToken cancellationToken = CancellationToken.None;
List<FileSystemTreeNodeResponse> expectedResponses = _fileSystemTreeNodeResponseFixture.CreateMany(3, 1, 1);
_mockHandler.HandleAsync(Arg.Any<GetDrivesQuery>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(expectedResponses.AsEnumerable()));
.Returns(Result.From(expectedResponses.AsEnumerable()));
// Act
IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
@@ -87,7 +87,7 @@ public class GetDrivesEndpointTests
// Arrange
CancellationToken cancellationToken = CancellationToken.None;
_mockHandler.HandleAsync(Arg.Any<GetDrivesQuery>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(Enumerable.Empty<FileSystemTreeNodeResponse>()));
.Returns(Result.From(Enumerable.Empty<FileSystemTreeNodeResponse>()));
// Act
await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
@@ -110,7 +110,7 @@ public class GetDrivesEndpointTests
operationStarted.SetResult(true);
await cancellationRequested.Task;
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
return ErrorOrFactory.From(_fileSystemTreeNodeResponseFixture.CreateMany(3, 1, 1).AsEnumerable());
return Result.From(_fileSystemTreeNodeResponseFixture.CreateMany(3, 1, 1).AsEnumerable());
}, callInfo.Arg<CancellationToken>()));
// Act
@@ -1,13 +1,12 @@
#region ========================================================================= USING =====================================================================================
using AutoFixture;
using AutoFixture.AutoNSubstitute;
using ErrorOr;
using FastEndpoints;
using Lumina.Application.Common.CQRS;
using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetFiles;
using Lumina.Contracts.Requests.FileSystemManagement.Files;
using Lumina.Contracts.Responses.FileSystemManagement.Files;
using Lumina.Presentation.Api.Common.Http;
using Lumina.Domain.Common.Primitives;
using Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Files.GetFiles;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
@@ -16,7 +15,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
#endregion
@@ -30,7 +28,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.
public class GetFilesEndpointTests
{
private readonly IFixture _fixture;
private readonly IQueryHandler<GetFilesQuery, ErrorOr<IEnumerable<FileResponse>>> _mockHandler;
private readonly IQueryHandler<GetFilesQuery, Result<IEnumerable<FileResponse>>> _mockHandler;
private readonly GetFilesEndpoint _sut;
/// <summary>
@@ -39,7 +37,7 @@ public class GetFilesEndpointTests
public GetFilesEndpointTests()
{
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
_mockHandler = Substitute.For<IQueryHandler<GetFilesQuery, ErrorOr<IEnumerable<FileResponse>>>>();
_mockHandler = Substitute.For<IQueryHandler<GetFilesQuery, Result<IEnumerable<FileResponse>>>>();
_sut = Factory.Create<GetFilesEndpoint>(_mockHandler);
}
@@ -49,9 +47,9 @@ public class GetFilesEndpointTests
// Arrange
GetFilesRequest request = _fixture.Create<GetFilesRequest>();
CancellationToken cancellationToken = CancellationToken.None;
List<FileResponse> expectedResponses = _fixture.CreateMany<FileResponse>(3).ToList();
List<FileResponse> expectedResponses = [.. _fixture.CreateMany<FileResponse>(3)];
_mockHandler.HandleAsync(Arg.Any<GetFilesQuery>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(expectedResponses.AsEnumerable()));
.Returns(Result.From(expectedResponses.AsEnumerable()));
// Act
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
@@ -120,7 +118,7 @@ public class GetFilesEndpointTests
GetFilesRequest request = _fixture.Create<GetFilesRequest>();
CancellationToken cancellationToken = CancellationToken.None;
_mockHandler.HandleAsync(Arg.Any<GetFilesQuery>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(Enumerable.Empty<FileResponse>()));
.Returns(Result.From(Enumerable.Empty<FileResponse>()));
// Act
await _sut.ExecuteAsync(request, cancellationToken);
@@ -147,7 +145,7 @@ public class GetFilesEndpointTests
operationStarted.SetResult(true);
await cancellationRequested.Task;
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
return ErrorOrFactory.From(_fixture.CreateMany<FileResponse>(3).AsEnumerable());
return Result.From(_fixture.CreateMany<FileResponse>(3).AsEnumerable());
}, callInfo.Arg<CancellationToken>()));
// Act
@@ -1,12 +1,12 @@
#region ========================================================================= USING =====================================================================================
using AutoFixture;
using AutoFixture.AutoNSubstitute;
using ErrorOr;
using FastEndpoints;
using Lumina.Application.Common.CQRS;
using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
using Lumina.Contracts.Requests.FileSystemManagement.Files;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Lumina.Domain.Common.Primitives;
using Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Files.GetTreeFiles;
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.Fixtures;
using Microsoft.AspNetCore.Http;
@@ -29,7 +29,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.
public class GetTreeFilesEndpointTests
{
private readonly IFixture _fixture;
private readonly IQueryHandler<GetTreeFilesQuery, ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>> _mockHandler;
private readonly IQueryHandler<GetTreeFilesQuery, Result<IEnumerable<FileSystemTreeNodeResponse>>> _mockHandler;
private readonly GetTreeFilesEndpoint _sut;
private readonly FileSystemTreeNodeResponseFixture _fileSystemTreeNodeResponseFixture;
@@ -39,7 +39,7 @@ public class GetTreeFilesEndpointTests
public GetTreeFilesEndpointTests()
{
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
_mockHandler = Substitute.For<IQueryHandler<GetTreeFilesQuery, ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>>>();
_mockHandler = Substitute.For<IQueryHandler<GetTreeFilesQuery, Result<IEnumerable<FileSystemTreeNodeResponse>>>>();
_fileSystemTreeNodeResponseFixture = new FileSystemTreeNodeResponseFixture();
_sut = Factory.Create<GetTreeFilesEndpoint>(_mockHandler);
}
@@ -52,7 +52,7 @@ public class GetTreeFilesEndpointTests
CancellationToken cancellationToken = CancellationToken.None;
List<FileSystemTreeNodeResponse> expectedResponses = _fileSystemTreeNodeResponseFixture.CreateMany(3, 3, 5);
_mockHandler.HandleAsync(Arg.Any<GetTreeFilesQuery>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(expectedResponses.AsEnumerable()));
.Returns(Result.From(expectedResponses.AsEnumerable()));
// Act
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
@@ -121,7 +121,7 @@ public class GetTreeFilesEndpointTests
GetTreeFilesRequest request = _fixture.Create<GetTreeFilesRequest>();
CancellationToken cancellationToken = CancellationToken.None;
_mockHandler.HandleAsync(Arg.Any<GetTreeFilesQuery>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(Enumerable.Empty<FileSystemTreeNodeResponse>()));
.Returns(Result.From(Enumerable.Empty<FileSystemTreeNodeResponse>()));
// Act
await _sut.ExecuteAsync(request, cancellationToken);
@@ -148,7 +148,7 @@ public class GetTreeFilesEndpointTests
operationStarted.SetResult(true);
await cancellationRequested.Task;
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
return ErrorOrFactory.From(_fileSystemTreeNodeResponseFixture.CreateMany(3, 3, 5).AsEnumerable());
return Result.From(_fileSystemTreeNodeResponseFixture.CreateMany(3, 3, 5).AsEnumerable());
}, callInfo.Arg<CancellationToken>()));
// Act
@@ -1,10 +1,10 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using Lumina.Application.Common.CQRS;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathExists;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using Lumina.Domain.Common.Primitives;
using Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.CheckPathExists;
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.Fixtures;
using Microsoft.AspNetCore.Http;
@@ -24,7 +24,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.
[ExcludeFromCodeCoverage]
public class CheckPathExistsEndpointTests
{
private readonly IQueryHandler<CheckPathExistsQuery, ErrorOr<PathExistsResponse>> _mockHandler;
private readonly IQueryHandler<CheckPathExistsQuery, Result<PathExistsResponse>> _mockHandler;
private readonly CheckPathExistsEndpoint _sut;
private readonly CheckPathExistsRequestFixture _checkPathExistsRequestFixture;
@@ -33,7 +33,7 @@ public class CheckPathExistsEndpointTests
/// </summary>
public CheckPathExistsEndpointTests()
{
_mockHandler = Substitute.For<IQueryHandler<CheckPathExistsQuery, ErrorOr<PathExistsResponse>>>();
_mockHandler = Substitute.For<IQueryHandler<CheckPathExistsQuery, Result<PathExistsResponse>>>();
_sut = Factory.Create<CheckPathExistsEndpoint>(_mockHandler);
_checkPathExistsRequestFixture = new CheckPathExistsRequestFixture();
}
@@ -89,7 +89,7 @@ public class CheckPathExistsEndpointTests
operationStarted.SetResult(true);
await cancellationRequested.Task;
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
return ErrorOrFactory.From(new PathExistsResponse(true));
return Result.From(new PathExistsResponse(true));
}, callInfo.Arg<CancellationToken>()));
// Act
@@ -1,9 +1,9 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Application.Common.CQRS;
using Lumina.Application.Core.FileSystemManagement.Paths.Commands.CombinePath;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using Lumina.Domain.Common.Primitives;
using Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.CombinePath;
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.Fixtures;
using Microsoft.AspNetCore.Http;
@@ -23,7 +23,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.
[ExcludeFromCodeCoverage]
public class CombinePathEndpointTests
{
private readonly ICommandHandler<CombinePathCommand, ErrorOr<PathSegmentResponse>> _mockHandler;
private readonly ICommandHandler<CombinePathCommand, Result<PathSegmentResponse>> _mockHandler;
private readonly CombinePathEndpoint _sut;
private readonly PathSegmentResponseFixture _pathSegmentResponseFixture;
private readonly CombinePathRequestFixture _combinePathRequestFixture;
@@ -33,7 +33,7 @@ public class CombinePathEndpointTests
/// </summary>
public CombinePathEndpointTests()
{
_mockHandler = Substitute.For<ICommandHandler<CombinePathCommand, ErrorOr<PathSegmentResponse>>>();
_mockHandler = Substitute.For<ICommandHandler<CombinePathCommand, Result<PathSegmentResponse>>>();
_sut = FastEndpoints.Factory.Create<CombinePathEndpoint>(_mockHandler);
_pathSegmentResponseFixture = new PathSegmentResponseFixture();
_combinePathRequestFixture = new CombinePathRequestFixture();
@@ -47,7 +47,7 @@ public class CombinePathEndpointTests
CancellationToken cancellationToken = CancellationToken.None;
PathSegmentResponse expectedResponse = _pathSegmentResponseFixture.Create();
_mockHandler.HandleAsync(Arg.Any<CombinePathCommand>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(expectedResponse));
.Returns(Result.From(expectedResponse));
// Act
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
@@ -116,7 +116,7 @@ public class CombinePathEndpointTests
CombinePathRequest request = _combinePathRequestFixture.Create("C:\\Users", "TestUser");
CancellationToken cancellationToken = CancellationToken.None;
_mockHandler.HandleAsync(Arg.Any<CombinePathCommand>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(_pathSegmentResponseFixture.Create()));
.Returns(Result.From(_pathSegmentResponseFixture.Create()));
// Act
await _sut.ExecuteAsync(request, cancellationToken);
@@ -142,7 +142,7 @@ public class CombinePathEndpointTests
operationStarted.SetResult(true);
await cancellationRequested.Task;
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
return ErrorOrFactory.From(_pathSegmentResponseFixture.Create());
return Result.From(_pathSegmentResponseFixture.Create());
}, callInfo.Arg<CancellationToken>()));
// Act
@@ -1,10 +1,10 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using Lumina.Application.Common.CQRS;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathParent;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using Lumina.Domain.Common.Primitives;
using Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.GetPathParent;
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.Fixtures;
using Microsoft.AspNetCore.Http;
@@ -26,7 +26,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.
[ExcludeFromCodeCoverage]
public class GetPathParentEndpointTests
{
private readonly IQueryHandler<GetPathParentQuery, ErrorOr<IEnumerable<PathSegmentResponse>>> _mockHandler;
private readonly IQueryHandler<GetPathParentQuery, Result<IEnumerable<PathSegmentResponse>>> _mockHandler;
private readonly GetPathParentEndpoint _sut;
private readonly PathSegmentResponseFixture _pathSegmentResponseFixture;
private readonly GetPathParentRequestFixture _getPathParentRequestFixture;
@@ -36,7 +36,7 @@ public class GetPathParentEndpointTests
/// </summary>
public GetPathParentEndpointTests()
{
_mockHandler = Substitute.For<IQueryHandler<GetPathParentQuery, ErrorOr<IEnumerable<PathSegmentResponse>>>>();
_mockHandler = Substitute.For<IQueryHandler<GetPathParentQuery, Result<IEnumerable<PathSegmentResponse>>>>();
_sut = Factory.Create<GetPathParentEndpoint>(_mockHandler);
_pathSegmentResponseFixture = new PathSegmentResponseFixture();
_getPathParentRequestFixture = new GetPathParentRequestFixture();
@@ -50,7 +50,7 @@ public class GetPathParentEndpointTests
CancellationToken cancellationToken = CancellationToken.None;
IEnumerable<PathSegmentResponse> expectedResponse = _pathSegmentResponseFixture.CreateMany();
_mockHandler.HandleAsync(Arg.Any<GetPathParentQuery>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(expectedResponse));
.Returns(Result.From(expectedResponse));
// Act
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
@@ -119,7 +119,7 @@ public class GetPathParentEndpointTests
GetPathParentRequest request = _getPathParentRequestFixture.Create(@"C:\Users\TestUser");
CancellationToken cancellationToken = CancellationToken.None;
_mockHandler.HandleAsync(Arg.Any<GetPathParentQuery>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(_pathSegmentResponseFixture.CreateMany().AsEnumerable()));
.Returns(Result.From(_pathSegmentResponseFixture.CreateMany().AsEnumerable()));
// Act
await _sut.ExecuteAsync(request, cancellationToken);
@@ -143,7 +143,7 @@ public class GetPathParentEndpointTests
operationStarted.SetResult(true);
await cancellationRequested.Task;
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
return ErrorOrFactory.From(_pathSegmentResponseFixture.CreateMany().AsEnumerable());
return Result.From(_pathSegmentResponseFixture.CreateMany().AsEnumerable());
}, callInfo.Arg<CancellationToken>()));
// Act
@@ -1,10 +1,10 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using Lumina.Application.Common.CQRS;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathRoot;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using Lumina.Domain.Common.Primitives;
using Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.GetPathRoot;
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.Fixtures;
using Microsoft.AspNetCore.Http;
@@ -24,7 +24,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.
[ExcludeFromCodeCoverage]
public class GetPathRootEndpointTests
{
private readonly IQueryHandler<GetPathRootQuery, ErrorOr<PathSegmentResponse>> _mockHandler;
private readonly IQueryHandler<GetPathRootQuery, Result<PathSegmentResponse>> _mockHandler;
private readonly GetPathRootEndpoint _sut;
private readonly PathSegmentResponseFixture _pathSegmentResponseFixture;
private readonly GetPathRootRequestFixture _getPathRootRequestFixture;
@@ -34,7 +34,7 @@ public class GetPathRootEndpointTests
/// </summary>
public GetPathRootEndpointTests()
{
_mockHandler = Substitute.For<IQueryHandler<GetPathRootQuery, ErrorOr<PathSegmentResponse>>>();
_mockHandler = Substitute.For<IQueryHandler<GetPathRootQuery, Result<PathSegmentResponse>>>();
_sut = Factory.Create<GetPathRootEndpoint>(_mockHandler);
_pathSegmentResponseFixture = new PathSegmentResponseFixture();
_getPathRootRequestFixture = new GetPathRootRequestFixture();
@@ -48,7 +48,7 @@ public class GetPathRootEndpointTests
CancellationToken cancellationToken = CancellationToken.None;
PathSegmentResponse expectedResponse = _pathSegmentResponseFixture.Create();
_mockHandler.HandleAsync(Arg.Any<GetPathRootQuery>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(expectedResponse));
.Returns(Result.From(expectedResponse));
// Act
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
@@ -117,7 +117,7 @@ public class GetPathRootEndpointTests
GetPathRootRequest request = _getPathRootRequestFixture.Create(@"C:\Users\TestUser");
CancellationToken cancellationToken = CancellationToken.None;
_mockHandler.HandleAsync(Arg.Any<GetPathRootQuery>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(_pathSegmentResponseFixture.Create()));
.Returns(Result.From(_pathSegmentResponseFixture.Create()));
// Act
await _sut.ExecuteAsync(request, cancellationToken);
@@ -141,7 +141,7 @@ public class GetPathRootEndpointTests
operationStarted.SetResult(true);
await cancellationRequested.Task;
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
return ErrorOrFactory.From(_pathSegmentResponseFixture.Create());
return Result.From(_pathSegmentResponseFixture.Create());
}, callInfo.Arg<CancellationToken>()));
// Act
@@ -1,9 +1,9 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Application.Common.CQRS;
using Lumina.Application.Core.FileSystemManagement.Paths.Commands.SplitPath;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using Lumina.Domain.Common.Primitives;
using Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.SplitPath;
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.Fixtures;
using Microsoft.AspNetCore.Http;
@@ -25,7 +25,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.
[ExcludeFromCodeCoverage]
public class SplitPathEndpointTests
{
private readonly ICommandHandler<SplitPathCommand, ErrorOr<IEnumerable<PathSegmentResponse>>> _mockHandler;
private readonly ICommandHandler<SplitPathCommand, Result<IEnumerable<PathSegmentResponse>>> _mockHandler;
private readonly SplitPathEndpoint _sut;
private readonly PathSegmentResponseFixture _pathSegmentResponseFixture;
private readonly SplitPathRequestFixture _splitPathRequestFixture;
@@ -35,7 +35,7 @@ public class SplitPathEndpointTests
/// </summary>
public SplitPathEndpointTests()
{
_mockHandler = Substitute.For<ICommandHandler<SplitPathCommand, ErrorOr<IEnumerable<PathSegmentResponse>>>>();
_mockHandler = Substitute.For<ICommandHandler<SplitPathCommand, Result<IEnumerable<PathSegmentResponse>>>>();
_sut = FastEndpoints.Factory.Create<SplitPathEndpoint>(_mockHandler);
_pathSegmentResponseFixture = new PathSegmentResponseFixture();
_splitPathRequestFixture = new SplitPathRequestFixture();
@@ -49,7 +49,7 @@ public class SplitPathEndpointTests
CancellationToken cancellationToken = CancellationToken.None;
IEnumerable<PathSegmentResponse> expectedResponse = _pathSegmentResponseFixture.CreateMany();
_mockHandler.HandleAsync(Arg.Any<SplitPathCommand>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(expectedResponse));
.Returns(Result.From(expectedResponse));
// Act
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
@@ -93,7 +93,7 @@ public class SplitPathEndpointTests
SplitPathRequest request = _splitPathRequestFixture.Create(@"C:\Users\TestUser\Documents");
CancellationToken cancellationToken = CancellationToken.None;
_mockHandler.HandleAsync(Arg.Any<SplitPathCommand>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(_pathSegmentResponseFixture.CreateMany().AsEnumerable()));
.Returns(Result.From(_pathSegmentResponseFixture.CreateMany().AsEnumerable()));
// Act
await _sut.ExecuteAsync(request, cancellationToken);
@@ -119,7 +119,7 @@ public class SplitPathEndpointTests
operationStarted.SetResult(true);
await cancellationRequested.Task;
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
return ErrorOrFactory.From(new List<PathSegmentResponse>
return Result.From(new List<PathSegmentResponse>
{
_pathSegmentResponseFixture.Create()
}.AsEnumerable());
@@ -1,15 +1,14 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using Lumina.Application.Common.CQRS;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.ValidatePath;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using Lumina.Domain.Common.Primitives;
using Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.ValidatePath;
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.Fixtures;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using NSubstitute;
using System;
using System.Diagnostics.CodeAnalysis;
@@ -25,7 +24,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.
[ExcludeFromCodeCoverage]
public class ValidatePathEndpointTests
{
private readonly IQueryHandler<ValidatePathQuery, ErrorOr<PathValidResponse>> _mockHandler;
private readonly IQueryHandler<ValidatePathQuery, Result<PathValidResponse>> _mockHandler;
private readonly ValidatePathEndpoint _sut;
private readonly ValidatePathRequestFixture _validatePathRequestFixture;
@@ -34,7 +33,7 @@ public class ValidatePathEndpointTests
/// </summary>
public ValidatePathEndpointTests()
{
_mockHandler = Substitute.For<IQueryHandler<ValidatePathQuery, ErrorOr<PathValidResponse>>>();
_mockHandler = Substitute.For<IQueryHandler<ValidatePathQuery, Result<PathValidResponse>>>();
_sut = Factory.Create<ValidatePathEndpoint>(_mockHandler);
_validatePathRequestFixture = new ValidatePathRequestFixture();
}
@@ -116,7 +115,7 @@ public class ValidatePathEndpointTests
operationStarted.SetResult(true);
await cancellationRequested.Task;
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
return ErrorOrFactory.From(new PathValidResponse(true));
return Result.From(new PathValidResponse(true));
}, callInfo.Arg<CancellationToken>()));
// Act
@@ -1,10 +1,10 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using Lumina.Application.Common.CQRS;
using Lumina.Application.Core.FileSystemManagement.Thumbnails.Queries.GetThumbnail;
using Lumina.Contracts.Requests.FileSystemManagement.Thumbnails;
using Lumina.Contracts.Responses.FileSystemManagement.Thumbnails;
using Lumina.Domain.Common.Primitives;
using Lumina.Presentation.Api.Common.Utilities;
using Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Thumbnails.GetThumbnail;
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.Fixtures;
@@ -25,7 +25,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.FileSystemManagement.
[ExcludeFromCodeCoverage]
public class GetThumbnailEndpointTests
{
private readonly IQueryHandler<GetThumbnailQuery, ErrorOr<ThumbnailResponse>> _mockHandler;
private readonly IQueryHandler<GetThumbnailQuery, Result<ThumbnailResponse>> _mockHandler;
private readonly GetThumbnailEndpoint _sut;
private readonly GetThumbnailRequestFixture _getThumbnailRequestFixture;
@@ -34,7 +34,7 @@ public class GetThumbnailEndpointTests
/// </summary>
public GetThumbnailEndpointTests()
{
_mockHandler = Substitute.For<IQueryHandler<GetThumbnailQuery, ErrorOr<ThumbnailResponse>>>();
_mockHandler = Substitute.For<IQueryHandler<GetThumbnailQuery, Result<ThumbnailResponse>>>();
_sut = Factory.Create<GetThumbnailEndpoint>(_mockHandler);
_getThumbnailRequestFixture = new GetThumbnailRequestFixture();
}
@@ -47,7 +47,7 @@ public class GetThumbnailEndpointTests
CancellationToken cancellationToken = CancellationToken.None;
ThumbnailResponse expectedResponse = ThumbnailResponseFixture.CreateThumbnailResponse();
_mockHandler.HandleAsync(Arg.Any<GetThumbnailQuery>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(expectedResponse));
.Returns(Result.From(expectedResponse));
// Act
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
@@ -117,7 +117,7 @@ public class GetThumbnailEndpointTests
GetThumbnailRequest request = _getThumbnailRequestFixture.Create("/path/to/file.jpg", 80);
CancellationToken cancellationToken = CancellationToken.None;
_mockHandler.HandleAsync(Arg.Any<GetThumbnailQuery>(), Arg.Any<CancellationToken>())
.Returns(ErrorOrFactory.From(ThumbnailResponseFixture.CreateThumbnailResponse()));
.Returns(Result.From(ThumbnailResponseFixture.CreateThumbnailResponse()));
// Act
await _sut.ExecuteAsync(request, cancellationToken);
@@ -141,7 +141,7 @@ public class GetThumbnailEndpointTests
operationStarted.SetResult(true);
await cancellationRequested.Task;
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
return ErrorOrFactory.From(ThumbnailResponseFixture.CreateThumbnailResponse());
return Result.From(ThumbnailResponseFixture.CreateThumbnailResponse());
}, callInfo.Arg<CancellationToken>()));
// Act