mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16:11:10 +00:00
Replaces ErrorOr library with a custom implementation.
This commit is contained in:
1 parent
8fe90a4dde
commit
3b772d68ca
436 files changed
+4234
-3922
No files matched your search
+6
-6
@@ -1,9 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.Admin.Authorization.Permissions.Queries.GetPermissions;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Permissions.GetPermissions;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -25,7 +25,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.Admin.Authorization.P
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetPermissionsEndpointTests
|
||||
{
|
||||
private readonly IQueryHandler<GetPermissionsQuery, ErrorOr<IEnumerable<PermissionResponse>>> _mockHandler;
|
||||
private readonly IQueryHandler<GetPermissionsQuery, Result<IEnumerable<PermissionResponse>>> _mockHandler;
|
||||
private readonly GetPermissionsEndpoint _sut;
|
||||
|
||||
/// <summary>
|
||||
@@ -33,7 +33,7 @@ public class GetPermissionsEndpointTests
|
||||
/// </summary>
|
||||
public GetPermissionsEndpointTests()
|
||||
{
|
||||
_mockHandler = Substitute.For<IQueryHandler<GetPermissionsQuery, ErrorOr<IEnumerable<PermissionResponse>>>>();
|
||||
_mockHandler = Substitute.For<IQueryHandler<GetPermissionsQuery, Result<IEnumerable<PermissionResponse>>>>();
|
||||
_sut = Factory.Create<GetPermissionsEndpoint>(_mockHandler);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class GetPermissionsEndpointTests
|
||||
new(Guid.NewGuid(), AuthorizationPermission.CanRegisterUsers)
|
||||
];
|
||||
_mockHandler.HandleAsync(Arg.Any<GetPermissionsQuery>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(expectedResponse));
|
||||
.Returns(Result.From(expectedResponse));
|
||||
|
||||
// Act
|
||||
IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
|
||||
@@ -91,7 +91,7 @@ public class GetPermissionsEndpointTests
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
IEnumerable<PermissionResponse> response = [];
|
||||
_mockHandler.HandleAsync(Arg.Any<GetPermissionsQuery>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(response));
|
||||
.Returns(Result.From(response));
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
|
||||
@@ -116,7 +116,7 @@ public class GetPermissionsEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
info.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return ErrorOrFactory.From(Enumerable.Empty<PermissionResponse>());
|
||||
return Result.From(Enumerable.Empty<PermissionResponse>());
|
||||
}, info.Arg<CancellationToken>()));
|
||||
|
||||
// Act
|
||||
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.Admin.Authorization.Roles.Commands.AddRole;
|
||||
using Lumina.Contracts.DTO.Authentication;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Roles.AddRole;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
@@ -24,7 +24,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.Admin.Authorization.R
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddRoleEndpointTests
|
||||
{
|
||||
private readonly ICommandHandler<AddRoleCommand, ErrorOr<RolePermissionsResponse>> _mockHandler;
|
||||
private readonly ICommandHandler<AddRoleCommand, Result<RolePermissionsResponse>> _mockHandler;
|
||||
private readonly AddRoleEndpoint _sut;
|
||||
|
||||
/// <summary>
|
||||
@@ -32,7 +32,7 @@ public class AddRoleEndpointTests
|
||||
/// </summary>
|
||||
public AddRoleEndpointTests()
|
||||
{
|
||||
_mockHandler = Substitute.For<ICommandHandler<AddRoleCommand, ErrorOr<RolePermissionsResponse>>>();
|
||||
_mockHandler = Substitute.For<ICommandHandler<AddRoleCommand, Result<RolePermissionsResponse>>>();
|
||||
_sut = FastEndpoints.Factory.Create<AddRoleEndpoint>(_mockHandler);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class AddRoleEndpointTests
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
RolePermissionsResponse expectedResponse = new(new RoleDto(Guid.NewGuid(), "Admin"), []);
|
||||
_mockHandler.HandleAsync(Arg.Any<AddRoleCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(expectedResponse));
|
||||
.Returns(Result.From(expectedResponse));
|
||||
|
||||
// Act
|
||||
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -87,7 +87,7 @@ public class AddRoleEndpointTests
|
||||
AddRoleRequest request = new("Admin", [Guid.NewGuid()]);
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<AddRoleCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(new RolePermissionsResponse(new RoleDto(Guid.NewGuid(), "Admin"), [])));
|
||||
.Returns(Result.From(new RolePermissionsResponse(new RoleDto(Guid.NewGuid(), "Admin"), [])));
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -114,7 +114,7 @@ public class AddRoleEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
info.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return ErrorOrFactory.From(new RolePermissionsResponse(new RoleDto(Guid.NewGuid(), "Admin"), []));
|
||||
return Result.From(new RolePermissionsResponse(new RoleDto(Guid.NewGuid(), "Admin"), []));
|
||||
}, info.Arg<CancellationToken>()));
|
||||
|
||||
// Act
|
||||
|
||||
+6
-6
@@ -1,8 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.Admin.Authorization.Roles.Commands.DeleteRole;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Roles.DeleteRole;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
@@ -21,7 +21,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.Admin.Authorization.R
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeleteRoleEndpointTests
|
||||
{
|
||||
private readonly ICommandHandler<DeleteRoleCommand, ErrorOr<Deleted>> _mockHandler;
|
||||
private readonly ICommandHandler<DeleteRoleCommand, Result<Deleted>> _mockHandler;
|
||||
private readonly DeleteRoleEndpoint _sut;
|
||||
|
||||
/// <summary>
|
||||
@@ -29,7 +29,7 @@ public class DeleteRoleEndpointTests
|
||||
/// </summary>
|
||||
public DeleteRoleEndpointTests()
|
||||
{
|
||||
_mockHandler = Substitute.For<ICommandHandler<DeleteRoleCommand, ErrorOr<Deleted>>>();
|
||||
_mockHandler = Substitute.For<ICommandHandler<DeleteRoleCommand, Result<Deleted>>>();
|
||||
_sut = FastEndpoints.Factory.Create<DeleteRoleEndpoint>(_mockHandler);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class DeleteRoleEndpointTests
|
||||
DeleteRoleRequest request = new(Guid.NewGuid());
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<DeleteRoleCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(Result.Deleted));
|
||||
.Returns(Result.From(Result.Deleted));
|
||||
|
||||
// Act
|
||||
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -83,7 +83,7 @@ public class DeleteRoleEndpointTests
|
||||
DeleteRoleRequest request = new(roleId);
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<DeleteRoleCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(Result.Deleted));
|
||||
.Returns(Result.From(Result.Deleted));
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -108,7 +108,7 @@ public class DeleteRoleEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
info.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return ErrorOrFactory.From(Result.Deleted);
|
||||
return Result.From(Result.Deleted);
|
||||
}, info.Arg<CancellationToken>()));
|
||||
|
||||
// Act
|
||||
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.Admin.Authorization.Roles.Queries.GetRolePermissions;
|
||||
using Lumina.Contracts.DTO.Authentication;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Roles.GetRolePermissions;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -24,7 +24,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.Admin.Authorization.R
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetRolePermissionsEndpointTests
|
||||
{
|
||||
private readonly IQueryHandler<GetRolePermissionsQuery, ErrorOr<RolePermissionsResponse>> _mockHandler;
|
||||
private readonly IQueryHandler<GetRolePermissionsQuery, Result<RolePermissionsResponse>> _mockHandler;
|
||||
private readonly GetRolePermissionsEndpoint _sut;
|
||||
|
||||
/// <summary>
|
||||
@@ -32,7 +32,7 @@ public class GetRolePermissionsEndpointTests
|
||||
/// </summary>
|
||||
public GetRolePermissionsEndpointTests()
|
||||
{
|
||||
_mockHandler = Substitute.For<IQueryHandler<GetRolePermissionsQuery, ErrorOr<RolePermissionsResponse>>>();
|
||||
_mockHandler = Substitute.For<IQueryHandler<GetRolePermissionsQuery, Result<RolePermissionsResponse>>>();
|
||||
_sut = FastEndpoints.Factory.Create<GetRolePermissionsEndpoint>(_mockHandler);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class GetRolePermissionsEndpointTests
|
||||
[new PermissionDto(Guid.NewGuid(), AuthorizationPermission.CanViewUsers)]
|
||||
);
|
||||
_mockHandler.HandleAsync(Arg.Any<GetRolePermissionsQuery>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(expectedResponse));
|
||||
.Returns(Result.From(expectedResponse));
|
||||
|
||||
// Act
|
||||
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -91,7 +91,7 @@ public class GetRolePermissionsEndpointTests
|
||||
GetRolePermissionsRequest request = new(roleId);
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<GetRolePermissionsQuery>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(new RolePermissionsResponse(
|
||||
.Returns(Result.From(new RolePermissionsResponse(
|
||||
new RoleDto(Guid.NewGuid(), "Admin"),
|
||||
[]
|
||||
)));
|
||||
@@ -119,7 +119,7 @@ public class GetRolePermissionsEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
info.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return ErrorOrFactory.From(new RolePermissionsResponse(
|
||||
return Result.From(new RolePermissionsResponse(
|
||||
new RoleDto(Guid.NewGuid(), "Admin"),
|
||||
[]
|
||||
));
|
||||
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.Admin.Authorization.Roles.Queries.GetRoles;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Roles.GetRoles;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
@@ -23,7 +23,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.Admin.Authorization.R
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetRolesEndpointTests
|
||||
{
|
||||
private readonly IQueryHandler<GetRolesQuery, ErrorOr<IEnumerable<RoleResponse>>> _mockHandler;
|
||||
private readonly IQueryHandler<GetRolesQuery, Result<IEnumerable<RoleResponse>>> _mockHandler;
|
||||
private readonly GetRolesEndpoint _sut;
|
||||
|
||||
/// <summary>
|
||||
@@ -31,7 +31,7 @@ public class GetRolesEndpointTests
|
||||
/// </summary>
|
||||
public GetRolesEndpointTests()
|
||||
{
|
||||
_mockHandler = Substitute.For<IQueryHandler<GetRolesQuery, ErrorOr<IEnumerable<RoleResponse>>>>();
|
||||
_mockHandler = Substitute.For<IQueryHandler<GetRolesQuery, Result<IEnumerable<RoleResponse>>>>();
|
||||
_sut = Factory.Create<GetRolesEndpoint>(_mockHandler);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class GetRolesEndpointTests
|
||||
new RoleResponse(Guid.NewGuid(), "Admin")
|
||||
];
|
||||
_mockHandler.HandleAsync(Arg.Any<GetRolesQuery>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(expectedResponse));
|
||||
.Returns(Result.From(expectedResponse));
|
||||
|
||||
// Act
|
||||
IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
|
||||
@@ -86,7 +86,7 @@ public class GetRolesEndpointTests
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<GetRolesQuery>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(new List<RoleResponse>
|
||||
.Returns(Result.From(new List<RoleResponse>
|
||||
{
|
||||
new(Guid.NewGuid(), "Admin")
|
||||
} as IEnumerable<RoleResponse>));
|
||||
@@ -114,7 +114,7 @@ public class GetRolesEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
info.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return ErrorOrFactory.From(new List<RoleResponse>() as IEnumerable<RoleResponse>);
|
||||
return Result.From(new List<RoleResponse>() as IEnumerable<RoleResponse>);
|
||||
}, info.Arg<CancellationToken>()));
|
||||
|
||||
// Act
|
||||
|
||||
+6
-7
@@ -1,17 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.Admin.Authorization.Roles.Commands.UpdateRole;
|
||||
using Lumina.Contracts.DTO.Authentication;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Roles.UpdateRole;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@@ -26,7 +25,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.Admin.Authorization.R
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdateRoleEndpointTests
|
||||
{
|
||||
private readonly ICommandHandler<UpdateRoleCommand, ErrorOr<RolePermissionsResponse>> _mockHandler;
|
||||
private readonly ICommandHandler<UpdateRoleCommand, Result<RolePermissionsResponse>> _mockHandler;
|
||||
private readonly UpdateRoleEndpoint _sut;
|
||||
|
||||
/// <summary>
|
||||
@@ -34,7 +33,7 @@ public class UpdateRoleEndpointTests
|
||||
/// </summary>
|
||||
public UpdateRoleEndpointTests()
|
||||
{
|
||||
_mockHandler = Substitute.For<ICommandHandler<UpdateRoleCommand, ErrorOr<RolePermissionsResponse>>>();
|
||||
_mockHandler = Substitute.For<ICommandHandler<UpdateRoleCommand, Result<RolePermissionsResponse>>>();
|
||||
_sut = FastEndpoints.Factory.Create<UpdateRoleEndpoint>(_mockHandler);
|
||||
}
|
||||
|
||||
@@ -49,7 +48,7 @@ public class UpdateRoleEndpointTests
|
||||
[new PermissionDto(Guid.NewGuid(), AuthorizationPermission.CanViewUsers)]
|
||||
);
|
||||
_mockHandler.HandleAsync(Arg.Any<UpdateRoleCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(expectedResponse));
|
||||
.Returns(Result.From(expectedResponse));
|
||||
|
||||
// Act
|
||||
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -92,7 +91,7 @@ public class UpdateRoleEndpointTests
|
||||
UpdateRoleRequest request = new(Guid.NewGuid(), "UpdatedAdmin", [Guid.NewGuid()]);
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<UpdateRoleCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(new RolePermissionsResponse(
|
||||
.Returns(Result.From(new RolePermissionsResponse(
|
||||
new RoleDto(Guid.NewGuid(), "UpdatedAdmin"),
|
||||
[]
|
||||
)));
|
||||
@@ -123,7 +122,7 @@ public class UpdateRoleEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
info.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return ErrorOrFactory.From(new RolePermissionsResponse(
|
||||
return Result.From(new RolePermissionsResponse(
|
||||
new RoleDto(Guid.NewGuid(), "UpdatedAdmin"),
|
||||
[]
|
||||
));
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Primitives;
|
||||
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.Common.Fixtures;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
+7
-7
@@ -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
|
||||
|
||||
+6
-6
@@ -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
|
||||
|
||||
+7
-9
@@ -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
|
||||
|
||||
+6
-6
@@ -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
|
||||
|
||||
+4
-4
@@ -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
|
||||
|
||||
+6
-6
@@ -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
|
||||
|
||||
+6
-6
@@ -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
|
||||
|
||||
+6
-6
@@ -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
|
||||
|
||||
+6
-6
@@ -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());
|
||||
|
||||
+4
-5
@@ -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
|
||||
|
||||
+6
-6
@@ -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
|
||||
|
||||
+6
-8
@@ -1,11 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
|
||||
using Lumina.Application.Core.Maintenance.ApplicationSetup.Queries.CheckInitialization;
|
||||
using Lumina.Contracts.Requests.Authentication;
|
||||
using Lumina.Contracts.Responses.Authentication;
|
||||
using Lumina.Contracts.Responses.UsersManagement;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Maintenance.ApplicationSetup;
|
||||
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.Maintenance.ApplicationSetup.Fixtures;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -25,7 +23,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.Maintenance.Applicati
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SetupApplicationEndpointTests
|
||||
{
|
||||
private readonly ICommandHandler<SetupApplicationCommand, ErrorOr<RegistrationResponse>> _mockHandler;
|
||||
private readonly ICommandHandler<SetupApplicationCommand, Result<RegistrationResponse>> _mockHandler;
|
||||
private readonly SetupApplicationEndpoint _sut;
|
||||
private readonly RegistrationRequestFixture _registrationRequestFixture;
|
||||
|
||||
@@ -34,7 +32,7 @@ public class SetupApplicationEndpointTests
|
||||
/// </summary>
|
||||
public SetupApplicationEndpointTests()
|
||||
{
|
||||
_mockHandler = Substitute.For<ICommandHandler<SetupApplicationCommand, ErrorOr<RegistrationResponse>>>();
|
||||
_mockHandler = Substitute.For<ICommandHandler<SetupApplicationCommand, Result<RegistrationResponse>>>();
|
||||
_sut = FastEndpoints.Factory.Create<SetupApplicationEndpoint>(_mockHandler);
|
||||
_registrationRequestFixture = new RegistrationRequestFixture();
|
||||
}
|
||||
@@ -47,7 +45,7 @@ public class SetupApplicationEndpointTests
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
RegistrationResponse expectedResponse = new(Guid.NewGuid(), "testUser", "TOTP123");
|
||||
_mockHandler.HandleAsync(Arg.Any<SetupApplicationCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(expectedResponse));
|
||||
.Returns(Result.From(expectedResponse));
|
||||
|
||||
// Act
|
||||
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -91,7 +89,7 @@ public class SetupApplicationEndpointTests
|
||||
RegistrationRequest request = _registrationRequestFixture.Create();
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<SetupApplicationCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(new RegistrationResponse(Guid.NewGuid(), "testUser", "TOTP123")));
|
||||
.Returns(Result.From(new RegistrationResponse(Guid.NewGuid(), "testUser", "TOTP123")));
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -121,7 +119,7 @@ public class SetupApplicationEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return ErrorOrFactory.From(new RegistrationResponse(Guid.NewGuid(), "testUser", "TOTP123"));
|
||||
return Result.From(new RegistrationResponse(Guid.NewGuid(), "testUser", "TOTP123"));
|
||||
}, callInfo.Arg<CancellationToken>()));
|
||||
|
||||
// Act
|
||||
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.UsersManagement.Authentication.Commands.ChangePassword;
|
||||
using Lumina.Contracts.Requests.Authentication;
|
||||
using Lumina.Contracts.Responses.Authentication;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.ChangePassword;
|
||||
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.UsersManagement.Authentication.ChangePassword.Fixtures;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -23,7 +23,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.UsersManagement.Authe
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ChangePasswordEndpointTests
|
||||
{
|
||||
private readonly ICommandHandler<ChangePasswordCommand, ErrorOr<ChangePasswordResponse>> _mockHandler;
|
||||
private readonly ICommandHandler<ChangePasswordCommand, Result<ChangePasswordResponse>> _mockHandler;
|
||||
private readonly ChangePasswordEndpoint _sut;
|
||||
private readonly ChangePasswordRequestFixture _changePasswordRequestFixture;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ChangePasswordEndpointTests
|
||||
/// </summary>
|
||||
public ChangePasswordEndpointTests()
|
||||
{
|
||||
_mockHandler = Substitute.For<ICommandHandler<ChangePasswordCommand, ErrorOr<ChangePasswordResponse>>>();
|
||||
_mockHandler = Substitute.For<ICommandHandler<ChangePasswordCommand, Result<ChangePasswordResponse>>>();
|
||||
_sut = FastEndpoints.Factory.Create<ChangePasswordEndpoint>(_mockHandler);
|
||||
_changePasswordRequestFixture = new ChangePasswordRequestFixture();
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class ChangePasswordEndpointTests
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
ChangePasswordResponse expectedResponse = new(IsPasswordChanged: true);
|
||||
_mockHandler.HandleAsync(Arg.Any<ChangePasswordCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(expectedResponse));
|
||||
.Returns(Result.From(expectedResponse));
|
||||
|
||||
// Act
|
||||
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -87,7 +87,7 @@ public class ChangePasswordEndpointTests
|
||||
ChangePasswordRequest request = _changePasswordRequestFixture.Create();
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<ChangePasswordCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(new ChangePasswordResponse(true)));
|
||||
.Returns(Result.From(new ChangePasswordResponse(true)));
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -117,7 +117,7 @@ public class ChangePasswordEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return ErrorOrFactory.From(new ChangePasswordResponse(true));
|
||||
return Result.From(new ChangePasswordResponse(true));
|
||||
}, callInfo.Arg<CancellationToken>()));
|
||||
|
||||
// Act
|
||||
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.UsersManagement.Authentication.Queries.GetUsers;
|
||||
using Lumina.Contracts.Responses.UsersManagement.Users;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.GetUsers;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
@@ -23,14 +23,14 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.UsersManagement.Authe
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetUsersEndpointTests
|
||||
{
|
||||
private readonly IQueryHandler<GetUsersQuery, ErrorOr<IEnumerable<UserResponse>>> _mockHandler;
|
||||
private readonly IQueryHandler<GetUsersQuery, Result<IEnumerable<UserResponse>>> _mockHandler;
|
||||
private readonly GetUsersEndpoint _sut;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetUsersEndpointTests"/> class.
|
||||
/// </summary>
|
||||
public GetUsersEndpointTests()
|
||||
{
|
||||
_mockHandler = Substitute.For<IQueryHandler<GetUsersQuery, ErrorOr<IEnumerable<UserResponse>>>>();
|
||||
_mockHandler = Substitute.For<IQueryHandler<GetUsersQuery, Result<IEnumerable<UserResponse>>>>();
|
||||
_sut = Factory.Create<GetUsersEndpoint>(_mockHandler);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class GetUsersEndpointTests
|
||||
new UserResponse(Guid.NewGuid(), "testUser", DateTime.UtcNow, null)
|
||||
];
|
||||
_mockHandler.HandleAsync(Arg.Any<GetUsersQuery>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(expectedResponse));
|
||||
.Returns(Result.From(expectedResponse));
|
||||
|
||||
// Act
|
||||
IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
|
||||
@@ -85,7 +85,7 @@ public class GetUsersEndpointTests
|
||||
// Arrange
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<GetUsersQuery>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(Array.Empty<UserResponse>() as IEnumerable<UserResponse>));
|
||||
.Returns(Result.From(Array.Empty<UserResponse>() as IEnumerable<UserResponse>));
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
|
||||
@@ -110,7 +110,7 @@ public class GetUsersEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
info.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return ErrorOrFactory.From(Array.Empty<UserResponse>() as IEnumerable<UserResponse>);
|
||||
return Result.From(Array.Empty<UserResponse>() as IEnumerable<UserResponse>);
|
||||
}, info.Arg<CancellationToken>()));
|
||||
|
||||
// Act
|
||||
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.UsersManagement.Authentication.Queries.LoginUser;
|
||||
using Lumina.Contracts.Requests.Authentication;
|
||||
using Lumina.Contracts.Responses.Authentication;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.Login;
|
||||
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.UsersManagement.Authentication.Login.Fixtures;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -24,7 +24,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.UsersManagement.Authe
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LoginEndpointTests
|
||||
{
|
||||
private readonly IQueryHandler<LoginUserQuery, ErrorOr<LoginResponse>> _mockHandler;
|
||||
private readonly IQueryHandler<LoginUserQuery, Result<LoginResponse>> _mockHandler;
|
||||
private readonly LoginEndpoint _sut;
|
||||
private readonly LoginRequestFixture _loginRequestFixture;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class LoginEndpointTests
|
||||
/// </summary>
|
||||
public LoginEndpointTests()
|
||||
{
|
||||
_mockHandler = Substitute.For<IQueryHandler<LoginUserQuery, ErrorOr<LoginResponse>>>();
|
||||
_mockHandler = Substitute.For<IQueryHandler<LoginUserQuery, Result<LoginResponse>>>();
|
||||
_sut = Factory.Create<LoginEndpoint>(_mockHandler);
|
||||
_loginRequestFixture = new LoginRequestFixture();
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class LoginEndpointTests
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
LoginResponse expectedResponse = new(Guid.NewGuid(), "testUser", "jwt_token", true);
|
||||
_mockHandler.HandleAsync(Arg.Any<LoginUserQuery>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(expectedResponse));
|
||||
.Returns(Result.From(expectedResponse));
|
||||
|
||||
// Act
|
||||
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -88,7 +88,7 @@ public class LoginEndpointTests
|
||||
LoginRequest request = _loginRequestFixture.Create();
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<LoginUserQuery>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(new LoginResponse(Guid.NewGuid(), "testUser", "jwt_token", true)));
|
||||
.Returns(Result.From(new LoginResponse(Guid.NewGuid(), "testUser", "jwt_token", true)));
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -117,7 +117,7 @@ public class LoginEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return ErrorOrFactory.From(new LoginResponse(Guid.NewGuid(), "testUser", "jwt_token", true));
|
||||
return Result.From(new LoginResponse(Guid.NewGuid(), "testUser", "jwt_token", true));
|
||||
}, callInfo.Arg<CancellationToken>()));
|
||||
|
||||
// Act
|
||||
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.UsersManagement.Authentication.Commands.RecoverPassword;
|
||||
using Lumina.Contracts.Requests.Authentication;
|
||||
using Lumina.Contracts.Responses.Authentication;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.RecoverPassword;
|
||||
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.UsersManagement.Authentication.RecoverPassword.Fixtures;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -23,7 +23,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.UsersManagement.Authe
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RecoverPasswordEndpointTests
|
||||
{
|
||||
private readonly ICommandHandler<RecoverPasswordCommand, ErrorOr<RecoverPasswordResponse>> _mockHandler;
|
||||
private readonly ICommandHandler<RecoverPasswordCommand, Result<RecoverPasswordResponse>> _mockHandler;
|
||||
private readonly RecoverPasswordEndpoint _sut;
|
||||
private readonly RecoverPasswordRequestFixture _recoverPasswordRequestFixture;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class RecoverPasswordEndpointTests
|
||||
/// </summary>
|
||||
public RecoverPasswordEndpointTests()
|
||||
{
|
||||
_mockHandler = Substitute.For<ICommandHandler<RecoverPasswordCommand, ErrorOr<RecoverPasswordResponse>>>();
|
||||
_mockHandler = Substitute.For<ICommandHandler<RecoverPasswordCommand, Result<RecoverPasswordResponse>>>();
|
||||
_sut = FastEndpoints.Factory.Create<RecoverPasswordEndpoint>(_mockHandler);
|
||||
_recoverPasswordRequestFixture = new RecoverPasswordRequestFixture();
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class RecoverPasswordEndpointTests
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
RecoverPasswordResponse expectedResponse = new(IsPasswordReset: true);
|
||||
_mockHandler.HandleAsync(Arg.Any<RecoverPasswordCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(expectedResponse));
|
||||
.Returns(Result.From(expectedResponse));
|
||||
|
||||
// Act
|
||||
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -87,7 +87,7 @@ public class RecoverPasswordEndpointTests
|
||||
RecoverPasswordRequest request = _recoverPasswordRequestFixture.Create();
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<RecoverPasswordCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(new RecoverPasswordResponse(true)));
|
||||
.Returns(Result.From(new RecoverPasswordResponse(true)));
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -115,7 +115,7 @@ public class RecoverPasswordEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return ErrorOrFactory.From(new RecoverPasswordResponse(true));
|
||||
return Result.From(new RecoverPasswordResponse(true));
|
||||
}, callInfo.Arg<CancellationToken>()));
|
||||
|
||||
// Act
|
||||
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.UsersManagement.Authentication.Commands.RegisterUser;
|
||||
using Lumina.Contracts.Requests.Authentication;
|
||||
using Lumina.Contracts.Responses.Authentication;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.Register;
|
||||
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.Maintenance.ApplicationSetup.Fixtures;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -23,7 +23,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.UsersManagement.Authe
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RegisterEndpointTests
|
||||
{
|
||||
private readonly ICommandHandler<RegisterUserCommand, ErrorOr<RegistrationResponse>> _mockHandler;
|
||||
private readonly ICommandHandler<RegisterUserCommand, Result<RegistrationResponse>> _mockHandler;
|
||||
private readonly RegisterEndpoint _sut;
|
||||
private readonly RegistrationRequestFixture _registrationRequestFixture;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class RegisterEndpointTests
|
||||
/// </summary>
|
||||
public RegisterEndpointTests()
|
||||
{
|
||||
_mockHandler = Substitute.For<ICommandHandler<RegisterUserCommand, ErrorOr<RegistrationResponse>>>();
|
||||
_mockHandler = Substitute.For<ICommandHandler<RegisterUserCommand, Result<RegistrationResponse>>>();
|
||||
_sut = FastEndpoints.Factory.Create<RegisterEndpoint>(_mockHandler);
|
||||
_registrationRequestFixture = new RegistrationRequestFixture();
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class RegisterEndpointTests
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
RegistrationResponse expectedResponse = new(Guid.NewGuid(), "testUser", "TOTP123");
|
||||
_mockHandler.HandleAsync(Arg.Any<RegisterUserCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(expectedResponse));
|
||||
.Returns(Result.From(expectedResponse));
|
||||
|
||||
// Act
|
||||
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -88,7 +88,7 @@ public class RegisterEndpointTests
|
||||
RegistrationRequest request = _registrationRequestFixture.Create();
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<RegisterUserCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(new RegistrationResponse(Guid.NewGuid(), "testUser", "TOTP123")));
|
||||
.Returns(Result.From(new RegistrationResponse(Guid.NewGuid(), "testUser", "TOTP123")));
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -118,7 +118,7 @@ public class RegisterEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return ErrorOrFactory.From(new RegistrationResponse(Guid.NewGuid(), "testUser", "TOTP123"));
|
||||
return Result.From(new RegistrationResponse(Guid.NewGuid(), "testUser", "TOTP123"));
|
||||
}, callInfo.Arg<CancellationToken>()));
|
||||
|
||||
// Act
|
||||
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.UsersManagement.Authorization.Queries.GetAuthorization;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authorization.GetAuthorization;
|
||||
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.UsersManagement.Authorization.GetAuthorization.Fixtures;
|
||||
@@ -27,7 +27,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.UsersManagement.Autho
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetAuthorizationEndpointTests
|
||||
{
|
||||
private readonly IQueryHandler<GetAuthorizationQuery, ErrorOr<AuthorizationResponse>> _mockHandler;
|
||||
private readonly IQueryHandler<GetAuthorizationQuery, Result<AuthorizationResponse>> _mockHandler;
|
||||
private readonly GetAuthorizationEndpoint _sut;
|
||||
|
||||
/// <summary>
|
||||
@@ -35,7 +35,7 @@ public class GetAuthorizationEndpointTests
|
||||
/// </summary>
|
||||
public GetAuthorizationEndpointTests()
|
||||
{
|
||||
_mockHandler = Substitute.For<IQueryHandler<GetAuthorizationQuery, ErrorOr<AuthorizationResponse>>>();
|
||||
_mockHandler = Substitute.For<IQueryHandler<GetAuthorizationQuery, Result<AuthorizationResponse>>>();
|
||||
_sut = Factory.Create<GetAuthorizationEndpoint>(_mockHandler);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class GetAuthorizationEndpointTests
|
||||
new HashSet<AuthorizationPermission> { AuthorizationPermission.CanViewUsers });
|
||||
|
||||
_mockHandler.HandleAsync(Arg.Any<GetAuthorizationQuery>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(expectedResponse));
|
||||
.Returns(Result.From(expectedResponse));
|
||||
|
||||
// Act
|
||||
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -96,7 +96,7 @@ public class GetAuthorizationEndpointTests
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
_mockHandler.HandleAsync(Arg.Any<GetAuthorizationQuery>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(new AuthorizationResponse(
|
||||
.Returns(Result.From(new AuthorizationResponse(
|
||||
request.UserId!.Value,
|
||||
string.Empty,
|
||||
new HashSet<AuthorizationPermission>().ToHashSet()
|
||||
@@ -127,7 +127,7 @@ public class GetAuthorizationEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return ErrorOrFactory.From(new AuthorizationResponse(
|
||||
return Result.From(new AuthorizationResponse(
|
||||
request.UserId!.Value,
|
||||
string.Empty,
|
||||
new HashSet<AuthorizationPermission>().ToHashSet()
|
||||
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.UsersManagement.Authorization.Queries.GetUserPermissions;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authorization.GetUserPermissions;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -25,7 +25,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.UsersManagement.Autho
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetUserPermissionsEndpointTests
|
||||
{
|
||||
private readonly IQueryHandler<GetUserPermissionsQuery, ErrorOr<IEnumerable<PermissionResponse>>> _mockHandler;
|
||||
private readonly IQueryHandler<GetUserPermissionsQuery, Result<IEnumerable<PermissionResponse>>> _mockHandler;
|
||||
private readonly GetUserPermissionsEndpoint _sut;
|
||||
|
||||
/// <summary>
|
||||
@@ -33,7 +33,7 @@ public class GetUserPermissionsEndpointTests
|
||||
/// </summary>
|
||||
public GetUserPermissionsEndpointTests()
|
||||
{
|
||||
_mockHandler = Substitute.For<IQueryHandler<GetUserPermissionsQuery, ErrorOr<IEnumerable<PermissionResponse>>>>();
|
||||
_mockHandler = Substitute.For<IQueryHandler<GetUserPermissionsQuery, Result<IEnumerable<PermissionResponse>>>>();
|
||||
_sut = Factory.Create<GetUserPermissionsEndpoint>(_mockHandler);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class GetUserPermissionsEndpointTests
|
||||
new PermissionResponse(Guid.NewGuid(), AuthorizationPermission.CanDeleteUsers)
|
||||
];
|
||||
_mockHandler.HandleAsync(Arg.Any<GetUserPermissionsQuery>(), 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 GetUserPermissionsEndpointTests
|
||||
GetUserPermissionsRequest request = new(userId);
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<GetUserPermissionsQuery>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(Array.Empty<PermissionResponse>() as IEnumerable<PermissionResponse>));
|
||||
.Returns(Result.From(Array.Empty<PermissionResponse>() as IEnumerable<PermissionResponse>));
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -118,7 +118,7 @@ public class GetUserPermissionsEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
info.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return ErrorOrFactory.From(Array.Empty<PermissionResponse>() as IEnumerable<PermissionResponse>);
|
||||
return Result.From(Array.Empty<PermissionResponse>() as IEnumerable<PermissionResponse>);
|
||||
}, info.Arg<CancellationToken>()));
|
||||
|
||||
// Act
|
||||
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.UsersManagement.Authorization.Queries.GetUserRole;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authorization.GetUserRole;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
@@ -23,7 +23,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.UsersManagement.Autho
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetUserRoleEndpointTests
|
||||
{
|
||||
private readonly IQueryHandler<GetUserRoleQuery, ErrorOr<RoleResponse?>> _mockHandler;
|
||||
private readonly IQueryHandler<GetUserRoleQuery, Result<RoleResponse?>> _mockHandler;
|
||||
private readonly GetUserRoleEndpoint _sut;
|
||||
|
||||
/// <summary>
|
||||
@@ -31,7 +31,7 @@ public class GetUserRoleEndpointTests
|
||||
/// </summary>
|
||||
public GetUserRoleEndpointTests()
|
||||
{
|
||||
_mockHandler = Substitute.For<IQueryHandler<GetUserRoleQuery, ErrorOr<RoleResponse?>>>();
|
||||
_mockHandler = Substitute.For<IQueryHandler<GetUserRoleQuery, Result<RoleResponse?>>>();
|
||||
_sut = Factory.Create<GetUserRoleEndpoint>(_mockHandler);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class GetUserRoleEndpointTests
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
RoleResponse expectedResponse = new(Guid.NewGuid(), "Admin");
|
||||
_mockHandler.HandleAsync(Arg.Any<GetUserRoleQuery>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From<RoleResponse?>(expectedResponse));
|
||||
.Returns(Result.From<RoleResponse?>(expectedResponse));
|
||||
|
||||
// Act
|
||||
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -87,7 +87,7 @@ public class GetUserRoleEndpointTests
|
||||
GetUserRoleRequest request = new(userId);
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<GetUserRoleQuery>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From<RoleResponse?>(new RoleResponse(Guid.NewGuid(), "Admin")));
|
||||
.Returns(Result.From<RoleResponse?>(new RoleResponse(Guid.NewGuid(), "Admin")));
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -112,7 +112,7 @@ public class GetUserRoleEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
info.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return ErrorOrFactory.From<RoleResponse?>(new RoleResponse(Guid.NewGuid(), "Admin"));
|
||||
return Result.From<RoleResponse?>(new RoleResponse(Guid.NewGuid(), "Admin"));
|
||||
}, info.Arg<CancellationToken>()));
|
||||
|
||||
// Act
|
||||
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.UsersManagement.Authorization.Commands.UpdateUserRoleAndPermissions;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authorization.UpdateUserRoleAndPermissions;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -25,7 +25,7 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.UsersManagement.Autho
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdateUserRoleAndPermissionsEndpointTests
|
||||
{
|
||||
private readonly ICommandHandler<UpdateUserRoleAndPermissionsCommand, ErrorOr<AuthorizationResponse>> _mockHandler;
|
||||
private readonly ICommandHandler<UpdateUserRoleAndPermissionsCommand, Result<AuthorizationResponse>> _mockHandler;
|
||||
private readonly UpdateUserRoleAndPermissionsEndpoint _sut;
|
||||
|
||||
/// <summary>
|
||||
@@ -33,7 +33,7 @@ public class UpdateUserRoleAndPermissionsEndpointTests
|
||||
/// </summary>
|
||||
public UpdateUserRoleAndPermissionsEndpointTests()
|
||||
{
|
||||
_mockHandler = Substitute.For<ICommandHandler<UpdateUserRoleAndPermissionsCommand, ErrorOr<AuthorizationResponse>>>();
|
||||
_mockHandler = Substitute.For<ICommandHandler<UpdateUserRoleAndPermissionsCommand, Result<AuthorizationResponse>>>();
|
||||
_sut = FastEndpoints.Factory.Create<UpdateUserRoleAndPermissionsEndpoint>(_mockHandler);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class UpdateUserRoleAndPermissionsEndpointTests
|
||||
new HashSet<AuthorizationPermission> { AuthorizationPermission.CanViewUsers }
|
||||
);
|
||||
_mockHandler.HandleAsync(Arg.Any<UpdateUserRoleAndPermissionsCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(expectedResponse));
|
||||
.Returns(Result.From(expectedResponse));
|
||||
|
||||
// Act
|
||||
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -104,7 +104,7 @@ public class UpdateUserRoleAndPermissionsEndpointTests
|
||||
);
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<UpdateUserRoleAndPermissionsCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ErrorOrFactory.From(new AuthorizationResponse(
|
||||
.Returns(Result.From(new AuthorizationResponse(
|
||||
Guid.NewGuid(),
|
||||
"Admin",
|
||||
new HashSet<AuthorizationPermission> { AuthorizationPermission.CanViewUsers }
|
||||
@@ -136,7 +136,7 @@ public class UpdateUserRoleAndPermissionsEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
info.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return ErrorOrFactory.From(new AuthorizationResponse(
|
||||
return Result.From(new AuthorizationResponse(
|
||||
Guid.NewGuid(),
|
||||
"Admin",
|
||||
new HashSet<AuthorizationPermission> { AuthorizationPermission.CanViewUsers }
|
||||
|
||||
Reference in new issue
Block a user