mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 07: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
+12
-4
@@ -14,13 +14,13 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Authentication;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ChangePasswordRequestMappingTests
|
||||
{
|
||||
private readonly ChangePasswordRequestFixture _fixture = new();
|
||||
private readonly ChangePasswordRequestFixture _changePasswordRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToCommand_WhenMappingRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
ChangePasswordRequest request = _fixture.Create();
|
||||
ChangePasswordRequest request = _changePasswordRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
ChangePasswordCommand result = request.ToCommand();
|
||||
@@ -37,7 +37,7 @@ public class ChangePasswordRequestMappingTests
|
||||
public void ToCommand_WhenMappingRequestWithNullValues_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
ChangePasswordRequest request = new(null, null, null, null);
|
||||
ChangePasswordRequest request = _changePasswordRequestFixture.Create(includeUsername: false, includeCurrentPassword: false, includeNewPassword: false, includeNewPasswordConfirm: false);
|
||||
|
||||
// Act
|
||||
ChangePasswordCommand result = request.ToCommand();
|
||||
@@ -61,7 +61,15 @@ public class ChangePasswordRequestMappingTests
|
||||
string? newPasswordConfirm)
|
||||
{
|
||||
// Arrange
|
||||
ChangePasswordRequest request = new(username, currentPassword, newPassword, newPasswordConfirm);
|
||||
ChangePasswordRequest request = _changePasswordRequestFixture.Create(
|
||||
username,
|
||||
currentPassword,
|
||||
newPassword,
|
||||
newPasswordConfirm,
|
||||
includeUsername: username is not null,
|
||||
includeCurrentPassword: currentPassword is not null,
|
||||
includeNewPassword: newPassword is not null,
|
||||
includeNewPasswordConfirm: newPasswordConfirm is not null);
|
||||
|
||||
// Act
|
||||
ChangePasswordCommand result = request.ToCommand();
|
||||
|
||||
+10
-4
@@ -14,13 +14,13 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Authentication;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LoginRequestMappingTests
|
||||
{
|
||||
private readonly LoginRequestFixture _fixture = new();
|
||||
private readonly LoginRequestFixture _loginRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
LoginRequest request = _fixture.Create();
|
||||
LoginRequest request = _loginRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
LoginUserQuery result = request.ToQuery();
|
||||
@@ -36,7 +36,7 @@ public class LoginRequestMappingTests
|
||||
public void ToQuery_WhenMappingRequestWithNullValues_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
LoginRequest request = new(null, null);
|
||||
LoginRequest request = _loginRequestFixture.Create(includeUsername: false, includePassword: false, includeTotpCode: false);
|
||||
|
||||
// Act
|
||||
LoginUserQuery result = request.ToQuery();
|
||||
@@ -59,7 +59,13 @@ public class LoginRequestMappingTests
|
||||
string? totpCode)
|
||||
{
|
||||
// Arrange
|
||||
LoginRequest request = new(username, password, totpCode);
|
||||
LoginRequest request = _loginRequestFixture.Create(
|
||||
username,
|
||||
password,
|
||||
totpCode,
|
||||
includeUsername: username is not null,
|
||||
includePassword: password is not null,
|
||||
includeTotpCode: totpCode is not null);
|
||||
|
||||
// Act
|
||||
LoginUserQuery result = request.ToQuery();
|
||||
|
||||
+8
-4
@@ -14,13 +14,13 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Authentication;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RecoverPasswordRequestMappingTests
|
||||
{
|
||||
private readonly RecoverPasswordRequestFixture _fixture = new();
|
||||
private readonly RecoverPasswordRequestFixture _recoverPasswordRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToCommand_WhenMappingRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
RecoverPasswordRequest request = _fixture.Create();
|
||||
RecoverPasswordRequest request = _recoverPasswordRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
RecoverPasswordCommand result = request.ToCommand();
|
||||
@@ -35,7 +35,7 @@ public class RecoverPasswordRequestMappingTests
|
||||
public void ToCommand_WhenMappingRequestWithNullValues_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
RecoverPasswordRequest request = new(null, null);
|
||||
RecoverPasswordRequest request = _recoverPasswordRequestFixture.Create(includeUsername: false, includeTotpCode: false);
|
||||
|
||||
// Act
|
||||
RecoverPasswordCommand result = request.ToCommand();
|
||||
@@ -56,7 +56,11 @@ public class RecoverPasswordRequestMappingTests
|
||||
string? totpCode)
|
||||
{
|
||||
// Arrange
|
||||
RecoverPasswordRequest request = new(username, totpCode);
|
||||
RecoverPasswordRequest request = _recoverPasswordRequestFixture.Create(
|
||||
username,
|
||||
totpCode,
|
||||
includeUsername: username is not null,
|
||||
includeTotpCode: totpCode is not null);
|
||||
|
||||
// Act
|
||||
RecoverPasswordCommand result = request.ToCommand();
|
||||
|
||||
+21
-7
@@ -15,13 +15,13 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Authentication;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RegistrationRequestMappingTests
|
||||
{
|
||||
private readonly RegistrationRequestFixture _fixture = new();
|
||||
private readonly RegistrationRequestFixture _registrationRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToSetupCommand_WhenMappingRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
RegistrationRequest request = _fixture.Create();
|
||||
RegistrationRequest request = _registrationRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
SetupApplicationCommand result = request.ToSetupCommand();
|
||||
@@ -38,7 +38,7 @@ public class RegistrationRequestMappingTests
|
||||
public void ToCommand_WhenMappingRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
RegistrationRequest request = _fixture.Create();
|
||||
RegistrationRequest request = _registrationRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
RegisterUserCommand result = request.ToCommand();
|
||||
@@ -55,7 +55,7 @@ public class RegistrationRequestMappingTests
|
||||
public void ToSetupCommand_WhenMappingRequestWithNullValues_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
RegistrationRequest request = new();
|
||||
RegistrationRequest request = _registrationRequestFixture.Create(includeUsername: false, includePassword: false, includePasswordConfirm: false, use2fa: true);
|
||||
|
||||
// Act
|
||||
SetupApplicationCommand result = request.ToSetupCommand();
|
||||
@@ -72,7 +72,7 @@ public class RegistrationRequestMappingTests
|
||||
public void ToCommand_WhenMappingRequestWithNullValues_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
RegistrationRequest request = new();
|
||||
RegistrationRequest request = _registrationRequestFixture.Create(includeUsername: false, includePassword: false, includePasswordConfirm: false, use2fa: true);
|
||||
|
||||
// Act
|
||||
RegisterUserCommand result = request.ToCommand();
|
||||
@@ -97,7 +97,14 @@ public class RegistrationRequestMappingTests
|
||||
bool use2fa)
|
||||
{
|
||||
// Arrange
|
||||
RegistrationRequest request = new(username, password, passwordConfirm, use2fa);
|
||||
RegistrationRequest request = _registrationRequestFixture.Create(
|
||||
username,
|
||||
password,
|
||||
passwordConfirm,
|
||||
use2fa,
|
||||
includeUsername: username is not null,
|
||||
includePassword: password is not null,
|
||||
includePasswordConfirm: passwordConfirm is not null);
|
||||
|
||||
// Act
|
||||
SetupApplicationCommand result = request.ToSetupCommand();
|
||||
@@ -122,7 +129,14 @@ public class RegistrationRequestMappingTests
|
||||
bool use2fa)
|
||||
{
|
||||
// Arrange
|
||||
RegistrationRequest request = new(username, password, passwordConfirm, use2fa);
|
||||
RegistrationRequest request = _registrationRequestFixture.Create(
|
||||
username,
|
||||
password,
|
||||
passwordConfirm,
|
||||
use2fa,
|
||||
includeUsername: username is not null,
|
||||
includePassword: password is not null,
|
||||
includePasswordConfirm: passwordConfirm is not null);
|
||||
|
||||
// Act
|
||||
RegisterUserCommand result = request.ToCommand();
|
||||
|
||||
+7
-4
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Authorization;
|
||||
using Lumina.Application.Core.Admin.Authorization.Roles.Commands.AddRole;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -15,11 +16,13 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Authorization;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddRoleRequestMappingTests
|
||||
{
|
||||
private readonly AddRoleRequestFixture _addRoleRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
AddRoleRequest request = new(
|
||||
AddRoleRequest request = _addRoleRequestFixture.Create(
|
||||
"Admin",
|
||||
[Guid.NewGuid(), Guid.NewGuid()]
|
||||
);
|
||||
@@ -37,7 +40,7 @@ public class AddRoleRequestMappingTests
|
||||
public void ToCommand_WhenMappingRequestWithEmptyPermissions_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
AddRoleRequest request = new(
|
||||
AddRoleRequest request = _addRoleRequestFixture.Create(
|
||||
"Guest",
|
||||
[]
|
||||
);
|
||||
@@ -58,7 +61,7 @@ public class AddRoleRequestMappingTests
|
||||
public void ToCommand_WhenMappingDifferentRoleNames_ShouldMapCorrectly(string roleName)
|
||||
{
|
||||
// Arrange
|
||||
AddRoleRequest request = new(
|
||||
AddRoleRequest request = _addRoleRequestFixture.Create(
|
||||
roleName,
|
||||
[Guid.NewGuid()]
|
||||
);
|
||||
@@ -82,7 +85,7 @@ public class AddRoleRequestMappingTests
|
||||
Guid.Parse("00000000-0000-0000-0000-000000000002"),
|
||||
Guid.Parse("00000000-0000-0000-0000-000000000003")
|
||||
];
|
||||
AddRoleRequest request = new("SuperAdmin", permissions);
|
||||
AddRoleRequest request = _addRoleRequestFixture.Create("SuperAdmin", permissions);
|
||||
|
||||
// Act
|
||||
AddRoleCommand result = request.ToCommand();
|
||||
|
||||
+7
-4
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Authorization;
|
||||
using Lumina.Application.Core.Admin.Authorization.Roles.Commands.DeleteRole;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -14,12 +15,14 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Authorization;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeleteRoleRequestMappingTests
|
||||
{
|
||||
private readonly DeleteRoleRequestFixture _deleteRoleRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
Guid roleId = Guid.NewGuid();
|
||||
DeleteRoleRequest request = new(roleId);
|
||||
DeleteRoleRequest request = _deleteRoleRequestFixture.Create(roleId);
|
||||
|
||||
// Act
|
||||
DeleteRoleCommand result = request.ToCommand();
|
||||
@@ -37,7 +40,7 @@ public class DeleteRoleRequestMappingTests
|
||||
{
|
||||
// Arrange
|
||||
Guid roleId = Guid.Parse(roleIdString);
|
||||
DeleteRoleRequest request = new(roleId);
|
||||
DeleteRoleRequest request = _deleteRoleRequestFixture.Create(roleId);
|
||||
|
||||
// Act
|
||||
DeleteRoleCommand result = request.ToCommand();
|
||||
@@ -51,7 +54,7 @@ public class DeleteRoleRequestMappingTests
|
||||
public void ToCommand_WhenRoleIdIsNull_ShouldThrowInvalidOperationException()
|
||||
{
|
||||
// Arrange
|
||||
DeleteRoleRequest request = new(null);
|
||||
DeleteRoleRequest request = _deleteRoleRequestFixture.Create(includeRoleId: false);
|
||||
|
||||
// Act & Assert
|
||||
Assert.Throws<InvalidOperationException>(() => request.ToCommand());
|
||||
@@ -61,7 +64,7 @@ public class DeleteRoleRequestMappingTests
|
||||
public void ToCommand_WhenMappingEmptyGuid_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
DeleteRoleRequest request = new(Guid.Empty);
|
||||
DeleteRoleRequest request = _deleteRoleRequestFixture.Create(Guid.Empty);
|
||||
|
||||
// Act
|
||||
DeleteRoleCommand result = request.ToCommand();
|
||||
|
||||
+6
-3
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Authorization;
|
||||
using Lumina.Application.Core.UsersManagement.Authorization.Queries.GetAuthorization;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -14,12 +15,14 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Authorization;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetAuthorizationRequestMappingTests
|
||||
{
|
||||
private readonly GetAuthorizationRequestFixture _getAuthorizationRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingValidRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
Guid userId = Guid.NewGuid();
|
||||
GetAuthorizationRequest request = new(userId);
|
||||
GetAuthorizationRequest request = _getAuthorizationRequestFixture.Create(userId);
|
||||
|
||||
// Act
|
||||
GetAuthorizationQuery result = request.ToQuery();
|
||||
@@ -33,7 +36,7 @@ public class GetAuthorizationRequestMappingTests
|
||||
public void ToQuery_WhenUserIdIsNull_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetAuthorizationRequest request = new(null);
|
||||
GetAuthorizationRequest request = _getAuthorizationRequestFixture.Create(includeUserId: false);
|
||||
|
||||
// Act
|
||||
GetAuthorizationQuery result = request.ToQuery();
|
||||
@@ -51,7 +54,7 @@ public class GetAuthorizationRequestMappingTests
|
||||
{
|
||||
// Arrange
|
||||
Guid userId = Guid.Parse(userIdString);
|
||||
GetAuthorizationRequest request = new(userId);
|
||||
GetAuthorizationRequest request = _getAuthorizationRequestFixture.Create(userId);
|
||||
|
||||
// Act
|
||||
GetAuthorizationQuery result = request.ToQuery();
|
||||
|
||||
+6
-3
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Authorization;
|
||||
using Lumina.Application.Core.Admin.Authorization.Roles.Queries.GetRolePermissions;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -14,12 +15,14 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Authorization;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetRolePermissionsRequestMappingTests
|
||||
{
|
||||
private readonly GetRolePermissionsRequestFixture _getRolePermissionsRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingValidRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
Guid roleId = Guid.NewGuid();
|
||||
GetRolePermissionsRequest request = new(roleId);
|
||||
GetRolePermissionsRequest request = _getRolePermissionsRequestFixture.Create(roleId);
|
||||
|
||||
// Act
|
||||
GetRolePermissionsQuery result = request.ToQuery();
|
||||
@@ -37,7 +40,7 @@ public class GetRolePermissionsRequestMappingTests
|
||||
{
|
||||
// Arrange
|
||||
Guid roleId = Guid.Parse(roleIdString);
|
||||
GetRolePermissionsRequest request = new(roleId);
|
||||
GetRolePermissionsRequest request = _getRolePermissionsRequestFixture.Create(roleId);
|
||||
|
||||
// Act
|
||||
GetRolePermissionsQuery result = request.ToQuery();
|
||||
@@ -51,7 +54,7 @@ public class GetRolePermissionsRequestMappingTests
|
||||
public void ToQuery_WhenMappingEmptyGuid_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetRolePermissionsRequest request = new(Guid.Empty);
|
||||
GetRolePermissionsRequest request = _getRolePermissionsRequestFixture.Create(Guid.Empty);
|
||||
|
||||
// Act
|
||||
GetRolePermissionsQuery result = request.ToQuery();
|
||||
|
||||
+7
-4
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Authorization;
|
||||
using Lumina.Application.Core.UsersManagement.Authorization.Queries.GetUserPermissions;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -14,12 +15,14 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Authorization;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetUserPermissionsRequestMappingTests
|
||||
{
|
||||
private readonly GetUserPermissionsRequestFixture _getUserPermissionsRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingValidRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
Guid userId = Guid.NewGuid();
|
||||
GetUserPermissionsRequest request = new(userId);
|
||||
GetUserPermissionsRequest request = _getUserPermissionsRequestFixture.Create(userId);
|
||||
|
||||
// Act
|
||||
GetUserPermissionsQuery result = request.ToQuery();
|
||||
@@ -33,7 +36,7 @@ public class GetUserPermissionsRequestMappingTests
|
||||
public void ToQuery_WhenUserIdIsNull_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetUserPermissionsRequest request = new(null);
|
||||
GetUserPermissionsRequest request = _getUserPermissionsRequestFixture.Create(includeUserId: false);
|
||||
|
||||
// Act
|
||||
GetUserPermissionsQuery result = request.ToQuery();
|
||||
@@ -51,7 +54,7 @@ public class GetUserPermissionsRequestMappingTests
|
||||
{
|
||||
// Arrange
|
||||
Guid userId = Guid.Parse(userIdString);
|
||||
GetUserPermissionsRequest request = new(userId);
|
||||
GetUserPermissionsRequest request = _getUserPermissionsRequestFixture.Create(userId);
|
||||
|
||||
// Act
|
||||
GetUserPermissionsQuery result = request.ToQuery();
|
||||
@@ -65,7 +68,7 @@ public class GetUserPermissionsRequestMappingTests
|
||||
public void ToQuery_WhenMappingEmptyGuid_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetUserPermissionsRequest request = new(Guid.Empty);
|
||||
GetUserPermissionsRequest request = _getUserPermissionsRequestFixture.Create(Guid.Empty);
|
||||
|
||||
// Act
|
||||
GetUserPermissionsQuery result = request.ToQuery();
|
||||
|
||||
+7
-4
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Authorization;
|
||||
using Lumina.Application.Core.UsersManagement.Authorization.Queries.GetUserRole;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -14,12 +15,14 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Authorization;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetUserRoleRequestMappingTests
|
||||
{
|
||||
private readonly GetUserRoleRequestFixture _getUserRoleRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingValidRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
Guid userId = Guid.NewGuid();
|
||||
GetUserRoleRequest request = new(userId);
|
||||
GetUserRoleRequest request = _getUserRoleRequestFixture.Create(userId);
|
||||
|
||||
// Act
|
||||
GetUserRoleQuery result = request.ToQuery();
|
||||
@@ -33,7 +36,7 @@ public class GetUserRoleRequestMappingTests
|
||||
public void ToQuery_WhenUserIdIsNull_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetUserRoleRequest request = new(null);
|
||||
GetUserRoleRequest request = _getUserRoleRequestFixture.Create(includeUserId: false);
|
||||
|
||||
// Act
|
||||
GetUserRoleQuery result = request.ToQuery();
|
||||
@@ -51,7 +54,7 @@ public class GetUserRoleRequestMappingTests
|
||||
{
|
||||
// Arrange
|
||||
Guid userId = Guid.Parse(userIdString);
|
||||
GetUserRoleRequest request = new(userId);
|
||||
GetUserRoleRequest request = _getUserRoleRequestFixture.Create(userId);
|
||||
|
||||
// Act
|
||||
GetUserRoleQuery result = request.ToQuery();
|
||||
@@ -65,7 +68,7 @@ public class GetUserRoleRequestMappingTests
|
||||
public void ToQuery_WhenMappingEmptyGuid_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetUserRoleRequest request = new(Guid.Empty);
|
||||
GetUserRoleRequest request = _getUserRoleRequestFixture.Create(Guid.Empty);
|
||||
|
||||
// Act
|
||||
GetUserRoleQuery result = request.ToQuery();
|
||||
|
||||
+7
-4
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Authorization;
|
||||
using Lumina.Application.Core.Admin.Authorization.Roles.Commands.UpdateRole;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -15,12 +16,14 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Authorization;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdateRoleRequestMappingTests
|
||||
{
|
||||
private readonly UpdateRoleRequestFixture _updateRoleRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<Guid> permissions = [Guid.NewGuid(), Guid.NewGuid()];
|
||||
UpdateRoleRequest request = new(
|
||||
UpdateRoleRequest request = _updateRoleRequestFixture.Create(
|
||||
Guid.NewGuid(),
|
||||
"Admin",
|
||||
permissions
|
||||
@@ -43,7 +46,7 @@ public class UpdateRoleRequestMappingTests
|
||||
public void ToCommand_WhenMappingDifferentRoleNames_ShouldMapCorrectly(string roleName)
|
||||
{
|
||||
// Arrange
|
||||
UpdateRoleRequest request = new(
|
||||
UpdateRoleRequest request = _updateRoleRequestFixture.Create(
|
||||
Guid.NewGuid(),
|
||||
roleName,
|
||||
[Guid.NewGuid()]
|
||||
@@ -64,7 +67,7 @@ public class UpdateRoleRequestMappingTests
|
||||
public void ToCommand_WhenMappingDifferentRoleIds_ShouldMapCorrectly(string roleIdString)
|
||||
{
|
||||
// Arrange
|
||||
UpdateRoleRequest request = new(
|
||||
UpdateRoleRequest request = _updateRoleRequestFixture.Create(
|
||||
Guid.Parse(roleIdString),
|
||||
"Admin",
|
||||
[Guid.NewGuid()]
|
||||
@@ -88,7 +91,7 @@ public class UpdateRoleRequestMappingTests
|
||||
Guid.Parse("00000000-0000-0000-0000-000000000002"),
|
||||
Guid.Parse("00000000-0000-0000-0000-000000000003")
|
||||
];
|
||||
UpdateRoleRequest request = new(Guid.NewGuid(), "Admin", permissions);
|
||||
UpdateRoleRequest request = _updateRoleRequestFixture.Create(Guid.NewGuid(), "Admin", permissions);
|
||||
|
||||
// Act
|
||||
UpdateRoleCommand result = request.ToCommand();
|
||||
|
||||
+10
-6
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Authorization;
|
||||
using Lumina.Application.Core.UsersManagement.Authorization.Commands.UpdateUserRoleAndPermissions;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -15,12 +16,14 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Authorization;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdateUserRoleAndPermissionsRequestMappingTests
|
||||
{
|
||||
private readonly UpdateUserRoleAndPermissionsRequestFixture _updateUserRoleAndPermissionsRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<Guid> permissions = [Guid.NewGuid()];
|
||||
UpdateUserRoleAndPermissionsRequest request = new(
|
||||
UpdateUserRoleAndPermissionsRequest request = _updateUserRoleAndPermissionsRequestFixture.Create(
|
||||
Guid.NewGuid(),
|
||||
Guid.NewGuid(),
|
||||
permissions
|
||||
@@ -41,10 +44,11 @@ public class UpdateUserRoleAndPermissionsRequestMappingTests
|
||||
{
|
||||
// Arrange
|
||||
List<Guid> permissions = [Guid.NewGuid()];
|
||||
UpdateUserRoleAndPermissionsRequest request = new(
|
||||
UpdateUserRoleAndPermissionsRequest request = _updateUserRoleAndPermissionsRequestFixture.Create(
|
||||
Guid.NewGuid(),
|
||||
null,
|
||||
permissions
|
||||
roleId: null,
|
||||
permissions: permissions,
|
||||
includeRoleId: false
|
||||
);
|
||||
|
||||
// Act
|
||||
@@ -64,7 +68,7 @@ public class UpdateUserRoleAndPermissionsRequestMappingTests
|
||||
public void ToCommand_WhenMappingDifferentUserIds_ShouldMapCorrectly(string userIdString)
|
||||
{
|
||||
// Arrange
|
||||
UpdateUserRoleAndPermissionsRequest request = new(
|
||||
UpdateUserRoleAndPermissionsRequest request = _updateUserRoleAndPermissionsRequestFixture.Create(
|
||||
Guid.Parse(userIdString),
|
||||
Guid.NewGuid(),
|
||||
[Guid.NewGuid()]
|
||||
@@ -88,7 +92,7 @@ public class UpdateUserRoleAndPermissionsRequestMappingTests
|
||||
Guid.Parse("00000000-0000-0000-0000-000000000002"),
|
||||
Guid.Parse("00000000-0000-0000-0000-000000000003")
|
||||
];
|
||||
UpdateUserRoleAndPermissionsRequest request = new(
|
||||
UpdateUserRoleAndPermissionsRequest request = _updateUserRoleAndPermissionsRequestFixture.Create(
|
||||
Guid.NewGuid(),
|
||||
Guid.NewGuid(),
|
||||
permissions
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class CheckPathExistsRequestMappingTests
|
||||
public void ToQuery_WhenMappingWithDifferentPathsAndHiddenElementsFlag_ShouldMapCorrectly(string path, bool shouldIncludeHiddenElements)
|
||||
{
|
||||
// Arrange
|
||||
CheckPathExistsRequest request = new(path, shouldIncludeHiddenElements);
|
||||
CheckPathExistsRequest request = _checkPathExistsRequestFixture.Create(path, shouldIncludeHiddenElements);
|
||||
|
||||
// Act
|
||||
CheckPathExistsQuery result = request.ToQuery();
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class CombinePathRequestMappingTests
|
||||
public void ToCommand_WhenMappingWithDifferentPaths_ShouldMapCorrectly(string originalPath, string newPath)
|
||||
{
|
||||
// Arrange
|
||||
CombinePathRequest request = new(originalPath, newPath);
|
||||
CombinePathRequest request = _combinePathRequestFixture.Create(originalPath, newPath);
|
||||
|
||||
// Act
|
||||
CombinePathCommand result = request.ToCommand();
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class GetPathParentRequestMappingTests
|
||||
public void ToQuery_WhenMappingWithDifferentPaths_ShouldMapCorrectly(string path)
|
||||
{
|
||||
// Arrange
|
||||
GetPathParentRequest request = new(path);
|
||||
GetPathParentRequest request = _getPathParentRequestFixture.Create(path);
|
||||
|
||||
// Act
|
||||
GetPathParentQuery result = request.ToQuery();
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class GetPathRootRequestMappingTests
|
||||
public void ToQuery_WhenMappingWithDifferentPaths_ShouldMapCorrectly(string path)
|
||||
{
|
||||
// Arrange
|
||||
GetPathRootRequest request = new(path);
|
||||
GetPathRootRequest request = _getPathRootRequestFixture.Create(path);
|
||||
|
||||
// Act
|
||||
GetPathRootQuery result = request.ToQuery();
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class SplitPathRequestMappingTests
|
||||
public void ToCommand_WhenMappingWithDifferentPaths_ShouldMapCorrectly(string path)
|
||||
{
|
||||
// Arrange
|
||||
SplitPathRequest request = new(path);
|
||||
SplitPathRequest request = _splitPathRequestFixture.Create(path);
|
||||
|
||||
// Act
|
||||
SplitPathCommand result = request.ToCommand();
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public class ValidatePathRequestMappingTests
|
||||
public void ToQuery_WhenMappingWithDifferentPaths_ShouldMapCorrectly(string path)
|
||||
{
|
||||
// Arrange
|
||||
ValidatePathRequest request = new(path);
|
||||
ValidatePathRequest request = _validatePathRequestFixture.Create(path);
|
||||
|
||||
// Act
|
||||
ValidatePathQuery result = request.ToQuery();
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class GetThumbnailRequestMappingTests
|
||||
public void ToQuery_WhenMappingWithDifferentPathsAndQualities_ShouldMapCorrectly(string path, int quality)
|
||||
{
|
||||
// Arrange
|
||||
GetThumbnailRequest request = new(path, quality);
|
||||
GetThumbnailRequest request = _getThumbnailRequestFixture.Create(path, quality);
|
||||
|
||||
// Act
|
||||
GetThumbnailQuery result = request.ToQuery();
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ public class ThumbnailMappingTests
|
||||
{
|
||||
// Arrange
|
||||
byte[] bytes = [.. _fixture.CreateMany<byte>(100)];
|
||||
Thumbnail domainModel = new(imageType, bytes);
|
||||
Thumbnail domainModel = _thumbnailFixture.Create(imageType, bytes);
|
||||
|
||||
// Act
|
||||
ThumbnailResponse result = domainModel.ToResponse();
|
||||
@@ -70,7 +70,7 @@ public class ThumbnailMappingTests
|
||||
// Arrange
|
||||
ImageType imageType = _fixture.Create<ImageType>();
|
||||
byte[] emptyBytes = [];
|
||||
Thumbnail domainModel = new(imageType, emptyBytes);
|
||||
Thumbnail domainModel = _thumbnailFixture.Create(imageType, emptyBytes);
|
||||
|
||||
// Act
|
||||
ThumbnailResponse result = domainModel.ToResponse();
|
||||
|
||||
+15
-10
@@ -6,6 +6,8 @@ using Lumina.Application.Fixtures.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -29,6 +31,9 @@ public class AlbumEntityMappingTests
|
||||
private readonly GenreEntityFixture _genreEntityFixture = new();
|
||||
private readonly TagEntityFixture _tagEntityFixture = new();
|
||||
private readonly AudioRatingEntityFixture _audioRatingEntityFixture = new();
|
||||
private readonly TrackIsrcEntityFixture _trackIsrcEntityFixture = new();
|
||||
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
|
||||
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToDomainEntity_WhenMappingValidAlbumEntity_ShouldMapAllPropertiesCorrectly()
|
||||
@@ -64,13 +69,13 @@ public class AlbumEntityMappingTests
|
||||
Assert.Equal(entity.OriginalLanguageCode!.ToLowerInvariant(), album.Metadata.OriginalLanguage.Value.LanguageCode);
|
||||
Assert.Equal(entity.OriginalLanguageName, album.Metadata.OriginalLanguage.Value.LanguageName);
|
||||
Assert.Equal(entity.OriginalLanguageNativeName, album.Metadata.OriginalLanguage.Value.NativeName.Value);
|
||||
Assert.Equal(entity.ReleaseType, album.Metadata.ReleaseType.Value);
|
||||
Assert.Equal(entity.ReleaseTypes.Select(releaseType => releaseType.ReleaseType), album.Metadata.ReleaseTypes);
|
||||
Assert.Equal(entity.ReleaseStatus, album.Metadata.ReleaseStatus.Value);
|
||||
Assert.Equal(entity.TotalDiscs, album.Metadata.TotalDiscs.Value);
|
||||
Assert.Equal(entity.TotalTracks, album.Metadata.TotalTracks);
|
||||
Assert.Equal(entity.MediaFormat, album.MediaFormat.Value);
|
||||
Assert.Equal(entity.Barcode, album.Barcode.Value.Value);
|
||||
Assert.Equal(entity.CatalogNumber, album.CatalogNumber.Value);
|
||||
Assert.Equal(entity.CatalogNumbers.Select(catalogNumber => catalogNumber.CatalogNumber), album.CatalogNumbers);
|
||||
Assert.Equal(entity.MusicBrainzReleaseId, album.MusicBrainzReleaseId.Value.Value);
|
||||
Assert.Equal(entity.MusicBrainzReleaseGroupId, album.MusicBrainzReleaseGroupId.Value.Value);
|
||||
Assert.Equal(entity.MusicBrainzReleaseArtistId, album.MusicBrainzReleaseArtistId.Value.Value);
|
||||
@@ -102,7 +107,7 @@ public class AlbumEntityMappingTests
|
||||
includeReleaseStatus: false,
|
||||
includeTotalDiscs: false,
|
||||
includeMediaFormat: false,
|
||||
includeCatalogNumber: false,
|
||||
includeCatalogNumbers: false,
|
||||
includeMusicBrainzReleaseId: false,
|
||||
includeMusicBrainzReleaseGroupId: false,
|
||||
includeMusicBrainzReleaseArtistId: false);
|
||||
@@ -123,12 +128,12 @@ public class AlbumEntityMappingTests
|
||||
Assert.Empty(album.Metadata.Tags);
|
||||
Assert.False(album.Metadata.Language.HasValue);
|
||||
Assert.False(album.Metadata.OriginalLanguage.HasValue);
|
||||
Assert.False(album.Metadata.ReleaseType.HasValue);
|
||||
Assert.Empty(album.Metadata.ReleaseTypes);
|
||||
Assert.False(album.Metadata.ReleaseStatus.HasValue);
|
||||
Assert.False(album.Metadata.TotalDiscs.HasValue);
|
||||
Assert.False(album.MediaFormat.HasValue);
|
||||
Assert.False(album.Barcode.HasValue);
|
||||
Assert.False(album.CatalogNumber.HasValue);
|
||||
Assert.Empty(album.CatalogNumbers);
|
||||
Assert.False(album.MusicBrainzReleaseId.HasValue);
|
||||
Assert.False(album.MusicBrainzReleaseGroupId.HasValue);
|
||||
Assert.False(album.MusicBrainzReleaseArtistId.HasValue);
|
||||
@@ -231,7 +236,7 @@ public class AlbumEntityMappingTests
|
||||
{
|
||||
// Arrange
|
||||
TrackEntity trackEntity = _trackEntityFixture.Create();
|
||||
trackEntity.Isrcs = [new TrackIsrcEntity("not-an-isrc")];
|
||||
trackEntity.Isrcs = [_trackIsrcEntityFixture.Create(value: "not-an-isrc")];
|
||||
AlbumEntity entity = _albumEntityFixture.Create(tracks: [trackEntity]);
|
||||
|
||||
// Act
|
||||
@@ -275,20 +280,20 @@ public class AlbumEntityMappingTests
|
||||
Assert.Equal(entity.OriginalLanguageNativeName, result.Metadata.OriginalLanguage.NativeName);
|
||||
Assert.Equal(entity.Tags.Select(tag => tag.Name).OrderBy(name => name), result.Metadata.Tags!.Select(tag => tag.Name).OrderBy(name => name));
|
||||
Assert.Equal(entity.Genres.Select(genre => genre.Name).OrderBy(name => name), result.Metadata.Genres!.Select(genre => genre.Name).OrderBy(name => name));
|
||||
Assert.Equal(entity.ReleaseType, result.Metadata.ReleaseType);
|
||||
Assert.Equal(entity.ReleaseTypes.Select(releaseType => releaseType.ReleaseType), result.Metadata.ReleaseTypes);
|
||||
Assert.Equal(entity.ReleaseStatus, result.Metadata.ReleaseStatus);
|
||||
Assert.Equal(entity.TotalDiscs, result.Metadata.TotalDiscs);
|
||||
Assert.Equal(entity.TotalTracks, result.Metadata.TotalTracks);
|
||||
Assert.Equal(entity.MediaFormat, result.MediaFormat);
|
||||
Assert.Equal(entity.Barcode, result.Barcode);
|
||||
Assert.Equal(entity.CatalogNumber, result.CatalogNumber);
|
||||
Assert.Equal(entity.CatalogNumbers.Select(catalogNumber => catalogNumber.CatalogNumber), result.CatalogNumbers);
|
||||
Assert.Equal(entity.MusicBrainzReleaseId, result.MusicBrainzReleaseId);
|
||||
Assert.Equal(entity.MusicBrainzReleaseGroupId, result.MusicBrainzReleaseGroupId);
|
||||
Assert.Equal(entity.MusicBrainzReleaseArtistId, result.MusicBrainzReleaseArtistId);
|
||||
Assert.Equal(entity.CreatedOnUtc, result.CreatedOnUtc);
|
||||
Assert.Equal(entity.UpdatedOnUtc, result.UpdatedOnUtc);
|
||||
Assert.Equal(entity.Contributors.Select(contributor => new MediaContributorReferenceDto(contributor.MediaContributorId, contributor.Role)), result.Contributors);
|
||||
Assert.Equal(entity.Ratings.Select(rating => new AudioRatingDto(rating.Value, rating.MaxValue, rating.Source, rating.VoteCount)), result.Ratings);
|
||||
Assert.Equal(entity.Contributors.Select(contributor => _mediaContributorReferenceDtoFixture.Create(contributorId: contributor.MediaContributorId, role: contributor.Role)), result.Contributors);
|
||||
Assert.Equal(entity.Ratings.Select(rating => _audioRatingDtoFixture.Create(value: rating.Value, maxValue: rating.MaxValue, source: rating.Source, voteCount: rating.VoteCount)), result.Ratings);
|
||||
Assert.Equal(entity.Tracks.Select(track => track.Id), result.Tracks!.Select(track => track.Id));
|
||||
}
|
||||
|
||||
|
||||
+5
-3
@@ -5,6 +5,7 @@ using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.A
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
|
||||
using Lumina.Contracts.Responses.Common;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
@@ -27,6 +28,7 @@ public class ArtistEntityMappingTests
|
||||
private readonly ArtistEntityFixture _artistEntityFixture = new();
|
||||
private readonly AlbumEntityFixture _albumEntityFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<ArtistEntity> _paginatedResultDtoFixture = new();
|
||||
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToDomainEntity_WhenMappingValidArtistEntity_ShouldMapAllPropertiesCorrectly()
|
||||
@@ -111,10 +113,10 @@ public class ArtistEntityMappingTests
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(entity.Id, result.Id);
|
||||
Assert.Equal(entity.LibraryId, result.LibraryId);
|
||||
Assert.Equal(entity.Name, result.Name);
|
||||
Assert.Equal(entity.Name, result.Metadata.Name);
|
||||
Assert.Equal(entity.Website, result.Website);
|
||||
Assert.Equal(entity.MusicBrainzArtistId, result.MusicBrainzArtistId);
|
||||
Assert.Equal(entity.Contributors.Select(contributor => new MediaContributorReferenceDto(contributor.MediaContributorId, contributor.Role)), result.Contributors);
|
||||
Assert.Equal(entity.Contributors.Select(contributor => _mediaContributorReferenceDtoFixture.Create(contributorId: contributor.MediaContributorId, role: contributor.Role)), result.Contributors);
|
||||
Assert.Equal(entity.Albums.Count, result.Albums!.Count);
|
||||
Assert.Equal(entity.Albums.Select(album => album.Id), result.Albums.Select(album => album.Id));
|
||||
Assert.Equal(entity.Albums.Select(album => album.Title), result.Albums.Select(album => album.Metadata.Title));
|
||||
@@ -157,7 +159,7 @@ public class ArtistEntityMappingTests
|
||||
for (int i = 0; i < entities.Count; i++)
|
||||
{
|
||||
Assert.Equal(entities[i].Id, results[i].Id);
|
||||
Assert.Equal(entities[i].Name, results[i].Name);
|
||||
Assert.Equal(entities[i].Name, results[i].Metadata.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+19
-10
@@ -2,10 +2,13 @@
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -26,6 +29,12 @@ public class TrackEntityMappingTests
|
||||
{
|
||||
private readonly TrackEntityFixture _trackEntityFixture = new();
|
||||
private readonly AudioRatingEntityFixture _audioRatingEntityFixture = new();
|
||||
private readonly GenreEntityFixture _genreEntityFixture = new();
|
||||
private readonly TagEntityFixture _tagEntityFixture = new();
|
||||
private readonly TrackMoodEntityFixture _trackMoodEntityFixture = new();
|
||||
private readonly TrackIsrcEntityFixture _trackIsrcEntityFixture = new();
|
||||
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
|
||||
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToDomainEntity_WhenMappingValidTrackEntity_ShouldMapAllPropertiesCorrectly()
|
||||
@@ -73,10 +82,10 @@ public class TrackEntityMappingTests
|
||||
Assert.Equal(entity.Script, track.Script.Value);
|
||||
Assert.Equal(entity.Key, track.Key.Value);
|
||||
Assert.Equal(entity.Bpm, track.Bpm.Value);
|
||||
Assert.Equal(entity.Work, track.Work.Value);
|
||||
Assert.Equal(entity.WorkTitle, track.Work.Value.Title);
|
||||
Assert.Equal(entity.MusicBrainzRecordingId, track.MusicBrainzRecordingId.Value.Value);
|
||||
Assert.Equal(entity.MusicBrainzTrackId, track.MusicBrainzTrackId.Value.Value);
|
||||
Assert.Equal(entity.MusicBrainzWorkId, track.MusicBrainzWorkId.Value.Value);
|
||||
Assert.Equal(entity.MusicBrainzWorkId, track.Work.Value.MusicBrainzWorkId.Value);
|
||||
Assert.Equal(entity.Moods.Select(mood => mood.Name), track.Moods.Select(mood => mood.Name));
|
||||
Assert.Equal(entity.Isrcs.Select(isrc => isrc.Value), track.Isrcs.Select(isrc => isrc.Value));
|
||||
Assert.Equal(entity.Ratings.Select(rating => rating.Value), track.Ratings.Select(rating => (decimal?)rating.Value));
|
||||
@@ -107,7 +116,7 @@ public class TrackEntityMappingTests
|
||||
{
|
||||
// Arrange
|
||||
TrackEntity entity = _trackEntityFixture.Create();
|
||||
entity.Genres = [new GenreEntity(string.Empty)];
|
||||
entity.Genres = [_genreEntityFixture.Create(name: string.Empty)];
|
||||
|
||||
// Act
|
||||
Result<Track> result = entity.ToDomainEntity();
|
||||
@@ -122,7 +131,7 @@ public class TrackEntityMappingTests
|
||||
{
|
||||
// Arrange
|
||||
TrackEntity entity = _trackEntityFixture.Create();
|
||||
entity.Tags = [new TagEntity(" ")];
|
||||
entity.Tags = [_tagEntityFixture.Create(name: " ")];
|
||||
|
||||
// Act
|
||||
Result<Track> result = entity.ToDomainEntity();
|
||||
@@ -137,7 +146,7 @@ public class TrackEntityMappingTests
|
||||
{
|
||||
// Arrange
|
||||
TrackEntity entity = _trackEntityFixture.Create();
|
||||
entity.Moods = [new TrackMoodEntity(string.Empty)];
|
||||
entity.Moods = [_trackMoodEntityFixture.Create(name: string.Empty)];
|
||||
|
||||
// Act
|
||||
Result<Track> result = entity.ToDomainEntity();
|
||||
@@ -152,7 +161,7 @@ public class TrackEntityMappingTests
|
||||
{
|
||||
// Arrange
|
||||
TrackEntity entity = _trackEntityFixture.Create();
|
||||
entity.Isrcs = [new TrackIsrcEntity("not-an-isrc")];
|
||||
entity.Isrcs = [_trackIsrcEntityFixture.Create(value: "not-an-isrc")];
|
||||
|
||||
// Act
|
||||
Result<Track> result = entity.ToDomainEntity();
|
||||
@@ -222,16 +231,16 @@ public class TrackEntityMappingTests
|
||||
Assert.Equal(entity.Script, result.Script);
|
||||
Assert.Equal(entity.Key, result.Key);
|
||||
Assert.Equal(entity.Bpm, result.Bpm);
|
||||
Assert.Equal(entity.Work, result.Work);
|
||||
Assert.Equal(entity.WorkTitle, result.Work!.Title);
|
||||
Assert.Equal(entity.MusicBrainzRecordingId, result.MusicBrainzRecordingId);
|
||||
Assert.Equal(entity.MusicBrainzTrackId, result.MusicBrainzTrackId);
|
||||
Assert.Equal(entity.MusicBrainzWorkId, result.MusicBrainzWorkId);
|
||||
Assert.Equal(entity.MusicBrainzWorkId, result.Work!.MusicBrainzWorkId);
|
||||
Assert.Equal(entity.CreatedOnUtc, result.CreatedOnUtc);
|
||||
Assert.Equal(entity.UpdatedOnUtc, result.UpdatedOnUtc);
|
||||
Assert.Equal(entity.Moods.Select(mood => mood.Name), result.Moods!.Select(mood => mood.Name));
|
||||
Assert.Equal(entity.Isrcs.Select(isrc => isrc.Value), result.Isrcs!.Select(isrc => isrc.Value));
|
||||
Assert.Equal(entity.Contributors.Select(contributor => new MediaContributorReferenceDto(contributor.MediaContributorId, contributor.Role)), result.Contributors);
|
||||
Assert.Equal(entity.Ratings.Select(rating => new AudioRatingDto(rating.Value, rating.MaxValue, rating.Source, rating.VoteCount)), result.Ratings);
|
||||
Assert.Equal(entity.Contributors.Select(contributor => _mediaContributorReferenceDtoFixture.Create(contributorId: contributor.MediaContributorId, role: contributor.Role)), result.Contributors);
|
||||
Assert.Equal(entity.Ratings.Select(rating => _audioRatingDtoFixture.Create(value: rating.Value, maxValue: rating.MaxValue, source: rating.Source, voteCount: rating.VoteCount)), result.Ratings);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
+8
-5
@@ -25,6 +25,9 @@ public class BookMetadataDtoMappingTests
|
||||
private readonly BookMetadataDtoFixture _bookMetadataDtoFixture = new();
|
||||
private readonly GenreDtoFixture _genreDtoFixture = new();
|
||||
private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new();
|
||||
private readonly TagDtoFixture _tagDtoFixture = new();
|
||||
private readonly IsbnDtoFixture _isbnDtoFixture = new();
|
||||
private readonly BookRatingDtoFixture _bookRatingDtoFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ApplyMetadata_WhenCalledWithValidMetadata_ShouldApplyItToTheBook()
|
||||
@@ -126,7 +129,7 @@ public class BookMetadataDtoMappingTests
|
||||
Book book = _bookFixture.Create();
|
||||
BookMetadataDto metadata = _bookMetadataDtoFixture.Create(
|
||||
title: "A valid title",
|
||||
tags: [new TagDto(" ")]);
|
||||
tags: [_tagDtoFixture.Create(name: " ")]);
|
||||
|
||||
// Act
|
||||
Result<Success> result = book.ApplyMetadata(metadata);
|
||||
@@ -142,7 +145,7 @@ public class BookMetadataDtoMappingTests
|
||||
Book book = _bookFixture.Create();
|
||||
BookMetadataDto metadata = _bookMetadataDtoFixture.Create(
|
||||
title: "A valid title",
|
||||
isbns: [new IsbnDto("not-an-isbn", IsbnFormat.Isbn13)]);
|
||||
isbns: [_isbnDtoFixture.Create(value: "not-an-isbn", format: IsbnFormat.Isbn13)]);
|
||||
|
||||
// Act
|
||||
Result<Success> result = book.ApplyMetadata(metadata);
|
||||
@@ -158,7 +161,7 @@ public class BookMetadataDtoMappingTests
|
||||
Book book = _bookFixture.Create();
|
||||
BookMetadataDto metadata = _bookMetadataDtoFixture.Create(
|
||||
title: "A valid title",
|
||||
ratings: [new BookRatingDto(-1m, 5m, null, null)]);
|
||||
ratings: [_bookRatingDtoFixture.Create(value: -1m, maxValue: 5m, includeSource: false, includeVoteCount: false)]);
|
||||
|
||||
// Act
|
||||
Result<Success> result = book.ApplyMetadata(metadata);
|
||||
@@ -196,8 +199,8 @@ public class BookMetadataDtoMappingTests
|
||||
Book book = _bookFixture.Create();
|
||||
BookMetadataDto metadata = _bookMetadataDtoFixture.Create(
|
||||
title: "A valid title",
|
||||
isbns: [new IsbnDto("9780306406157", IsbnFormat.Isbn13)],
|
||||
ratings: [new BookRatingDto(4m, 5m, null, 10)]);
|
||||
isbns: [_isbnDtoFixture.Create(value: "9780306406157", format: IsbnFormat.Isbn13)],
|
||||
ratings: [_bookRatingDtoFixture.Create(value: 4m, maxValue: 5m, voteCount: 10, includeSource: false)]);
|
||||
|
||||
// Act
|
||||
Result<Success> result = book.ApplyMetadata(metadata);
|
||||
|
||||
+4
-1
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Application.Core.Plugins.Queries.GetLibraryMetadataProviders;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Plugins;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -14,11 +15,13 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Plugins;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetLibraryMetadataProvidersRequestMappingTests
|
||||
{
|
||||
private readonly GetLibraryMetadataProvidersRequestFixture _getLibraryMetadataProvidersRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingValidRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetLibraryMetadataProvidersRequest request = new(LibraryId: Guid.NewGuid());
|
||||
GetLibraryMetadataProvidersRequest request = _getLibraryMetadataProvidersRequestFixture.Create(Guid.NewGuid());
|
||||
|
||||
// Act
|
||||
GetLibraryMetadataProvidersQuery result = request.ToQuery();
|
||||
|
||||
+4
-1
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Application.Core.Plugins.Queries.GetPluginSettings;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Plugins;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -14,11 +15,13 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Plugins;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetPluginSettingsRequestMappingTests
|
||||
{
|
||||
private readonly GetPluginSettingsRequestFixture _getPluginSettingsRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingValidRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetPluginSettingsRequest request = new(PluginId: Guid.NewGuid());
|
||||
GetPluginSettingsRequest request = _getPluginSettingsRequestFixture.Create(Guid.NewGuid());
|
||||
|
||||
// Act
|
||||
GetPluginSettingsQuery result = request.ToQuery();
|
||||
|
||||
+6
-3
@@ -3,6 +3,7 @@ using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Plugins;
|
||||
using Lumina.Plugins.Contracts.Common.Models.DTO.Settings;
|
||||
using Lumina.Plugins.Contracts.Fixtures.Common.Models.DTO.Settings;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
@@ -15,11 +16,13 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Plugins;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PluginSettingDescriptorMappingTests
|
||||
{
|
||||
private readonly PluginSettingDescriptorDtoFixture _pluginSettingDescriptorDtoFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToResponse_WhenMappingValidDescriptor_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
PluginSettingDescriptorDto descriptor = new("apiKey", "API Key", PluginSettingType.Text, "default", null);
|
||||
PluginSettingDescriptorDto descriptor = _pluginSettingDescriptorDtoFixture.Create("apiKey", "API Key", PluginSettingType.Text, "default", null);
|
||||
|
||||
// Act
|
||||
PluginSettingDescriptorResponse result = descriptor.ToResponse();
|
||||
@@ -41,7 +44,7 @@ public class PluginSettingDescriptorMappingTests
|
||||
public void ToResponse_WhenMappingDifferentSettingTypes_ShouldMapTypeCorrectly(PluginSettingType type)
|
||||
{
|
||||
// Arrange
|
||||
PluginSettingDescriptorDto descriptor = new("key", "Label", type, null, null);
|
||||
PluginSettingDescriptorDto descriptor = _pluginSettingDescriptorDtoFixture.Create("key", "Label", type, null, null);
|
||||
|
||||
// Act
|
||||
PluginSettingDescriptorResponse result = descriptor.ToResponse();
|
||||
@@ -54,7 +57,7 @@ public class PluginSettingDescriptorMappingTests
|
||||
public void ToResponse_WhenMappingDescriptorWithAllowedValues_ShouldMapAllowedValues()
|
||||
{
|
||||
// Arrange
|
||||
PluginSettingDescriptorDto descriptor = new("mode", "Mode", PluginSettingType.Select, null, ["fast", "slow"]);
|
||||
PluginSettingDescriptorDto descriptor = _pluginSettingDescriptorDtoFixture.Create("mode", "Mode", PluginSettingType.Select, null, ["fast", "slow"]);
|
||||
|
||||
// Act
|
||||
PluginSettingDescriptorResponse result = descriptor.ToResponse();
|
||||
|
||||
+4
-1
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Application.Core.Plugins.Commands.ReorderLibraryMetadataProviders;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Plugins;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -15,11 +16,13 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Plugins;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReorderLibraryMetadataProvidersRequestMappingTests
|
||||
{
|
||||
private readonly ReorderLibraryMetadataProvidersRequestFixture _reorderLibraryMetadataProvidersRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
ReorderLibraryMetadataProvidersRequest request = new(LibraryId: Guid.NewGuid(), PluginIds: [Guid.NewGuid(), Guid.NewGuid()]);
|
||||
ReorderLibraryMetadataProvidersRequest request = _reorderLibraryMetadataProvidersRequestFixture.Create(Guid.NewGuid(), [Guid.NewGuid(), Guid.NewGuid()]);
|
||||
|
||||
// Act
|
||||
ReorderLibraryMetadataProvidersCommand result = request.ToCommand();
|
||||
|
||||
+4
-1
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Application.Core.Plugins.Commands.SetLibraryMetadataProviderEnabled;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Plugins;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -14,11 +15,13 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Plugins;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SetLibraryMetadataProviderEnabledRequestMappingTests
|
||||
{
|
||||
private readonly SetLibraryMetadataProviderEnabledRequestFixture _setLibraryMetadataProviderEnabledRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
SetLibraryMetadataProviderEnabledRequest request = new(LibraryId: Guid.NewGuid(), PluginId: Guid.NewGuid(), IsEnabled: true);
|
||||
SetLibraryMetadataProviderEnabledRequest request = _setLibraryMetadataProviderEnabledRequestFixture.Create(Guid.NewGuid(), Guid.NewGuid(), true);
|
||||
|
||||
// Act
|
||||
SetLibraryMetadataProviderEnabledCommand result = request.ToCommand();
|
||||
|
||||
+5
-2
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Application.Core.Plugins.Commands.UpdatePluginSettings;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Plugins;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -15,11 +16,13 @@ namespace Lumina.Application.UnitTests.Common.Mapping.Plugins;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdatePluginSettingsRequestMappingTests
|
||||
{
|
||||
private readonly UpdatePluginSettingsRequestFixture _updatePluginSettingsRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
UpdatePluginSettingsRequest request = new(PluginId: Guid.NewGuid(), Settings: new Dictionary<string, string> { ["key"] = "value" });
|
||||
UpdatePluginSettingsRequest request = _updatePluginSettingsRequestFixture.Create(Guid.NewGuid(), new Dictionary<string, string> { ["key"] = "value" });
|
||||
|
||||
// Act
|
||||
UpdatePluginSettingsCommand result = request.ToCommand();
|
||||
@@ -34,7 +37,7 @@ public class UpdatePluginSettingsRequestMappingTests
|
||||
public void ToCommand_WhenMappingRequestWithNullSettings_ShouldMapNullSettings()
|
||||
{
|
||||
// Arrange
|
||||
UpdatePluginSettingsRequest request = new(PluginId: Guid.NewGuid(), Settings: null);
|
||||
UpdatePluginSettingsRequest request = _updatePluginSettingsRequestFixture.Create(Guid.NewGuid(), includeSettings: false);
|
||||
|
||||
// Act
|
||||
UpdatePluginSettingsCommand result = request.ToCommand();
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ public class DeleteThemeRequestMappingTests
|
||||
public void ToCommand_WhenMappingDifferentThemeIds_ShouldMapCorrectly(string themeId)
|
||||
{
|
||||
// Arrange
|
||||
DeleteThemeRequest request = new(themeId);
|
||||
DeleteThemeRequest request = _deleteThemeRequestFixture.Create(themeId);
|
||||
|
||||
// Act
|
||||
DeleteThemeCommand result = request.ToCommand();
|
||||
@@ -53,7 +53,7 @@ public class DeleteThemeRequestMappingTests
|
||||
public void ToCommand_WhenThemeIdIsNull_ShouldMapNull()
|
||||
{
|
||||
// Arrange
|
||||
DeleteThemeRequest request = new(null);
|
||||
DeleteThemeRequest request = _deleteThemeRequestFixture.Create(includeThemeId: false);
|
||||
|
||||
// Act
|
||||
DeleteThemeCommand result = request.ToCommand();
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ public class GetThemeArchiveRequestMappingTests
|
||||
public void ToQuery_WhenMappingDifferentThemeIds_ShouldMapCorrectly(string themeId)
|
||||
{
|
||||
// Arrange
|
||||
GetThemeArchiveRequest request = new(themeId);
|
||||
GetThemeArchiveRequest request = _getThemeArchiveRequestFixture.Create(themeId);
|
||||
|
||||
// Act
|
||||
GetThemeArchiveQuery result = request.ToQuery();
|
||||
@@ -53,7 +53,7 @@ public class GetThemeArchiveRequestMappingTests
|
||||
public void ToQuery_WhenThemeIdIsNull_ShouldMapNull()
|
||||
{
|
||||
// Arrange
|
||||
GetThemeArchiveRequest request = new(null);
|
||||
GetThemeArchiveRequest request = _getThemeArchiveRequestFixture.Create(includeThemeId: false);
|
||||
|
||||
// Act
|
||||
GetThemeArchiveQuery result = request.ToQuery();
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ public class GetThemeAssetRequestMappingTests
|
||||
public void ToQuery_WhenMappingDifferentThemeIdsAndAssetPaths_ShouldMapCorrectly(string themeId, string assetPath)
|
||||
{
|
||||
// Arrange
|
||||
GetThemeAssetRequest request = new(themeId, assetPath);
|
||||
GetThemeAssetRequest request = _getThemeAssetRequestFixture.Create(themeId, assetPath);
|
||||
|
||||
// Act
|
||||
GetThemeAssetQuery result = request.ToQuery();
|
||||
@@ -55,7 +55,7 @@ public class GetThemeAssetRequestMappingTests
|
||||
public void ToQuery_WhenFieldsAreNull_ShouldMapNull()
|
||||
{
|
||||
// Arrange
|
||||
GetThemeAssetRequest request = new(null, null);
|
||||
GetThemeAssetRequest request = _getThemeAssetRequestFixture.Create(includeThemeId: false, includeAssetPath: false);
|
||||
|
||||
// Act
|
||||
GetThemeAssetQuery result = request.ToQuery();
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ public class GetThemeTemplateRequestMappingTests
|
||||
public void ToQuery_WhenMappingDifferentThemeIdsAndPageKeys_ShouldMapCorrectly(string themeId, string pageKey)
|
||||
{
|
||||
// Arrange
|
||||
GetThemeTemplateRequest request = new(themeId, pageKey);
|
||||
GetThemeTemplateRequest request = _getThemeTemplateRequestFixture.Create(themeId, pageKey);
|
||||
|
||||
// Act
|
||||
GetThemeTemplateQuery result = request.ToQuery();
|
||||
@@ -55,7 +55,7 @@ public class GetThemeTemplateRequestMappingTests
|
||||
public void ToQuery_WhenFieldsAreNull_ShouldMapNull()
|
||||
{
|
||||
// Arrange
|
||||
GetThemeTemplateRequest request = new(null, null);
|
||||
GetThemeTemplateRequest request = _getThemeTemplateRequestFixture.Create(includeThemeId: false, includePageKey: false);
|
||||
|
||||
// Act
|
||||
GetThemeTemplateQuery result = request.ToQuery();
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ public class SetCurrentThemeRequestMappingTests
|
||||
public void ToCommand_WhenMappingDifferentThemeIds_ShouldMapCorrectly(string themeId)
|
||||
{
|
||||
// Arrange
|
||||
SetCurrentThemeRequest request = new(themeId);
|
||||
SetCurrentThemeRequest request = _setCurrentThemeRequestFixture.Create(themeId);
|
||||
|
||||
// Act
|
||||
SetCurrentThemeCommand result = request.ToCommand();
|
||||
@@ -53,7 +53,7 @@ public class SetCurrentThemeRequestMappingTests
|
||||
public void ToCommand_WhenThemeIdIsNull_ShouldMapNull()
|
||||
{
|
||||
// Arrange
|
||||
SetCurrentThemeRequest request = new(null);
|
||||
SetCurrentThemeRequest request = _setCurrentThemeRequestFixture.Create(includeThemeId: false);
|
||||
|
||||
// Act
|
||||
SetCurrentThemeCommand result = request.ToCommand();
|
||||
|
||||
+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