mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 10:11:10 +00:00
Refactors the test fixtures and their consumers to compose other fixtures instead of instantiating models inline
This commit is contained in:
1 parent
0abda472c6
commit
3aadd6de84
157 files changed
+1312
-597
No files matched your search
+4
-2
@@ -9,6 +9,7 @@ using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Core.Admin.Authorization.Permissions.Queries.GetPermissions;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Core.Admin.Authorization.Permissions.Queries.GetPermissions;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -38,6 +39,7 @@ public class GetPermissionsQueryHandlerTests
|
||||
private readonly Guid _userId;
|
||||
private readonly GetPermissionsQueryFixture _getPermissionsQueryFixture = new();
|
||||
private readonly PermissionEntityFixture _permissionEntityFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<PermissionEntity> _paginatedResultDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPermissionsQueryHandlerTests"/> class.
|
||||
@@ -74,7 +76,7 @@ public class GetPermissionsQueryHandlerTests
|
||||
_mockAuthorizationService.IsInRoleAsync(_userId, "Admin", Arg.Any<CancellationToken>())
|
||||
.Returns(true);
|
||||
_mockPermissionRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<PermissionEntity> { Data = permissions, CurrentPage = 1, PerPage = permissions.Count, Count = permissions.Count, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: permissions, currentPage: 1, perPage: permissions.Count, count: permissions.Count, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PermissionResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
|
||||
@@ -158,7 +160,7 @@ public class GetPermissionsQueryHandlerTests
|
||||
_mockAuthorizationService.IsInRoleAsync(_userId, "Admin", Arg.Any<CancellationToken>())
|
||||
.Returns(true);
|
||||
_mockPermissionRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<PermissionEntity> { Data = permissions, CurrentPage = 1, PerPage = permissions.Count, Count = permissions.Count, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: permissions, currentPage: 1, perPage: permissions.Count, count: permissions.Count, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<PermissionResponse>> result = await _sut.HandleAsync(query, cancellationToken);
|
||||
|
||||
+4
-2
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Errors;
|
||||
using Lumina.Application.Core.Admin.Authorization.Roles.Commands.DeleteRole;
|
||||
using Lumina.Application.Fixtures.Core.Admin.Authorization.Roles.Commands.DeleteRole;
|
||||
using Lumina.Application.UnitTests.Common.Setup;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using System;
|
||||
@@ -17,12 +18,13 @@ namespace Lumina.Application.UnitTests.Core.Admin.Authorization.Roles.Commands.D
|
||||
public class DeleteRoleCommandValidatorTests
|
||||
{
|
||||
private readonly DeleteRoleCommandValidator _validator = new();
|
||||
private readonly DeleteRoleCommandFixture _deleteRoleCommandFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenRoleIdIsEmpty_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
DeleteRoleCommand command = new(Guid.Empty);
|
||||
DeleteRoleCommand command = _deleteRoleCommandFixture.Create(Guid.Empty);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(command);
|
||||
@@ -35,7 +37,7 @@ public class DeleteRoleCommandValidatorTests
|
||||
public void Validate_WhenRoleIdIsValid_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
DeleteRoleCommand command = new(Guid.NewGuid());
|
||||
DeleteRoleCommand command = _deleteRoleCommandFixture.Create(Guid.NewGuid());
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(command);
|
||||
|
||||
+4
-2
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Errors;
|
||||
using Lumina.Application.Core.Admin.Authorization.Roles.Queries.GetRolePermissions;
|
||||
using Lumina.Application.Fixtures.Core.Admin.Authorization.Roles.Queries.GetRolePermissions;
|
||||
using Lumina.Application.UnitTests.Common.Setup;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using System;
|
||||
@@ -17,12 +18,13 @@ namespace Lumina.Application.UnitTests.Core.Admin.Authorization.Roles.Queries.Ge
|
||||
public class GetRolePermissionsQueryValidatorTests
|
||||
{
|
||||
private readonly GetRolePermissionsQueryValidator _validator = new();
|
||||
private readonly GetRolePermissionsQueryFixture _getRolePermissionsQueryFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenRoleIdIsEmpty_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetRolePermissionsQuery query = new(Guid.Empty);
|
||||
GetRolePermissionsQuery query = _getRolePermissionsQueryFixture.Create(Guid.Empty);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
@@ -35,7 +37,7 @@ public class GetRolePermissionsQueryValidatorTests
|
||||
public void Validate_WhenRoleIdIsValid_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetRolePermissionsQuery query = new(Guid.NewGuid());
|
||||
GetRolePermissionsQuery query = _getRolePermissionsQueryFixture.Create(Guid.NewGuid());
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
|
||||
+3
-1
@@ -9,6 +9,7 @@ using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Core.Admin.Authorization.Roles.Queries.GetRoles;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Core.Admin.Authorization.Roles.Queries.GetRoles;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -35,6 +36,7 @@ public class GetRolesQueryHandlerTests
|
||||
private readonly GetRolesQueryHandler _sut;
|
||||
private readonly GetRolesQueryFixture _getRolesQueryFixture = new();
|
||||
private readonly RoleEntityFixture _roleEntityFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<RoleEntity> _paginatedResultDtoFixture = new();
|
||||
private readonly Guid _userId;
|
||||
|
||||
/// <summary>
|
||||
@@ -126,7 +128,7 @@ public class GetRolesQueryHandlerTests
|
||||
_mockAuthorizationService.IsInRoleAsync(_userId, "Admin", Arg.Any<CancellationToken>())
|
||||
.Returns(true);
|
||||
_mockRoleRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<RoleEntity> { Data = roles, CurrentPage = 1, PerPage = roles.Count, Count = roles.Count, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: roles, currentPage: 1, perPage: roles.Count, count: roles.Count, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<RoleResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ public class CheckPathExistsQueryHandlerTests
|
||||
public async Task HandleAsync_WhenCalledWithNullPath_ShouldStillCallPathService()
|
||||
{
|
||||
// Arrange
|
||||
CheckPathExistsQuery query = new(null!, false);
|
||||
CheckPathExistsQuery query = _checkPathExistsQueryFixture.Create(includePath: false, shouldIncludeHiddenElements: false);
|
||||
_mockPathService.Exists(Arg.Any<string>(), Arg.Any<bool>()).Returns(false);
|
||||
|
||||
// Act
|
||||
|
||||
+2
-2
@@ -73,7 +73,7 @@ public class ValidatePathQueryHandlerTests
|
||||
public async Task HandleAsync_WhenCalledWithNullPath_ShouldReturnFalseResponse()
|
||||
{
|
||||
// Arrange
|
||||
ValidatePathQuery query = new(null!);
|
||||
ValidatePathQuery query = _validatePathQueryFixture.Create(includePath: false);
|
||||
_mockPathService.IsValidPath(Arg.Any<string>()).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -89,7 +89,7 @@ public class ValidatePathQueryHandlerTests
|
||||
public async Task HandleAsync_WhenCalledWithEmptyPath_ShouldReturnFalseResponse()
|
||||
{
|
||||
// Arrange
|
||||
ValidatePathQuery query = new(string.Empty);
|
||||
ValidatePathQuery query = _validatePathQueryFixture.Create(string.Empty);
|
||||
_mockPathService.IsValidPath(Arg.Any<string>()).Returns(false);
|
||||
|
||||
// Act
|
||||
|
||||
+8
-6
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.FileSystemManagement.Thumbnails.Queries.GetThumbnail;
|
||||
using Lumina.Application.Fixtures.Core.FileSystemManagement.Thumbnails.Queries.GetThumbnail;
|
||||
using Lumina.Application.UnitTests.Common.Setup;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -16,12 +17,13 @@ namespace Lumina.Application.UnitTests.Core.FileSystemManagement.Thumbnails.Quer
|
||||
public class GetThumbnailQueryValidatorTests
|
||||
{
|
||||
private readonly GetThumbnailQueryValidator _validator = new();
|
||||
private readonly GetThumbnailQueryFixture _getThumbnailQueryFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenPathIsNull_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetThumbnailQuery query = new(null!, 1);
|
||||
GetThumbnailQuery query = _getThumbnailQueryFixture.Create(includePath: false, quality: 1);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
@@ -34,7 +36,7 @@ public class GetThumbnailQueryValidatorTests
|
||||
public void Validate_WhenPathIsEmpty_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetThumbnailQuery query = new(string.Empty, 1);
|
||||
GetThumbnailQuery query = _getThumbnailQueryFixture.Create(string.Empty, 1);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
@@ -47,7 +49,7 @@ public class GetThumbnailQueryValidatorTests
|
||||
public void Validate_WhenPathIsValid_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetThumbnailQuery query = new("test", 1);
|
||||
GetThumbnailQuery query = _getThumbnailQueryFixture.Create("test", 1);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
@@ -60,7 +62,7 @@ public class GetThumbnailQueryValidatorTests
|
||||
public void Validate_WhenQualityIsNegative_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetThumbnailQuery query = new("test", -1);
|
||||
GetThumbnailQuery query = _getThumbnailQueryFixture.Create("test", -1);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
@@ -73,7 +75,7 @@ public class GetThumbnailQueryValidatorTests
|
||||
public void Validate_WhenQualityIsOver100_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetThumbnailQuery query = new("test", 101);
|
||||
GetThumbnailQuery query = _getThumbnailQueryFixture.Create("test", 101);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
@@ -86,7 +88,7 @@ public class GetThumbnailQueryValidatorTests
|
||||
public void Validate_WhenQualityIsValid_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetThumbnailQuery query = new("test", 1);
|
||||
GetThumbnailQuery query = _getThumbnailQueryFixture.Create("test", 1);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
|
||||
+17
-21
@@ -16,6 +16,7 @@ using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
|
||||
using Lumina.Contracts.Responses.Authentication;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -51,6 +52,8 @@ public class SetupApplicationCommandHandlerTests
|
||||
private readonly UserEntityFixture _userEntityFixture = new();
|
||||
private readonly ScheduledJobEntityFixture _scheduledJobEntityFixture = new();
|
||||
private readonly SetupApplicationCommandFixture _setupApplicationCommandFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<UserEntity> _paginatedResultDtoFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<ScheduledJobEntity> _paginatedResultDtoFixtureScheduledJob = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SetupApplicationCommandHandlerTests"/> class.
|
||||
@@ -78,7 +81,7 @@ public class SetupApplicationCommandHandlerTests
|
||||
_mockDataSeedService.SetDefaultScheduledJobsAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Created);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixtureScheduledJob.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
|
||||
_sut = new SetupApplicationCommandHandler(
|
||||
_mockUnitOfWork,
|
||||
@@ -100,7 +103,7 @@ public class SetupApplicationCommandHandlerTests
|
||||
string hashedPassword = Uri.EscapeDataString("hashedPassword");
|
||||
|
||||
_mockUserRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<UserEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
_mockHashService.HashString(command.Password!)
|
||||
.Returns(hashedPassword);
|
||||
_mockUserRepository.InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>())
|
||||
@@ -139,7 +142,7 @@ public class SetupApplicationCommandHandlerTests
|
||||
string encryptedSecret = "encryptedSecret";
|
||||
|
||||
_mockUserRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<UserEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
_mockHashService.HashString(command.Password!)
|
||||
.Returns(hashedPassword);
|
||||
_mockTotpTokenGenerator.GenerateSecret()
|
||||
@@ -181,7 +184,7 @@ public class SetupApplicationCommandHandlerTests
|
||||
UserEntity existingUser = _userEntityFixture.Create();
|
||||
|
||||
_mockUserRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<UserEntity> { Data = [existingUser], CurrentPage = 1, PerPage = 1, Count = 1, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [existingUser], currentPage: 1, perPage: 1, count: 1, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<RegistrationResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
|
||||
@@ -225,7 +228,7 @@ public class SetupApplicationCommandHandlerTests
|
||||
Error error = Error.Failure("Database.Error", "Failed to insert user");
|
||||
|
||||
_mockUserRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<UserEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
_mockUserRepository.InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>())
|
||||
.Returns(error);
|
||||
|
||||
@@ -249,7 +252,7 @@ public class SetupApplicationCommandHandlerTests
|
||||
Error error = Error.Failure("Database.Error", "Failed to set default permissions");
|
||||
|
||||
_mockUserRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<UserEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
_mockUserRepository.InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Created);
|
||||
_mockDataSeedService.SetDefaultAuthorizationPermissionsAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
|
||||
@@ -274,7 +277,7 @@ public class SetupApplicationCommandHandlerTests
|
||||
Error error = Error.Failure("Database.Error", "Failed to set default roles");
|
||||
|
||||
_mockUserRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<UserEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
_mockUserRepository.InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Created);
|
||||
_mockDataSeedService.SetDefaultAuthorizationPermissionsAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
|
||||
@@ -302,7 +305,7 @@ public class SetupApplicationCommandHandlerTests
|
||||
Error error = Error.Failure("Database.Error", "Failed to set admin role permissions");
|
||||
|
||||
_mockUserRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<UserEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
_mockUserRepository.InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Created);
|
||||
_mockDataSeedService.SetDefaultAuthorizationPermissionsAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
|
||||
@@ -333,7 +336,7 @@ public class SetupApplicationCommandHandlerTests
|
||||
Error error = Error.Failure("Database.Error", "Failed to set admin role to administrator account");
|
||||
|
||||
_mockUserRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<UserEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
_mockUserRepository.InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Created);
|
||||
_mockDataSeedService.SetDefaultAuthorizationPermissionsAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
|
||||
@@ -367,7 +370,7 @@ public class SetupApplicationCommandHandlerTests
|
||||
Error error = Error.Failure("Database.Error", "Failed to seed default scheduled jobs");
|
||||
|
||||
_mockUserRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<UserEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
_mockUserRepository.InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Created);
|
||||
_mockDataSeedService.SetDefaultAuthorizationPermissionsAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
|
||||
@@ -399,7 +402,7 @@ public class SetupApplicationCommandHandlerTests
|
||||
SetupApplicationCommand command = _setupApplicationCommandFixture.Create();
|
||||
|
||||
_mockUserRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<UserEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
_mockUserRepository.InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Created);
|
||||
_mockDataSeedService.SetDefaultAuthorizationPermissionsAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
|
||||
@@ -436,7 +439,7 @@ public class SetupApplicationCommandHandlerTests
|
||||
ScheduledJobEntity addedScheduledJob = _scheduledJobEntityFixture.Create(status: ScheduledJobStatus.Added);
|
||||
|
||||
_mockUserRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<UserEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
_mockUserRepository.InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Created);
|
||||
_mockDataSeedService.SetDefaultAuthorizationPermissionsAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
|
||||
@@ -448,14 +451,7 @@ public class SetupApplicationCommandHandlerTests
|
||||
_mockDataSeedService.SetAdminRoleToAdministratorAccount(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Created);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity>
|
||||
{
|
||||
Data = [activeScheduledJob1, activeScheduledJob2, addedScheduledJob],
|
||||
CurrentPage = 1,
|
||||
PerPage = 3,
|
||||
Count = 3,
|
||||
NumberOfPages = 1
|
||||
}));
|
||||
.Returns(Result.From(_paginatedResultDtoFixtureScheduledJob.Create(data: [activeScheduledJob1, activeScheduledJob2, addedScheduledJob], currentPage: 1, perPage: 3, count: 3, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<RegistrationResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
|
||||
@@ -491,7 +487,7 @@ public class SetupApplicationCommandHandlerTests
|
||||
// Arrange
|
||||
SetupApplicationCommand command = _setupApplicationCommandFixture.Create();
|
||||
_mockUserRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<UserEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
_mockHashService.HashString(command.Password!)
|
||||
.Returns("hashedPassword");
|
||||
_mockUserRepository.InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>())
|
||||
|
||||
+4
-2
@@ -6,6 +6,7 @@ using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Maintenance.ApplicationSetup.Queries.CheckInitialization;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Core.Maintenance.ApplicationSetup.Queries.CheckInitialization;
|
||||
using Lumina.Contracts.Responses.UsersManagement;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -29,6 +30,7 @@ public class CheckInitializationQueryHandlerTests
|
||||
private readonly CheckInitializationQueryHandler _sut;
|
||||
private readonly CheckInitializationQueryFixture _checkInitializationQueryFixture = new();
|
||||
private readonly UserEntityFixture _userEntityFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<UserEntity> _paginatedResultDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CheckInitializationQueryHandlerTests"/> class.
|
||||
@@ -50,7 +52,7 @@ public class CheckInitializationQueryHandlerTests
|
||||
// Arrange
|
||||
List<UserEntity> users = _userEntityFixture.CreateMany();
|
||||
_mockUserRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<UserEntity> { Data = users, CurrentPage = 1, PerPage = users.Count, Count = users.Count, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: users, currentPage: 1, perPage: users.Count, count: users.Count, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
InitializationResponse result = await _sut.HandleAsync(_checkInitializationQueryFixture.Create(), CancellationToken.None);
|
||||
@@ -65,7 +67,7 @@ public class CheckInitializationQueryHandlerTests
|
||||
{
|
||||
// Arrange
|
||||
_mockUserRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<UserEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
InitializationResponse result = await _sut.HandleAsync(_checkInitializationQueryFixture.Create(), CancellationToken.None);
|
||||
|
||||
+8
-11
@@ -12,6 +12,8 @@ using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization.Policies.LibraryOwnership;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.UpdateTrack;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaContributors;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.UpdateTrack;
|
||||
@@ -60,9 +62,11 @@ public class UpdateTrackCommandHandlerTests
|
||||
private readonly AlbumEntityFixture _albumEntityFixture = new();
|
||||
private readonly TrackEntityFixture _trackEntityFixture = new();
|
||||
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
|
||||
private readonly AudioMetadataDtoFixture _audioMetadataDtoFixture = new();
|
||||
private readonly MusicTrackMetadataDtoFixture _audioMetadataDtoFixture = new();
|
||||
private readonly GenreDtoFixture _genreDtoFixture = new();
|
||||
private readonly LibraryEntityFixture _libraryEntityFixture = new();
|
||||
private readonly MediaContributorEntityFixture _mediaContributorEntityFixture = new();
|
||||
private readonly GenreEntityFixture _genreEntityFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateTrackCommandHandlerTests"/> class.
|
||||
@@ -102,14 +106,7 @@ public class UpdateTrackCommandHandlerTests
|
||||
.Returns(callInfo =>
|
||||
{
|
||||
IReadOnlyCollection<Guid> contributorIds = callInfo.Arg<IReadOnlyCollection<Guid>>();
|
||||
return Result.From<IReadOnlyList<MediaContributorEntity>>([.. contributorIds.Select(contributorId => new MediaContributorEntity
|
||||
{
|
||||
Id = contributorId,
|
||||
DisplayName = contributorId.ToString(),
|
||||
CreatedOnUtc = DateTime.UtcNow,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedBy = null
|
||||
})]);
|
||||
return Result.From<IReadOnlyList<MediaContributorEntity>>([.. contributorIds.Select(contributorId => _mediaContributorEntityFixture.Create(id: contributorId, displayName: contributorId.ToString()))]);
|
||||
});
|
||||
|
||||
_sut = new UpdateTrackCommandHandler(_mockUnitOfWork, _mockAuthorizationService, _mockCurrentUserService, _mockValidator, _mockPathService);
|
||||
@@ -471,7 +468,7 @@ public class UpdateTrackCommandHandlerTests
|
||||
Guid albumId = Guid.NewGuid();
|
||||
Guid trackId = Guid.NewGuid();
|
||||
AlbumEntity invalidAlbum = _albumEntityFixture.Create(id: albumId, libraryId: libraryId, tracks: [_trackEntityFixture.Create(id: trackId, albumId: albumId, libraryId: libraryId)]);
|
||||
invalidAlbum.Genres = [new GenreEntity(string.Empty)];
|
||||
invalidAlbum.Genres = [_genreEntityFixture.Create(name: string.Empty)];
|
||||
ArtistEntity existingArtist = _artistEntityFixture.Create(libraryId: libraryId, albums: [invalidAlbum]);
|
||||
UpdateTrackCommand command = _updateTrackCommandFixture.Create(libraryId: libraryId.ToString(), artistId: existingArtist.Id.ToString(), albumId: albumId.ToString(), trackId: trackId.ToString());
|
||||
_mockArtistRepository.GetByIdAsync(Arg.Any<Guid>(), Arg.Any<bool>(), Arg.Any<bool>(), Arg.Any<CancellationToken>())
|
||||
@@ -492,7 +489,7 @@ public class UpdateTrackCommandHandlerTests
|
||||
// Arrange
|
||||
Guid libraryId = Guid.NewGuid();
|
||||
(ArtistEntity existingArtist, Guid albumId, Guid trackId) = CreateArtistWithTrack(libraryId);
|
||||
AudioMetadataDto invalidMetadata = _audioMetadataDtoFixture.Create(genres: [_genreDtoFixture.Create(name: string.Empty)]);
|
||||
MusicTrackMetadataDto invalidMetadata = _audioMetadataDtoFixture.Create(genres: [_genreDtoFixture.Create(name: string.Empty)]);
|
||||
UpdateTrackCommand command = _updateTrackCommandFixture.Create(libraryId: libraryId.ToString(), artistId: existingArtist.Id.ToString(), albumId: albumId.ToString(), trackId: trackId.ToString(), metadata: invalidMetadata);
|
||||
_mockArtistRepository.GetByIdAsync(Arg.Any<Guid>(), Arg.Any<bool>(), Arg.Any<bool>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ArtistEntity?>(existingArtist));
|
||||
|
||||
+4
-2
@@ -9,6 +9,7 @@ using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraries;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Core.MediaLibrary.Management.Queries.GetLibraries;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -35,6 +36,7 @@ public class GetLibrariesQueryHandlerTests
|
||||
private readonly GetLibrariesQueryHandler _sut;
|
||||
private readonly GetLibrariesQueryFixture _getLibrariesQueryFixture = new();
|
||||
private readonly LibraryEntityFixture _libraryEntityFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<LibraryEntity> _paginatedResultDtoFixture = new();
|
||||
private readonly Guid _userId;
|
||||
|
||||
/// <summary>
|
||||
@@ -66,7 +68,7 @@ public class GetLibrariesQueryHandlerTests
|
||||
_libraryEntityFixture.Create(userId: _userId),
|
||||
_libraryEntityFixture.Create(userId: Guid.NewGuid())
|
||||
];
|
||||
_mockLibraryRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<LibraryEntity> { Data = libraries, CurrentPage = 1, PerPage = libraries.Count, Count = libraries.Count, NumberOfPages = 1 }));
|
||||
_mockLibraryRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(_paginatedResultDtoFixture.Create(data: libraries, currentPage: 1, perPage: libraries.Count, count: libraries.Count, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<LibraryResponse[]> result = await _sut.HandleAsync(_getLibrariesQueryFixture.Create(), CancellationToken.None);
|
||||
@@ -88,7 +90,7 @@ public class GetLibrariesQueryHandlerTests
|
||||
_libraryEntityFixture.Create(userId: _userId),
|
||||
_libraryEntityFixture.Create(userId: otherUserId)
|
||||
];
|
||||
_mockLibraryRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<LibraryEntity> { Data = libraries, CurrentPage = 1, PerPage = libraries.Count, Count = libraries.Count, NumberOfPages = 1 }));
|
||||
_mockLibraryRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(_paginatedResultDtoFixture.Create(data: libraries, currentPage: 1, perPage: libraries.Count, count: libraries.Count, numberOfPages: 1)));
|
||||
_mockAuthorizationService.IsInRoleAsync(_userId, "Admin", Arg.Any<CancellationToken>()).Returns(false);
|
||||
|
||||
// Act
|
||||
|
||||
+2
-8
@@ -65,6 +65,7 @@ public class AddBookCommandHandlerTests
|
||||
private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new();
|
||||
private readonly WrittenContentMetadataDtoFixture _writtenContentMetadataDtoFixture = new();
|
||||
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
|
||||
private readonly MediaContributorEntityFixture _mediaContributorEntityFixture = new();
|
||||
private readonly LibraryEntityFixture _libraryEntityFixture = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -104,14 +105,7 @@ public class AddBookCommandHandlerTests
|
||||
.Returns(callInfo =>
|
||||
{
|
||||
IReadOnlyCollection<Guid> contributorIds = callInfo.Arg<IReadOnlyCollection<Guid>>();
|
||||
return Result.From<IReadOnlyList<MediaContributorEntity>>([.. contributorIds.Select(contributorId => new MediaContributorEntity
|
||||
{
|
||||
Id = contributorId,
|
||||
DisplayName = contributorId.ToString(),
|
||||
CreatedOnUtc = DateTime.UtcNow,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedBy = null
|
||||
})]);
|
||||
return Result.From<IReadOnlyList<MediaContributorEntity>>([.. contributorIds.Select(contributorId => _mediaContributorEntityFixture.Create(id: contributorId, displayName: contributorId.ToString()))]);
|
||||
});
|
||||
|
||||
IValidator<AddBookCommand> mockValidator = Substitute.For<IValidator<AddBookCommand>>();
|
||||
|
||||
+2
-8
@@ -61,6 +61,7 @@ public class UpdateBookCommandHandlerTests
|
||||
private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new();
|
||||
private readonly WrittenContentMetadataDtoFixture _writtenContentMetadataDtoFixture = new();
|
||||
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
|
||||
private readonly MediaContributorEntityFixture _mediaContributorEntityFixture = new();
|
||||
private readonly LibraryEntityFixture _libraryEntityFixture = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -97,14 +98,7 @@ public class UpdateBookCommandHandlerTests
|
||||
.Returns(callInfo =>
|
||||
{
|
||||
IReadOnlyCollection<Guid> contributorIds = callInfo.Arg<IReadOnlyCollection<Guid>>();
|
||||
return Result.From<IReadOnlyList<MediaContributorEntity>>([.. contributorIds.Select(contributorId => new MediaContributorEntity
|
||||
{
|
||||
Id = contributorId,
|
||||
DisplayName = contributorId.ToString(),
|
||||
CreatedOnUtc = DateTime.UtcNow,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedBy = null
|
||||
})]);
|
||||
return Result.From<IReadOnlyList<MediaContributorEntity>>([.. contributorIds.Select(contributorId => _mediaContributorEntityFixture.Create(id: contributorId, displayName: contributorId.ToString()))]);
|
||||
});
|
||||
|
||||
_sut = new UpdateBookCommandHandler(_mockUnitOfWork, _mockAuthorizationService, _mockCurrentUserService, _mockValidator);
|
||||
|
||||
+5
-3
@@ -10,6 +10,7 @@ using Lumina.Application.Common.Infrastructure.Authorization.Policies.LibraryOwn
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Core.Plugins.Queries.GetLibraryArtworkProviders;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Core.Plugins.Queries.GetLibraryArtworkProviders;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
@@ -41,6 +42,7 @@ public class GetLibraryArtworkProvidersQueryHandlerTests
|
||||
private readonly GetLibraryArtworkProvidersQueryFixture _getLibraryArtworkProvidersQueryFixture = new();
|
||||
private readonly LibraryArtworkProviderConfigurationEntityFixture _configurationEntityFixture = new();
|
||||
private readonly PluginEntityFixture _pluginEntityFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<PluginEntity> _paginatedResultDtoFixture = new();
|
||||
private readonly Guid _userId;
|
||||
|
||||
/// <summary>
|
||||
@@ -104,7 +106,7 @@ public class GetLibraryArtworkProvidersQueryHandlerTests
|
||||
_pluginEntityFixture.Create(secondPluginId)
|
||||
];
|
||||
_mockPluginRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<PluginEntity> { Data = plugins, CurrentPage = 1, PerPage = plugins.Count, Count = plugins.Count, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: plugins, currentPage: 1, perPage: plugins.Count, count: plugins.Count, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IReadOnlyList<LibraryArtworkProviderResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
|
||||
@@ -132,7 +134,7 @@ public class GetLibraryArtworkProvidersQueryHandlerTests
|
||||
_mockArtworkProviderConfigurationRepository.GetByLibraryIdAsync(query.LibraryId, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<IReadOnlyList<LibraryArtworkProviderConfigurationEntity>>(configurations));
|
||||
_mockPluginRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<PluginEntity> { Data = [_pluginEntityFixture.Create()], CurrentPage = 1, PerPage = 1, Count = 1, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [_pluginEntityFixture.Create()], currentPage: 1, perPage: 1, count: 1, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IReadOnlyList<LibraryArtworkProviderResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
|
||||
@@ -152,7 +154,7 @@ public class GetLibraryArtworkProvidersQueryHandlerTests
|
||||
_mockArtworkProviderConfigurationRepository.GetByLibraryIdAsync(query.LibraryId, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<IReadOnlyList<LibraryArtworkProviderConfigurationEntity>>([]));
|
||||
_mockPluginRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<PluginEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IReadOnlyList<LibraryArtworkProviderResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
|
||||
|
||||
+5
-3
@@ -11,6 +11,7 @@ using Lumina.Application.Common.Infrastructure.Reading;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Core.Plugins.Queries.GetLibraryBookReaders;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Core.Plugins.Queries.GetLibraryBookReaders;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
@@ -43,6 +44,7 @@ public class GetLibraryBookReadersQueryHandlerTests
|
||||
private readonly GetLibraryBookReadersQueryFixture _getLibraryBookReadersQueryFixture = new();
|
||||
private readonly LibraryBookReaderConfigurationEntityFixture _configurationEntityFixture = new();
|
||||
private readonly PluginEntityFixture _pluginEntityFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<PluginEntity> _paginatedResultDtoFixture = new();
|
||||
private readonly Guid _userId;
|
||||
|
||||
/// <summary>
|
||||
@@ -108,7 +110,7 @@ public class GetLibraryBookReadersQueryHandlerTests
|
||||
_pluginEntityFixture.Create(disabledPluginId, "B Reader")
|
||||
];
|
||||
_mockPluginRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<PluginEntity> { Data = plugins, CurrentPage = 1, PerPage = plugins.Count, Count = plugins.Count, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: plugins, currentPage: 1, perPage: plugins.Count, count: plugins.Count, numberOfPages: 1)));
|
||||
Dictionary<Guid, IReadOnlyList<string>> supportedExtensions = new()
|
||||
{
|
||||
[enabledPluginId] = [".epub"],
|
||||
@@ -143,7 +145,7 @@ public class GetLibraryBookReadersQueryHandlerTests
|
||||
_mockLibraryBookReaderConfigurationRepository.GetByLibraryIdAsync(query.LibraryId, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<IReadOnlyList<LibraryBookReaderConfigurationEntity>>(configurations));
|
||||
_mockPluginRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<PluginEntity> { Data = [_pluginEntityFixture.Create()], CurrentPage = 1, PerPage = 1, Count = 1, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [_pluginEntityFixture.Create()], currentPage: 1, perPage: 1, count: 1, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IReadOnlyList<LibraryBookReaderResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
|
||||
@@ -164,7 +166,7 @@ public class GetLibraryBookReadersQueryHandlerTests
|
||||
_mockLibraryBookReaderConfigurationRepository.GetByLibraryIdAsync(query.LibraryId, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<IReadOnlyList<LibraryBookReaderConfigurationEntity>>([]));
|
||||
_mockPluginRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<PluginEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IReadOnlyList<LibraryBookReaderResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
|
||||
|
||||
+5
-3
@@ -11,6 +11,7 @@ using Lumina.Application.Common.Infrastructure.Plugins;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Core.Plugins.Queries.GetLibraryMetadataProviders;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Core.Plugins.Queries.GetLibraryMetadataProviders;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
@@ -42,6 +43,7 @@ public class GetLibraryMetadataProvidersQueryHandlerTests
|
||||
private readonly GetLibraryMetadataProvidersQueryFixture _getLibraryMetadataProvidersQueryFixture = new();
|
||||
private readonly LibraryMetadataProviderConfigurationEntityFixture _configurationEntityFixture = new();
|
||||
private readonly PluginEntityFixture _pluginEntityFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<PluginEntity> _paginatedResultDtoFixture = new();
|
||||
private readonly Guid _userId;
|
||||
|
||||
/// <summary>
|
||||
@@ -104,7 +106,7 @@ public class GetLibraryMetadataProvidersQueryHandlerTests
|
||||
_pluginEntityFixture.Create(secondPluginId)
|
||||
];
|
||||
_mockPluginRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<PluginEntity> { Data = plugins, CurrentPage = 1, PerPage = plugins.Count, Count = plugins.Count, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: plugins, currentPage: 1, perPage: plugins.Count, count: plugins.Count, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IReadOnlyList<LibraryMetadataProviderResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
|
||||
@@ -132,7 +134,7 @@ public class GetLibraryMetadataProvidersQueryHandlerTests
|
||||
_mockProviderConfigurationStore.GetConfigurationsAsync(query.LibraryId, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<IReadOnlyList<LibraryMetadataProviderConfigurationEntity>>(configurations));
|
||||
_mockPluginRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<PluginEntity> { Data = [_pluginEntityFixture.Create()], CurrentPage = 1, PerPage = 1, Count = 1, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [_pluginEntityFixture.Create()], currentPage: 1, perPage: 1, count: 1, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IReadOnlyList<LibraryMetadataProviderResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
|
||||
@@ -152,7 +154,7 @@ public class GetLibraryMetadataProvidersQueryHandlerTests
|
||||
_mockProviderConfigurationStore.GetConfigurationsAsync(query.LibraryId, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<IReadOnlyList<LibraryMetadataProviderConfigurationEntity>>([]));
|
||||
_mockPluginRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<PluginEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IReadOnlyList<LibraryMetadataProviderResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
|
||||
|
||||
+3
-1
@@ -6,6 +6,7 @@ using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Plugins.Queries.GetPlugins;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Core.Plugins.Queries.GetPlugins;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -29,6 +30,7 @@ public class GetPluginsQueryHandlerTests
|
||||
private readonly GetPluginsQueryHandler _sut;
|
||||
private readonly GetPluginsQueryFixture _getPluginsQueryFixture = new();
|
||||
private readonly PluginEntityFixture _pluginEntityFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<PluginEntity> _paginatedResultDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPluginsQueryHandlerTests"/> class.
|
||||
@@ -48,7 +50,7 @@ public class GetPluginsQueryHandlerTests
|
||||
// Arrange
|
||||
List<PluginEntity> plugins = [_pluginEntityFixture.Create(), _pluginEntityFixture.Create()];
|
||||
_mockPluginRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<PluginEntity> { Data = plugins, CurrentPage = 1, PerPage = plugins.Count, Count = plugins.Count, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: plugins, currentPage: 1, perPage: plugins.Count, count: plugins.Count, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IReadOnlyList<PluginResponse>> result = await _sut.HandleAsync(_getPluginsQueryFixture.Create(), CancellationToken.None);
|
||||
|
||||
+4
-2
@@ -7,6 +7,7 @@ using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Scheduling.Events;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Contracts.Responses.Scheduling;
|
||||
using Lumina.Domain.Common.Exceptions;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -35,6 +36,7 @@ public class ScheduledJobAddedDomainEventHandlerTests
|
||||
private readonly ScheduledJobAddedDomainEventHandler _sut;
|
||||
private readonly ScheduledJobEntityFixture _scheduledJobEntityFixture = new();
|
||||
private readonly ScheduledJobAddedDomainEventFixture _scheduledJobAddedDomainEventFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<ScheduledJobEntity> _paginatedResultDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScheduledJobAddedDomainEventHandlerTests"/> class.
|
||||
@@ -47,7 +49,7 @@ public class ScheduledJobAddedDomainEventHandlerTests
|
||||
_mockScheduledJobRepository = Substitute.For<IScheduledJobRepository>();
|
||||
|
||||
_mockUnitOfWork.ScheduledJobRepository.Returns(_mockScheduledJobRepository);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
|
||||
_sut = new ScheduledJobAddedDomainEventHandler(_mockScheduledJobNotifier, _mockUnitOfWork);
|
||||
}
|
||||
@@ -59,7 +61,7 @@ public class ScheduledJobAddedDomainEventHandlerTests
|
||||
ScheduledJobAddedDomainEvent domainEvent = _scheduledJobAddedDomainEventFixture.Create();
|
||||
ScheduledJobEntity scheduledJob1 = _scheduledJobEntityFixture.Create(name: "Job 1");
|
||||
ScheduledJobEntity scheduledJob2 = _scheduledJobEntityFixture.Create(name: "Job 2");
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [scheduledJob1, scheduledJob2], CurrentPage = 1, PerPage = 2, Count = 2, NumberOfPages = 1 }));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(_paginatedResultDtoFixture.Create(data: [scheduledJob1, scheduledJob2], currentPage: 1, perPage: 2, count: 2, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
await _sut.HandleAsync(domainEvent, CancellationToken.None);
|
||||
|
||||
+3
-1
@@ -7,6 +7,7 @@ using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.Infrastructure.Scheduling;
|
||||
using Lumina.Application.Core.Scheduling.Events;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Contracts.Responses.Scheduling;
|
||||
using Lumina.Domain.Common.Exceptions;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -34,6 +35,7 @@ public class ScheduledJobCycleStartedDomainEventHandlerTests
|
||||
private readonly IScheduledJobRepository _mockScheduledJobRepository;
|
||||
private readonly ScheduledJobCycleStartedDomainEventHandler _sut;
|
||||
private readonly ScheduledJobCycleStartedDomainEventFixture _scheduledJobCycleStartedDomainEventFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<ScheduledJobEntity> _paginatedResultDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScheduledJobCycleStartedDomainEventHandlerTests"/> class.
|
||||
@@ -47,7 +49,7 @@ public class ScheduledJobCycleStartedDomainEventHandlerTests
|
||||
_mockScheduledJobRepository = Substitute.For<IScheduledJobRepository>();
|
||||
|
||||
_mockUnitOfWork.ScheduledJobRepository.Returns(_mockScheduledJobRepository);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
|
||||
_sut = new ScheduledJobCycleStartedDomainEventHandler(_mockScheduledJobNotifier, _mockScheduledJobScheduler, _mockUnitOfWork);
|
||||
}
|
||||
|
||||
+4
-2
@@ -7,6 +7,7 @@ using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Scheduling.Events;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Contracts.Responses.Scheduling;
|
||||
using Lumina.Domain.Common.Exceptions;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -34,6 +35,7 @@ public class ScheduledJobCycleStoppedDomainEventHandlerTests
|
||||
private readonly ScheduledJobCycleStoppedDomainEventHandler _sut;
|
||||
private readonly ScheduledJobEntityFixture _scheduledJobEntityFixture = new();
|
||||
private readonly ScheduledJobCycleStoppedDomainEventFixture _scheduledJobCycleStoppedDomainEventFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<ScheduledJobEntity> _paginatedResultDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScheduledJobCycleStoppedDomainEventHandlerTests"/> class.
|
||||
@@ -46,7 +48,7 @@ public class ScheduledJobCycleStoppedDomainEventHandlerTests
|
||||
_mockScheduledJobRepository = Substitute.For<IScheduledJobRepository>();
|
||||
|
||||
_mockUnitOfWork.ScheduledJobRepository.Returns(_mockScheduledJobRepository);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
|
||||
_sut = new ScheduledJobCycleStoppedDomainEventHandler(_mockScheduledJobNotifier, _mockUnitOfWork);
|
||||
}
|
||||
@@ -57,7 +59,7 @@ public class ScheduledJobCycleStoppedDomainEventHandlerTests
|
||||
// Arrange
|
||||
ScheduledJobCycleStoppedDomainEvent domainEvent = _scheduledJobCycleStoppedDomainEventFixture.Create();
|
||||
ScheduledJobEntity stoppedJob = _scheduledJobEntityFixture.Create(name: "Stopped job", status: Lumina.Domain.SharedKernel.Common.Enums.Scheduling.ScheduledJobStatus.Added);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [stoppedJob], CurrentPage = 1, PerPage = 1, Count = 1, NumberOfPages = 1 }));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(_paginatedResultDtoFixture.Create(data: [stoppedJob], currentPage: 1, perPage: 1, count: 1, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
await _sut.HandleAsync(domainEvent, CancellationToken.None);
|
||||
|
||||
+3
-1
@@ -7,6 +7,7 @@ using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Scheduling.Events;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Contracts.Responses.Scheduling;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Exceptions;
|
||||
@@ -38,6 +39,7 @@ public class ScheduledJobExecutionCompletedDomainEventHandlerTests
|
||||
private readonly ScheduledJobEntityFixture _scheduledJobEntityFixture = new();
|
||||
private readonly ScheduledJobExecutionEntityFixture _scheduledJobExecutionEntityFixture = new();
|
||||
private readonly ScheduledJobExecutionCompletedDomainEventFixture _scheduledJobExecutionCompletedDomainEventFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<ScheduledJobEntity> _paginatedResultDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScheduledJobExecutionCompletedDomainEventHandlerTests"/> class.
|
||||
@@ -54,7 +56,7 @@ public class ScheduledJobExecutionCompletedDomainEventHandlerTests
|
||||
_mockUnitOfWork.ScheduledJobExecutionRepository.Returns(_mockScheduledJobExecutionRepository);
|
||||
_mockScheduledJobRepository.UpdateAsync(Arg.Any<ScheduledJobEntity>(), Arg.Any<CancellationToken>()).Returns(Result.Updated);
|
||||
_mockScheduledJobExecutionRepository.UpdateAsync(Arg.Any<ScheduledJobExecutionEntity>(), Arg.Any<CancellationToken>()).Returns(Result.Updated);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
|
||||
_sut = new ScheduledJobExecutionCompletedDomainEventHandler(_mockScheduledJobNotifier, _mockUnitOfWork);
|
||||
}
|
||||
|
||||
+3
-1
@@ -7,6 +7,7 @@ using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Scheduling.Events;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Contracts.Responses.Scheduling;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Exceptions;
|
||||
@@ -39,6 +40,7 @@ public class ScheduledJobExecutionStartedDomainEventHandlerTests
|
||||
private readonly ScheduledJobEntityFixture _scheduledJobEntityFixture = new();
|
||||
private readonly ScheduledJobExecutionEntityFixture _scheduledJobExecutionEntityFixture = new();
|
||||
private readonly ScheduledJobExecutionStartedDomainEventFixture _scheduledJobExecutionStartedDomainEventFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<ScheduledJobEntity> _paginatedResultDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScheduledJobExecutionStartedDomainEventHandlerTests"/> class.
|
||||
@@ -55,7 +57,7 @@ public class ScheduledJobExecutionStartedDomainEventHandlerTests
|
||||
_mockUnitOfWork.ScheduledJobExecutionRepository.Returns(_mockScheduledJobExecutionRepository);
|
||||
_mockScheduledJobRepository.UpdateAsync(Arg.Any<ScheduledJobEntity>(), Arg.Any<CancellationToken>()).Returns(Result.Updated);
|
||||
_mockScheduledJobExecutionRepository.InsertAsync(Arg.Any<ScheduledJobExecutionEntity>(), Arg.Any<CancellationToken>()).Returns(Result.Created);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
|
||||
_sut = new ScheduledJobExecutionStartedDomainEventHandler(_mockScheduledJobNotifier, _mockUnitOfWork);
|
||||
}
|
||||
|
||||
+3
-1
@@ -7,6 +7,7 @@ using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Scheduling.Events;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Contracts.Responses.Scheduling;
|
||||
using Lumina.Domain.Common.Exceptions;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -35,6 +36,7 @@ public class ScheduledJobExecutionStoppedDomainEventHandlerTests
|
||||
private readonly ScheduledJobExecutionStoppedDomainEventHandler _sut;
|
||||
private readonly ScheduledJobExecutionEntityFixture _scheduledJobExecutionEntityFixture = new();
|
||||
private readonly ScheduledJobExecutionStoppedDomainEventFixture _scheduledJobExecutionStoppedDomainEventFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<ScheduledJobEntity> _paginatedResultDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScheduledJobExecutionStoppedDomainEventHandlerTests"/> class.
|
||||
@@ -50,7 +52,7 @@ public class ScheduledJobExecutionStoppedDomainEventHandlerTests
|
||||
_mockUnitOfWork.ScheduledJobRepository.Returns(_mockScheduledJobRepository);
|
||||
_mockUnitOfWork.ScheduledJobExecutionRepository.Returns(_mockScheduledJobExecutionRepository);
|
||||
_mockScheduledJobExecutionRepository.UpdateAsync(Arg.Any<ScheduledJobExecutionEntity>(), Arg.Any<CancellationToken>()).Returns(Result.Updated);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
|
||||
_sut = new ScheduledJobExecutionStoppedDomainEventHandler(_mockScheduledJobNotifier, _mockUnitOfWork);
|
||||
}
|
||||
|
||||
+4
-2
@@ -7,6 +7,7 @@ using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Scheduling.Events;
|
||||
using Lumina.Application.Core.Scheduling.Notifications;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Contracts.Responses.Scheduling;
|
||||
using Lumina.Domain.Common.Exceptions;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -34,6 +35,7 @@ public class ScheduledJobRemovedDomainEventHandlerTests
|
||||
private readonly ScheduledJobRemovedDomainEventHandler _sut;
|
||||
private readonly ScheduledJobEntityFixture _scheduledJobEntityFixture = new();
|
||||
private readonly ScheduledJobRemovedDomainEventFixture _scheduledJobRemovedDomainEventFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<ScheduledJobEntity> _paginatedResultDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScheduledJobRemovedDomainEventHandlerTests"/> class.
|
||||
@@ -46,7 +48,7 @@ public class ScheduledJobRemovedDomainEventHandlerTests
|
||||
_mockScheduledJobRepository = Substitute.For<IScheduledJobRepository>();
|
||||
|
||||
_mockUnitOfWork.ScheduledJobRepository.Returns(_mockScheduledJobRepository);
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
|
||||
_sut = new ScheduledJobRemovedDomainEventHandler(_mockScheduledJobNotifier, _mockUnitOfWork);
|
||||
}
|
||||
@@ -57,7 +59,7 @@ public class ScheduledJobRemovedDomainEventHandlerTests
|
||||
// Arrange
|
||||
ScheduledJobRemovedDomainEvent domainEvent = _scheduledJobRemovedDomainEventFixture.Create();
|
||||
ScheduledJobEntity remainingJob = _scheduledJobEntityFixture.Create(name: "Remaining job");
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [remainingJob], CurrentPage = 1, PerPage = 1, Count = 1, NumberOfPages = 1 }));
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>()).Returns(Result.From(_paginatedResultDtoFixture.Create(data: [remainingJob], currentPage: 1, perPage: 1, count: 1, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
await _sut.HandleAsync(domainEvent, CancellationToken.None);
|
||||
|
||||
+4
-2
@@ -8,6 +8,7 @@ using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Core.Scheduling.Queries.GetScheduledJobs;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Contracts.Responses.Scheduling;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using NSubstitute;
|
||||
@@ -34,6 +35,7 @@ public class GetScheduledJobsQueryHandlerTests
|
||||
private readonly IScheduledJobRepository _mockScheduledJobRepository;
|
||||
private readonly GetScheduledJobsQueryHandler _sut;
|
||||
private readonly ScheduledJobEntityFixture _scheduledJobEntityFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<ScheduledJobEntity> _paginatedResultDtoFixture = new();
|
||||
private readonly Guid _userId = Guid.NewGuid();
|
||||
|
||||
/// <summary>
|
||||
@@ -61,7 +63,7 @@ public class GetScheduledJobsQueryHandlerTests
|
||||
ScheduledJobEntity scheduledJob1 = _scheduledJobEntityFixture.Create(name: "Job 1");
|
||||
ScheduledJobEntity scheduledJob2 = _scheduledJobEntityFixture.Create(name: "Job 2");
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [scheduledJob1, scheduledJob2], CurrentPage = 1, PerPage = 2, Count = 2, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [scheduledJob1, scheduledJob2], currentPage: 1, perPage: 2, count: 2, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<ScheduledJobResponse>> result = await _sut.HandleAsync(new GetScheduledJobsQuery(), CancellationToken.None);
|
||||
@@ -78,7 +80,7 @@ public class GetScheduledJobsQueryHandlerTests
|
||||
{
|
||||
// Arrange
|
||||
_mockScheduledJobRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<ScheduledJobEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<ScheduledJobResponse>> result = await _sut.HandleAsync(new GetScheduledJobsQuery(), CancellationToken.None);
|
||||
|
||||
+10
-8
@@ -10,6 +10,7 @@ using Lumina.Application.Common.Infrastructure.Themes;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Core.Themes.Management.Commands.DeleteTheme;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Themes;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Core.Themes.Management.Commands.DeleteTheme;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -41,6 +42,7 @@ public class DeleteThemeCommandHandlerTests
|
||||
private readonly DeleteThemeCommandHandler _sut;
|
||||
private readonly DeleteThemeCommandFixture _deleteThemeCommandFixture = new();
|
||||
private readonly ThemeEntityFixture _themeEntityFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<ThemeEntity> _paginatedResultDtoFixture = new();
|
||||
private readonly Guid _userId;
|
||||
|
||||
/// <summary>
|
||||
@@ -210,7 +212,7 @@ public class DeleteThemeCommandHandlerTests
|
||||
_mockThemeRepository.GetByThemeIdAsync(command.ThemeId!, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ThemeEntity?>(theme));
|
||||
_mockThemeRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<ThemeEntity> { Data = [theme, userTheme], CurrentPage = 1, PerPage = 2, Count = 2, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [theme, userTheme], currentPage: 1, perPage: 2, count: 2, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<Success> result = await _sut.HandleAsync(command, CancellationToken.None);
|
||||
@@ -232,7 +234,7 @@ public class DeleteThemeCommandHandlerTests
|
||||
_mockThemeRepository.GetByThemeIdAsync(command.ThemeId!, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ThemeEntity?>(theme));
|
||||
_mockThemeRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<ThemeEntity> { Data = [theme], CurrentPage = 1, PerPage = 1, Count = 1, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [theme], currentPage: 1, perPage: 1, count: 1, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<Success> result = await _sut.HandleAsync(command, CancellationToken.None);
|
||||
@@ -255,7 +257,7 @@ public class DeleteThemeCommandHandlerTests
|
||||
_mockThemeRepository.GetByThemeIdAsync(command.ThemeId!, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ThemeEntity?>(theme));
|
||||
_mockThemeRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<ThemeEntity> { Data = [theme, otherBundledTheme], CurrentPage = 1, PerPage = 2, Count = 2, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [theme, otherBundledTheme], currentPage: 1, perPage: 2, count: 2, numberOfPages: 1)));
|
||||
_mockThemeRepository.UpdateAsync(Arg.Any<ThemeEntity>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Updated);
|
||||
|
||||
@@ -282,7 +284,7 @@ public class DeleteThemeCommandHandlerTests
|
||||
_mockThemeRepository.GetByThemeIdAsync(command.ThemeId!, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ThemeEntity?>(theme));
|
||||
_mockThemeRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<ThemeEntity> { Data = [theme, bundledTheme], CurrentPage = 1, PerPage = 2, Count = 2, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [theme, bundledTheme], currentPage: 1, perPage: 2, count: 2, numberOfPages: 1)));
|
||||
_mockThemeRepository.DeleteByIdAsync(theme.Id, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Deleted);
|
||||
|
||||
@@ -308,7 +310,7 @@ public class DeleteThemeCommandHandlerTests
|
||||
_mockThemeRepository.GetByThemeIdAsync(command.ThemeId!, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ThemeEntity?>(theme));
|
||||
_mockThemeRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<ThemeEntity> { Data = [theme, bundledTheme], CurrentPage = 1, PerPage = 2, Count = 2, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [theme, bundledTheme], currentPage: 1, perPage: 2, count: 2, numberOfPages: 1)));
|
||||
_mockThemeRepository.DeleteByIdAsync(theme.Id, Arg.Any<CancellationToken>())
|
||||
.Returns(error);
|
||||
|
||||
@@ -333,7 +335,7 @@ public class DeleteThemeCommandHandlerTests
|
||||
_mockThemeRepository.GetByThemeIdAsync(command.ThemeId!, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ThemeEntity?>(theme));
|
||||
_mockThemeRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<ThemeEntity> { Data = [theme, replacementTheme], CurrentPage = 1, PerPage = 2, Count = 2, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [theme, replacementTheme], currentPage: 1, perPage: 2, count: 2, numberOfPages: 1)));
|
||||
_mockThemeRepository.UpdateAsync(Arg.Any<ThemeEntity>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Updated);
|
||||
|
||||
@@ -364,7 +366,7 @@ public class DeleteThemeCommandHandlerTests
|
||||
_mockThemeRepository.GetByThemeIdAsync(command.ThemeId!, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ThemeEntity?>(theme));
|
||||
_mockThemeRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<ThemeEntity> { Data = [theme, betaTheme, alphaTheme], CurrentPage = 1, PerPage = 3, Count = 3, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [theme, betaTheme, alphaTheme], currentPage: 1, perPage: 3, count: 3, numberOfPages: 1)));
|
||||
_mockThemeRepository.UpdateAsync(Arg.Any<ThemeEntity>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Updated);
|
||||
|
||||
@@ -392,7 +394,7 @@ public class DeleteThemeCommandHandlerTests
|
||||
_mockThemeRepository.GetByThemeIdAsync(command.ThemeId!, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<ThemeEntity?>(theme));
|
||||
_mockThemeRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<ThemeEntity> { Data = [theme, bundledTheme], CurrentPage = 1, PerPage = 2, Count = 2, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [theme, bundledTheme], currentPage: 1, perPage: 2, count: 2, numberOfPages: 1)));
|
||||
_mockThemeRepository.DeleteByIdAsync(theme.Id, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Deleted);
|
||||
_mockThemeService.DeleteAsync(theme.ThemeId, Arg.Any<CancellationToken>())
|
||||
|
||||
+4
-2
@@ -6,6 +6,7 @@ using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Themes.Management.Queries.GetThemes;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Themes;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Core.Themes.Management.Queries.GetThemes;
|
||||
using Lumina.Contracts.Responses.Themes;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -30,6 +31,7 @@ public class GetThemesQueryHandlerTests
|
||||
private readonly GetThemesQueryHandler _sut;
|
||||
private readonly GetThemesQueryFixture _getThemesQueryFixture = new();
|
||||
private readonly ThemeEntityFixture _themeEntityFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<ThemeEntity> _paginatedResultDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetThemesQueryHandlerTests"/> class.
|
||||
@@ -53,7 +55,7 @@ public class GetThemesQueryHandlerTests
|
||||
ThemeEntity bundledUpperTheme = _themeEntityFixture.Create(themeId: "bundled-upper", name: "Banana", installSource: ThemeInstallSource.Bundled, isDeleted: false);
|
||||
ThemeEntity deletedTheme = _themeEntityFixture.Create(themeId: "deleted-theme", name: "Deleted", installSource: ThemeInstallSource.Uploaded, isDeleted: true);
|
||||
_mockThemeRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<ThemeEntity> { Data = [uploadedTheme, bundledLowerTheme, bundledUpperTheme, deletedTheme], CurrentPage = 1, PerPage = 4, Count = 4, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [uploadedTheme, bundledLowerTheme, bundledUpperTheme, deletedTheme], currentPage: 1, perPage: 4, count: 4, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IReadOnlyList<ThemeResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
|
||||
@@ -77,7 +79,7 @@ public class GetThemesQueryHandlerTests
|
||||
// Arrange
|
||||
GetThemesQuery query = _getThemesQueryFixture.Create();
|
||||
_mockThemeRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<ThemeEntity> { Data = [], CurrentPage = 1, PerPage = 0, Count = 0, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: [], currentPage: 1, perPage: 0, count: 0, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IReadOnlyList<ThemeResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
|
||||
|
||||
+7
-5
@@ -7,6 +7,7 @@ using Lumina.Application.Common.Infrastructure.Security;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Core.UsersManagement.Authentication.Commands.ChangePassword;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Fixtures.Core.UsersManagement.Authentication.Commands.ChangePassword;
|
||||
using Lumina.Contracts.Responses.Authentication;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using NSubstitute;
|
||||
@@ -29,6 +30,7 @@ public class ChangePasswordCommandHandlerTests
|
||||
private readonly IUserRepository _mockUserRepository;
|
||||
private readonly ChangePasswordCommandHandler _sut;
|
||||
private readonly UserEntityFixture _userEntityFixture = new();
|
||||
private readonly ChangePasswordCommandFixture _changePasswordCommandFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChangePasswordCommandHandlerTests"/> class.
|
||||
@@ -63,7 +65,7 @@ public class ChangePasswordCommandHandlerTests
|
||||
UserEntity user = _userEntityFixture.Create();
|
||||
user.Password = escapedHashedCurrentPassword;
|
||||
|
||||
ChangePasswordCommand command = new(
|
||||
ChangePasswordCommand command = _changePasswordCommandFixture.Create(
|
||||
user.Username,
|
||||
currentPassword,
|
||||
newPassword,
|
||||
@@ -96,7 +98,7 @@ public class ChangePasswordCommandHandlerTests
|
||||
public async Task HandleAsync_WhenUserDoesNotExist_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
ChangePasswordCommand command = new("nonexistentUser", "oldPass", "newPass", "newPass");
|
||||
ChangePasswordCommand command = _changePasswordCommandFixture.Create("nonexistentUser", "oldPass", "newPass", "newPass");
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(command.Username!, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(null));
|
||||
@@ -120,7 +122,7 @@ public class ChangePasswordCommandHandlerTests
|
||||
UserEntity user = _userEntityFixture.Create();
|
||||
string incorrectPassword = "wrongPassword";
|
||||
|
||||
ChangePasswordCommand command = new(
|
||||
ChangePasswordCommand command = _changePasswordCommandFixture.Create(
|
||||
user.Username,
|
||||
incorrectPassword,
|
||||
"newPass",
|
||||
@@ -156,7 +158,7 @@ public class ChangePasswordCommandHandlerTests
|
||||
UserEntity user = _userEntityFixture.Create();
|
||||
user.Password = escapedHashedCurrentPassword;
|
||||
|
||||
ChangePasswordCommand command = new(
|
||||
ChangePasswordCommand command = _changePasswordCommandFixture.Create(
|
||||
user.Username,
|
||||
currentPassword,
|
||||
newPassword,
|
||||
@@ -189,7 +191,7 @@ public class ChangePasswordCommandHandlerTests
|
||||
string currentPassword = "currentPassword";
|
||||
string newPassword = "newPassword";
|
||||
UserEntity user = _userEntityFixture.Create();
|
||||
ChangePasswordCommand command = new(
|
||||
ChangePasswordCommand command = _changePasswordCommandFixture.Create(
|
||||
user.Username,
|
||||
currentPassword,
|
||||
newPassword,
|
||||
|
||||
+10
-8
@@ -8,6 +8,7 @@ using Lumina.Application.Common.Infrastructure.Security;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Core.UsersManagement.Authentication.Commands.RecoverPassword;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Fixtures.Core.UsersManagement.Authentication.Commands.RecoverPassword;
|
||||
using Lumina.Contracts.Responses.Authentication;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using NSubstitute;
|
||||
@@ -32,6 +33,7 @@ public class RecoverPasswordCommandHandlerTests
|
||||
private readonly IUserRepository _mockUserRepository;
|
||||
private readonly RecoverPasswordCommandHandler _sut;
|
||||
private readonly UserEntityFixture _userEntityFixture = new();
|
||||
private readonly RecoverPasswordCommandFixture _recoverPasswordCommandFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CheckInitializationQueryHandlerTests"/> class.
|
||||
@@ -71,7 +73,7 @@ public class RecoverPasswordCommandHandlerTests
|
||||
user.TotpSecret = encryptedTotpSecret;
|
||||
user.TempPassword = null;
|
||||
|
||||
RecoverPasswordCommand command = new(user.Username, totpCode);
|
||||
RecoverPasswordCommand command = _recoverPasswordCommandFixture.Create(user.Username, totpCode);
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(user));
|
||||
@@ -102,7 +104,7 @@ public class RecoverPasswordCommandHandlerTests
|
||||
public async Task HandleAsync_WhenUserDoesNotExist_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
RecoverPasswordCommand command = new("nonexistentUser", "123456");
|
||||
RecoverPasswordCommand command = _recoverPasswordCommandFixture.Create("nonexistentUser", "123456");
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(command.Username!, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(null));
|
||||
@@ -127,7 +129,7 @@ public class RecoverPasswordCommandHandlerTests
|
||||
user.TempPassword = "existingTempPassword";
|
||||
user.TempPasswordCreated = DateTime.UtcNow;
|
||||
|
||||
RecoverPasswordCommand command = new(user.Username, "123456");
|
||||
RecoverPasswordCommand command = _recoverPasswordCommandFixture.Create(user.Username, "123456");
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(user));
|
||||
@@ -151,7 +153,7 @@ public class RecoverPasswordCommandHandlerTests
|
||||
UserEntity user = _userEntityFixture.Create();
|
||||
user.TotpSecret = null;
|
||||
|
||||
RecoverPasswordCommand command = new(user.Username, "123456");
|
||||
RecoverPasswordCommand command = _recoverPasswordCommandFixture.Create(user.Username, "123456");
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(user));
|
||||
@@ -179,7 +181,7 @@ public class RecoverPasswordCommandHandlerTests
|
||||
UserEntity user = _userEntityFixture.Create();
|
||||
user.TotpSecret = encryptedTotpSecret;
|
||||
|
||||
RecoverPasswordCommand command = new(user.Username, totpCode);
|
||||
RecoverPasswordCommand command = _recoverPasswordCommandFixture.Create(user.Username, totpCode);
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(user));
|
||||
@@ -213,7 +215,7 @@ public class RecoverPasswordCommandHandlerTests
|
||||
UserEntity user = _userEntityFixture.Create();
|
||||
user.TotpSecret = encryptedTotpSecret;
|
||||
|
||||
RecoverPasswordCommand command = new(user.Username, totpCode);
|
||||
RecoverPasswordCommand command = _recoverPasswordCommandFixture.Create(user.Username, totpCode);
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(user));
|
||||
@@ -247,7 +249,7 @@ public class RecoverPasswordCommandHandlerTests
|
||||
UserEntity user = _userEntityFixture.Create();
|
||||
user.TotpSecret = encryptedTotpSecret;
|
||||
|
||||
RecoverPasswordCommand command = new(user.Username, totpCode);
|
||||
RecoverPasswordCommand command = _recoverPasswordCommandFixture.Create(user.Username, totpCode);
|
||||
Error error = Error.Failure("Database.Error", "Failed to check username");
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(command.Username!, Arg.Any<CancellationToken>())
|
||||
@@ -274,7 +276,7 @@ public class RecoverPasswordCommandHandlerTests
|
||||
UserEntity user = _userEntityFixture.Create();
|
||||
user.TotpSecret = encryptedTotpSecret;
|
||||
|
||||
RecoverPasswordCommand command = new(user.Username, null);
|
||||
RecoverPasswordCommand command = _recoverPasswordCommandFixture.Create(user.Username, includeTotpCode: false);
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(user));
|
||||
|
||||
+3
-1
@@ -9,6 +9,7 @@ using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Core.UsersManagement.Authentication.Queries.GetUsers;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Core.UsersManagement.Authentication.Queries.GetUsers;
|
||||
using Lumina.Contracts.Responses.UsersManagement.Users;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -35,6 +36,7 @@ public class GetUsersQueryHandlerTests
|
||||
private readonly IUserRepository _mockUserRepository;
|
||||
private readonly GetUsersQueryHandler _sut;
|
||||
private readonly UserEntityFixture _userEntityFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<UserEntity> _paginatedResultDtoFixture = new();
|
||||
private readonly GetUsersQueryFixture _getUsersQueryFixture = new();
|
||||
private readonly Guid _userId;
|
||||
|
||||
@@ -124,7 +126,7 @@ public class GetUsersQueryHandlerTests
|
||||
_mockAuthorizationService.IsInRoleAsync(_userId, "Admin", Arg.Any<CancellationToken>())
|
||||
.Returns(true);
|
||||
_mockUserRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<UserEntity> { Data = users, CurrentPage = 1, PerPage = users.Count, Count = users.Count, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: users, currentPage: 1, perPage: users.Count, count: users.Count, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<UserResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
|
||||
|
||||
+12
-10
@@ -9,6 +9,7 @@ using Lumina.Application.Common.Infrastructure.Time;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Core.UsersManagement.Authentication.Queries.LoginUser;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Fixtures.Core.UsersManagement.Authentication.Queries.LoginUser;
|
||||
using Lumina.Contracts.Responses.Authentication;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using NSubstitute;
|
||||
@@ -35,6 +36,7 @@ public class LoginUserQueryHandlerTests
|
||||
private readonly IDateTimeProvider _mockDateTimeProvider;
|
||||
private readonly LoginUserQueryHandler _sut;
|
||||
private readonly UserEntityFixture _userEntityFixture = new();
|
||||
private readonly LoginUserQueryFixture _loginUserQueryFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LoginUserQueryHandlerTests"/> class.
|
||||
@@ -78,7 +80,7 @@ public class LoginUserQueryHandlerTests
|
||||
user.Password = Uri.EscapeDataString(hashedPassword);
|
||||
user.TotpSecret = null;
|
||||
|
||||
LoginUserQuery query = new(user.Username, password);
|
||||
LoginUserQuery query = _loginUserQueryFixture.Create(user.Username, password);
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(user));
|
||||
@@ -113,7 +115,7 @@ public class LoginUserQueryHandlerTests
|
||||
user.Password = Uri.EscapeDataString(hashedPassword);
|
||||
user.TotpSecret = encryptedTotpSecret;
|
||||
|
||||
LoginUserQuery query = new(user.Username, password, totpCode);
|
||||
LoginUserQuery query = _loginUserQueryFixture.Create(user.Username, password, totpCode: totpCode);
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(user));
|
||||
@@ -141,7 +143,7 @@ public class LoginUserQueryHandlerTests
|
||||
public async Task HandleAsync_WhenUserDoesNotExist_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
LoginUserQuery query = new("nonexistentUser", "password");
|
||||
LoginUserQuery query = _loginUserQueryFixture.Create("nonexistentUser", "password");
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(query.Username!, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(null));
|
||||
@@ -165,7 +167,7 @@ public class LoginUserQueryHandlerTests
|
||||
user.Password = Uri.EscapeDataString(hashedPassword);
|
||||
user.TempPassword = null;
|
||||
|
||||
LoginUserQuery query = new(user.Username, password);
|
||||
LoginUserQuery query = _loginUserQueryFixture.Create(user.Username, password);
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(user));
|
||||
@@ -193,7 +195,7 @@ public class LoginUserQueryHandlerTests
|
||||
user.TempPassword = Uri.EscapeDataString(hashedTempPassword);
|
||||
user.TempPasswordCreated = DateTime.UtcNow.AddMinutes(-16); // Expired (more than 15 minutes old)
|
||||
|
||||
LoginUserQuery query = new(user.Username, password);
|
||||
LoginUserQuery query = _loginUserQueryFixture.Create(user.Username, password);
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(user));
|
||||
@@ -231,7 +233,7 @@ public class LoginUserQueryHandlerTests
|
||||
user.TempPasswordCreated = DateTime.UtcNow.AddMinutes(-10);
|
||||
user.TotpSecret = null; // Ensure no TOTP validation is needed
|
||||
|
||||
LoginUserQuery query = new(user.Username, password);
|
||||
LoginUserQuery query = _loginUserQueryFixture.Create(user.Username, password);
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(user));
|
||||
@@ -265,7 +267,7 @@ public class LoginUserQueryHandlerTests
|
||||
user.Password = Uri.EscapeDataString(hashedPassword);
|
||||
user.TotpSecret = encryptedTotpSecret;
|
||||
|
||||
LoginUserQuery query = new(user.Username, password);
|
||||
LoginUserQuery query = _loginUserQueryFixture.Create(user.Username, password);
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(user));
|
||||
@@ -294,7 +296,7 @@ public class LoginUserQueryHandlerTests
|
||||
user.Password = Uri.EscapeDataString(hashedPassword);
|
||||
user.TotpSecret = encryptedTotpSecret;
|
||||
|
||||
LoginUserQuery query = new(user.Username, password, totpCode);
|
||||
LoginUserQuery query = _loginUserQueryFixture.Create(user.Username, password, totpCode: totpCode);
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(user));
|
||||
@@ -317,7 +319,7 @@ public class LoginUserQueryHandlerTests
|
||||
public async Task HandleAsync_WhenGetByUsernameReturnsError_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
LoginUserQuery query = new("username", "password");
|
||||
LoginUserQuery query = _loginUserQueryFixture.Create("username", "password");
|
||||
Error error = Error.Failure("Database.Error", "Failed to retrieve user");
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(query.Username!, Arg.Any<CancellationToken>())
|
||||
@@ -344,7 +346,7 @@ public class LoginUserQueryHandlerTests
|
||||
user.TempPassword = Uri.EscapeDataString(hashedTempPassword);
|
||||
user.TempPasswordCreated = DateTime.UtcNow.AddMinutes(-10); // Valid timeframe
|
||||
|
||||
LoginUserQuery query = new(user.Username, password);
|
||||
LoginUserQuery query = _loginUserQueryFixture.Create(user.Username, password);
|
||||
|
||||
_mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From<UserEntity?>(user));
|
||||
|
||||
+3
-1
@@ -12,6 +12,7 @@ using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Core.UsersManagement.Authorization.Commands.UpdateUserRoleAndPermissions;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Application.Fixtures.Core.UsersManagement.Authorization.Commands.UpdateUserRoleAndPermissions;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -49,6 +50,7 @@ public class UpdateUserRoleAndPermissionsCommandHandlerTests
|
||||
private readonly UserPermissionEntityFixture _userPermissionEntityFixture = new();
|
||||
private readonly UpdateUserRoleAndPermissionsCommandFixture _updateUserRoleAndPermissionsCommandFixture = new();
|
||||
private readonly PermissionEntityFixture _permissionEntityFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<UserEntity> _paginatedResultDtoFixture = new();
|
||||
private readonly Guid _userId;
|
||||
|
||||
/// <summary>
|
||||
@@ -180,7 +182,7 @@ public class UpdateUserRoleAndPermissionsCommandHandlerTests
|
||||
_mockRoleRepository.GetByIdAsync(command.RoleId!.Value, cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(newRole);
|
||||
_mockUserRepository.GetAllAsync<BaseFilterDto>(cancellationToken: Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new PaginatedResultDto<UserEntity> { Data = users, CurrentPage = 1, PerPage = users.Count, Count = users.Count, NumberOfPages = 1 }));
|
||||
.Returns(Result.From(_paginatedResultDtoFixture.Create(data: users, currentPage: 1, perPage: users.Count, count: users.Count, numberOfPages: 1)));
|
||||
|
||||
// Act
|
||||
Result<AuthorizationResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
|
||||
|
||||
+8
-6
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.UsersManagement.Authorization.Commands.UpdateUserRoleAndPermissions;
|
||||
using Lumina.Application.Fixtures.Core.UsersManagement.Authorization.Commands.UpdateUserRoleAndPermissions;
|
||||
using Lumina.Application.UnitTests.Common.Setup;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using System;
|
||||
@@ -18,12 +19,13 @@ namespace Lumina.Application.UnitTests.Core.UsersManagement.Authorization.Comman
|
||||
public class UpdateUserRoleAndPermissionsCommandValidatorTests
|
||||
{
|
||||
private readonly UpdateUserRoleAndPermissionsCommandValidator _validator = new();
|
||||
private readonly UpdateUserRoleAndPermissionsCommandFixture _updateUserRoleAndPermissionsCommandFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenUserIdIsEmpty_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
UpdateUserRoleAndPermissionsCommand command = new(
|
||||
UpdateUserRoleAndPermissionsCommand command = _updateUserRoleAndPermissionsCommandFixture.Create(
|
||||
Guid.Empty,
|
||||
Guid.NewGuid(),
|
||||
[Guid.NewGuid()]);
|
||||
@@ -39,7 +41,7 @@ public class UpdateUserRoleAndPermissionsCommandValidatorTests
|
||||
public void Validate_WhenPermissionsContainEmptyGuid_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
UpdateUserRoleAndPermissionsCommand command = new(
|
||||
UpdateUserRoleAndPermissionsCommand command = _updateUserRoleAndPermissionsCommandFixture.Create(
|
||||
Guid.NewGuid(),
|
||||
Guid.NewGuid(),
|
||||
[Guid.Empty, Guid.NewGuid()]);
|
||||
@@ -55,10 +57,10 @@ public class UpdateUserRoleAndPermissionsCommandValidatorTests
|
||||
public void Validate_WhenPermissionsIsNull_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
UpdateUserRoleAndPermissionsCommand command = new(
|
||||
UpdateUserRoleAndPermissionsCommand command = _updateUserRoleAndPermissionsCommandFixture.Create(
|
||||
Guid.NewGuid(),
|
||||
Guid.NewGuid(),
|
||||
null!);
|
||||
includePermissions: false);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(command);
|
||||
@@ -71,7 +73,7 @@ public class UpdateUserRoleAndPermissionsCommandValidatorTests
|
||||
public void Validate_WhenPermissionsIsEmpty_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
UpdateUserRoleAndPermissionsCommand command = new(
|
||||
UpdateUserRoleAndPermissionsCommand command = _updateUserRoleAndPermissionsCommandFixture.Create(
|
||||
Guid.NewGuid(),
|
||||
Guid.NewGuid(),
|
||||
[]);
|
||||
@@ -87,7 +89,7 @@ public class UpdateUserRoleAndPermissionsCommandValidatorTests
|
||||
public void Validate_WhenCommandIsValid_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
UpdateUserRoleAndPermissionsCommand command = new(
|
||||
UpdateUserRoleAndPermissionsCommand command = _updateUserRoleAndPermissionsCommandFixture.Create(
|
||||
Guid.NewGuid(),
|
||||
Guid.NewGuid(),
|
||||
[Guid.NewGuid()]);
|
||||
|
||||
+5
-3
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.UsersManagement.Authorization.Queries.GetUserPermissions;
|
||||
using Lumina.Application.Fixtures.Core.UsersManagement.Authorization.Queries.GetUserPermissions;
|
||||
using Lumina.Application.UnitTests.Common.Setup;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -17,12 +18,13 @@ namespace Lumina.Application.UnitTests.Core.UsersManagement.Authorization.Querie
|
||||
public class GetUserPermissionsQueryValidatorTests
|
||||
{
|
||||
private readonly GetUserPermissionsQueryValidator _validator = new();
|
||||
private readonly GetUserPermissionsQueryFixture _getUserPermissionsQueryFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenUserIdIsNull_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetUserPermissionsQuery query = new(null);
|
||||
GetUserPermissionsQuery query = _getUserPermissionsQueryFixture.Create(includeUserId: false);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
@@ -35,7 +37,7 @@ public class GetUserPermissionsQueryValidatorTests
|
||||
public void Validate_WhenUserIdIsEmpty_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetUserPermissionsQuery query = new(Guid.Empty);
|
||||
GetUserPermissionsQuery query = _getUserPermissionsQueryFixture.Create(Guid.Empty);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
@@ -48,7 +50,7 @@ public class GetUserPermissionsQueryValidatorTests
|
||||
public void Validate_WhenUserIdIsValid_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetUserPermissionsQuery query = new(Guid.NewGuid());
|
||||
GetUserPermissionsQuery query = _getUserPermissionsQueryFixture.Create(Guid.NewGuid());
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
|
||||
+5
-3
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.UsersManagement.Authorization.Queries.GetUserRole;
|
||||
using Lumina.Application.Fixtures.Core.UsersManagement.Authorization.Queries.GetUserRole;
|
||||
using Lumina.Application.UnitTests.Common.Setup;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -17,12 +18,13 @@ namespace Lumina.Application.UnitTests.Core.UsersManagement.Authorization.Querie
|
||||
public class GetUserRoleQueryValidatorTests
|
||||
{
|
||||
private readonly GetUserRoleQueryValidator _validator = new();
|
||||
private readonly GetUserRoleQueryFixture _getUserRoleQueryFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenUserIdIsNull_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetUserRoleQuery query = new(null);
|
||||
GetUserRoleQuery query = _getUserRoleQueryFixture.Create(includeUserId: false);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
@@ -35,7 +37,7 @@ public class GetUserRoleQueryValidatorTests
|
||||
public void Validate_WhenUserIdIsEmpty_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetUserRoleQuery query = new(Guid.Empty);
|
||||
GetUserRoleQuery query = _getUserRoleQueryFixture.Create(Guid.Empty);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
@@ -48,7 +50,7 @@ public class GetUserRoleQueryValidatorTests
|
||||
public void Validate_WhenUserIdIsValid_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
GetUserRoleQuery query = new(Guid.NewGuid());
|
||||
GetUserRoleQuery query = _getUserRoleQueryFixture.Create(Guid.NewGuid());
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(query);
|
||||
|
||||
Reference in new issue
Block a user