mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 09:11:10 +00:00
Removes FluentAssertions library from test projects, due to licensing changes
This commit is contained in:
1 parent
c1100e5398
commit
d46bfae4fc
235 files changed
+4468
-4725
No files matched your search
+9
-9
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
@@ -14,6 +13,7 @@ using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
@@ -73,8 +73,8 @@ public class GetPermissionsQueryHandlerTests
|
||||
ErrorOr<IEnumerable<PermissionResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().HaveCount(2);
|
||||
Assert.False(result.IsError);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
await _mockAuthorizationService.Received(1).IsInRoleAsync(_userId, "Admin", Arg.Any<CancellationToken>());
|
||||
await _mockPermissionRepository.Received(1).GetAllAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -92,8 +92,8 @@ public class GetPermissionsQueryHandlerTests
|
||||
ErrorOr<IEnumerable<PermissionResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authorization.NotAuthorized);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockAuthorizationService.Received(1).IsInRoleAsync(_userId, "Admin", Arg.Any<CancellationToken>());
|
||||
await _mockPermissionRepository.DidNotReceive().GetAllAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -114,8 +114,8 @@ public class GetPermissionsQueryHandlerTests
|
||||
ErrorOr<IEnumerable<PermissionResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
await _mockAuthorizationService.Received(1).IsInRoleAsync(_userId, "Admin", Arg.Any<CancellationToken>());
|
||||
await _mockPermissionRepository.Received(1).GetAllAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -140,8 +140,8 @@ public class GetPermissionsQueryHandlerTests
|
||||
ErrorOr<IEnumerable<PermissionResponse>> result = await _sut.Handle(query, cancellationToken);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().HaveCount(1);
|
||||
Assert.False(result.IsError);
|
||||
Assert.Single(result.Value);
|
||||
await _mockAuthorizationService.Received(1).IsInRoleAsync(_userId, "Admin", Arg.Any<CancellationToken>());
|
||||
await _mockPermissionRepository.Received(1).GetAllAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
+11
-12
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
@@ -68,8 +67,8 @@ public class AddRoleCommandHandlerTests
|
||||
ErrorOr<RolePermissionsResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authorization.NotAuthorized);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockRoleRepository.DidNotReceive().InsertAsync(Arg.Any<RoleEntity>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -89,8 +88,8 @@ public class AddRoleCommandHandlerTests
|
||||
ErrorOr<RolePermissionsResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -112,8 +111,8 @@ public class AddRoleCommandHandlerTests
|
||||
ErrorOr<RolePermissionsResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -133,8 +132,8 @@ public class AddRoleCommandHandlerTests
|
||||
ErrorOr<RolePermissionsResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Persistence.ErrorPersistingAuthorizationRole);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Persistence.ErrorPersistingAuthorizationRole, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -171,9 +170,9 @@ public class AddRoleCommandHandlerTests
|
||||
ErrorOr<RolePermissionsResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Role.RoleName.Should().Be(command.RoleName);
|
||||
result.Value.Permissions.Should().HaveCount(command.Permissions.Count);
|
||||
Assert.False(result.IsError);
|
||||
Assert.Equal(command.RoleName, result.Value.Role.RoleName);
|
||||
Assert.Equal(command.Permissions.Count, result.Value.Permissions.Length);
|
||||
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
}
|
||||
+11
-12
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
@@ -65,8 +64,8 @@ public class DeleteRoleCommandHandlerTests
|
||||
ErrorOr<Deleted> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authorization.NotAuthorized);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockRoleRepository.DidNotReceive().DeleteByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -85,8 +84,8 @@ public class DeleteRoleCommandHandlerTests
|
||||
ErrorOr<Deleted> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authorization.RoleNotFound);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authorization.RoleNotFound, result.FirstError);
|
||||
await _mockRoleRepository.DidNotReceive().DeleteByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -106,8 +105,8 @@ public class DeleteRoleCommandHandlerTests
|
||||
ErrorOr<Deleted> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authorization.AdminRoleCannotBeDeleted);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authorization.AdminRoleCannotBeDeleted, result.FirstError);
|
||||
await _mockRoleRepository.DidNotReceive().DeleteByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -127,8 +126,8 @@ public class DeleteRoleCommandHandlerTests
|
||||
ErrorOr<Deleted> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
await _mockRoleRepository.DidNotReceive().DeleteByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -151,8 +150,8 @@ public class DeleteRoleCommandHandlerTests
|
||||
ErrorOr<Deleted> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -174,7 +173,7 @@ public class DeleteRoleCommandHandlerTests
|
||||
ErrorOr<Deleted> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
Assert.False(result.IsError);
|
||||
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
}
|
||||
+11
-12
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
@@ -68,8 +67,8 @@ public class UpdateRoleCommandHandlerTests
|
||||
ErrorOr<RolePermissionsResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authorization.NotAuthorized);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockRoleRepository.DidNotReceive().UpdateAsync(Arg.Any<RoleEntity>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -89,8 +88,8 @@ public class UpdateRoleCommandHandlerTests
|
||||
ErrorOr<RolePermissionsResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -112,8 +111,8 @@ public class UpdateRoleCommandHandlerTests
|
||||
ErrorOr<RolePermissionsResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -133,8 +132,8 @@ public class UpdateRoleCommandHandlerTests
|
||||
ErrorOr<RolePermissionsResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Persistence.ErrorPersistingAuthorizationRole);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Persistence.ErrorPersistingAuthorizationRole, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -170,9 +169,9 @@ public class UpdateRoleCommandHandlerTests
|
||||
ErrorOr<RolePermissionsResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Role.RoleName.Should().Be(command.RoleName);
|
||||
result.Value.Permissions.Should().HaveCount(command.Permissions.Count);
|
||||
Assert.False(result.IsError);
|
||||
Assert.Equal(command.RoleName, result.Value.Role.RoleName);
|
||||
Assert.Equal(command.Permissions.Count, result.Value.Permissions.Length);
|
||||
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
}
|
||||
+9
-10
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
@@ -67,8 +66,8 @@ public class GetRolePermissionsQueryHandlerTests
|
||||
ErrorOr<RolePermissionsResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authorization.NotAuthorized);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockRoleRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -88,8 +87,8 @@ public class GetRolePermissionsQueryHandlerTests
|
||||
ErrorOr<RolePermissionsResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -107,8 +106,8 @@ public class GetRolePermissionsQueryHandlerTests
|
||||
ErrorOr<RolePermissionsResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authorization.RoleNotFound);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authorization.RoleNotFound, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -145,8 +144,8 @@ public class GetRolePermissionsQueryHandlerTests
|
||||
ErrorOr<RolePermissionsResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Role.RoleName.Should().Be(role.RoleName);
|
||||
result.Value.Permissions.Should().HaveCount(1);
|
||||
Assert.False(result.IsError);
|
||||
Assert.Equal(role.RoleName, result.Value.Role.RoleName);
|
||||
Assert.Single(result.Value.Permissions);
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
@@ -14,6 +13,7 @@ using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
@@ -66,8 +66,8 @@ public class GetRolesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<RoleResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authorization.NotAuthorized);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockRoleRepository.DidNotReceive().GetAllAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -87,8 +87,8 @@ public class GetRolesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<RoleResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -111,7 +111,7 @@ public class GetRolesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<RoleResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().HaveCount(2);
|
||||
Assert.False(result.IsError);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
}
|
||||
}
|
||||
+20
-21
@@ -2,7 +2,6 @@
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectories;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Directories.Fixtures;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Directories.Queries.GetDirectories.Fixtures;
|
||||
@@ -57,20 +56,20 @@ public class GetDirectoriesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<DirectoryResponse>> result = await _sut.Handle(getDirectoriesQuery, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeAssignableTo<IEnumerable<DirectoryResponse>>();
|
||||
result.Value.Should().HaveCount(directories.Count());
|
||||
Assert.False(result.IsError);
|
||||
Assert.IsAssignableFrom<IEnumerable<DirectoryResponse>>(result.Value);
|
||||
Assert.Equal(directories.Count(), result.Value.Count());
|
||||
|
||||
List<DirectoryResponse> resultList = result.Value.ToList();
|
||||
List<Directory> directoriesList = directories.ToList();
|
||||
|
||||
for (int i = 0; i < resultList.Count; i++)
|
||||
{
|
||||
resultList[i].Path.Should().Be(directoriesList[i].Id.Path);
|
||||
resultList[i].Name.Should().Be(directoriesList[i].Name);
|
||||
resultList[i].DateCreated.Should().Be(directoriesList[i].DateCreated.Value);
|
||||
resultList[i].DateModified.Should().Be(directoriesList[i].DateModified.Value);
|
||||
resultList[i].Items.Should().BeEmpty(); // since files are not included
|
||||
Assert.Equal(directoriesList[i].Id.Path, resultList[i].Path);
|
||||
Assert.Equal(directoriesList[i].Name, resultList[i].Name);
|
||||
Assert.Equal(directoriesList[i].DateCreated.Value, resultList[i].DateCreated);
|
||||
Assert.Equal(directoriesList[i].DateModified.Value, resultList[i].DateModified);
|
||||
Assert.Empty(resultList[i].Items); // since files are not included
|
||||
}
|
||||
|
||||
_mockDirectoryService.Received(1).GetSubdirectories(getDirectoriesQuery.Path!, getDirectoriesQuery.IncludeHiddenElements);
|
||||
@@ -91,20 +90,20 @@ public class GetDirectoriesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<DirectoryResponse>> result = await _sut.Handle(getDirectoriesQuery, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeAssignableTo<IEnumerable<DirectoryResponse>>();
|
||||
result.Value.Should().HaveCount(directories.Count());
|
||||
Assert.False(result.IsError);
|
||||
Assert.IsAssignableFrom<IEnumerable<DirectoryResponse>>(result.Value);
|
||||
Assert.Equal(directories.Count(), result.Value.Count());
|
||||
|
||||
List<DirectoryResponse> resultList = result.Value.ToList();
|
||||
List<Directory> directoriesList = directories.ToList();
|
||||
|
||||
for (int i = 0; i < resultList.Count; i++)
|
||||
{
|
||||
resultList[i].Path.Should().Be(directoriesList[i].Id.Path);
|
||||
resultList[i].Name.Should().Be(directoriesList[i].Name);
|
||||
resultList[i].DateCreated.Should().Be(directoriesList[i].DateCreated.Value);
|
||||
resultList[i].DateModified.Should().Be(directoriesList[i].DateModified.Value);
|
||||
resultList[i].Items.Should().HaveCount(directoriesList[i].Items.Count);
|
||||
Assert.Equal(directoriesList[i].Id.Path, resultList[i].Path);
|
||||
Assert.Equal(directoriesList[i].Name, resultList[i].Name);
|
||||
Assert.Equal(directoriesList[i].DateCreated.Value, resultList[i].DateCreated);
|
||||
Assert.Equal(directoriesList[i].DateModified.Value, resultList[i].DateModified);
|
||||
Assert.Equal(directoriesList[i].Items.Count, resultList[i].Items.Count);
|
||||
}
|
||||
|
||||
_mockDirectoryService.Received(1).GetSubdirectories(getDirectoriesQuery.Path!, getDirectoriesQuery.IncludeHiddenElements);
|
||||
@@ -123,8 +122,8 @@ public class GetDirectoriesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<DirectoryResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
_mockDirectoryService.Received(1).GetSubdirectories(query.Path!, query.IncludeHiddenElements);
|
||||
}
|
||||
|
||||
@@ -141,8 +140,8 @@ public class GetDirectoriesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<DirectoryResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeEmpty();
|
||||
Assert.False(result.IsError);
|
||||
Assert.Empty(result.Value);
|
||||
_mockDirectoryService.Received(1).GetSubdirectories(query.Path!, query.IncludeHiddenElements);
|
||||
}
|
||||
}
|
||||
+13
-14
@@ -2,7 +2,6 @@
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Core.FileSystemManagement.Drives.Queries.GetDrives;
|
||||
using Lumina.Domain.Common.Enums.FileSystem;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
@@ -58,9 +57,9 @@ public class GetDrivesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _sut.Handle(getDrivesQuery, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeAssignableTo<IEnumerable<FileSystemTreeNodeResponse>>();
|
||||
result.Value.Should().HaveCount(drives.Count());
|
||||
Assert.False(result.IsError);
|
||||
Assert.IsAssignableFrom<IEnumerable<FileSystemTreeNodeResponse>>(result.Value);
|
||||
Assert.Equal(drives.Count(), result.Value.Count());
|
||||
|
||||
List<FileSystemTreeNodeResponse> resultList = result.Value.ToList();
|
||||
List<FileSystemItem> drivesList = drives.ToList();
|
||||
@@ -70,12 +69,12 @@ public class GetDrivesQueryHandlerTests
|
||||
FileSystemTreeNodeResponse response = resultList[i];
|
||||
WindowsRootItem drive = (WindowsRootItem)drivesList[i];
|
||||
|
||||
response.Path.Should().Be(drive.Id.Path);
|
||||
response.Name.Should().Be(drive.Name);
|
||||
response.ItemType.Should().Be(FileSystemItemType.Root);
|
||||
response.IsExpanded.Should().BeFalse();
|
||||
response.ChildrenLoaded.Should().BeFalse();
|
||||
response.Children.Should().BeEmpty();
|
||||
Assert.Equal(drive.Id.Path, response.Path);
|
||||
Assert.Equal(drive.Name, response.Name);
|
||||
Assert.Equal(FileSystemItemType.Root, response.ItemType);
|
||||
Assert.False(response.IsExpanded);
|
||||
Assert.False(response.ChildrenLoaded);
|
||||
Assert.Empty(response.Children);
|
||||
}
|
||||
|
||||
_mockDriveService.Received(1).GetDrives();
|
||||
@@ -94,8 +93,8 @@ public class GetDrivesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
_mockDriveService.Received(1).GetDrives();
|
||||
}
|
||||
|
||||
@@ -112,8 +111,8 @@ public class GetDrivesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeEmpty();
|
||||
Assert.False(result.IsError);
|
||||
Assert.Empty(result.Value);
|
||||
_mockDriveService.Received(1).GetDrives();
|
||||
}
|
||||
}
|
||||
+10
-12
@@ -1,7 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Core.FileSystemManagement.FileSystem.Queries.GetFileSystem;
|
||||
using Lumina.Domain.Common.Enums.FileSystem;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.FileSystem;
|
||||
@@ -51,8 +50,8 @@ public class GetFileSystemQueryHandlerTests
|
||||
FileSystemTypeResponse result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.PlatformType.Should().Be(platformType);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(platformType, result.PlatformType);
|
||||
_mockPlatformContextManager.Received(1).GetCurrentContext();
|
||||
}
|
||||
|
||||
@@ -67,10 +66,10 @@ public class GetFileSystemQueryHandlerTests
|
||||
ValueTask<FileSystemTypeResponse> resultTask = _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
resultTask.IsCompleted.Should().BeTrue();
|
||||
Assert.True(resultTask.IsCompleted);
|
||||
FileSystemTypeResponse result = await resultTask;
|
||||
result.Should().NotBeNull();
|
||||
result.PlatformType.Should().Be(PlatformType.Unix);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(PlatformType.Unix, result.PlatformType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -86,7 +85,7 @@ public class GetFileSystemQueryHandlerTests
|
||||
FileSystemTypeResponse result2 = await _sut.Handle(query2, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result1.Should().BeEquivalentTo(result2);
|
||||
Assert.Equal(result1.PlatformType, result2.PlatformType);
|
||||
_mockPlatformContextManager.Received(1).GetCurrentContext();
|
||||
}
|
||||
|
||||
@@ -98,11 +97,10 @@ public class GetFileSystemQueryHandlerTests
|
||||
_mockPlatformContext.Platform.Returns(PlatformType.Unix);
|
||||
CancellationToken cancellationToken = new(true);
|
||||
|
||||
// Act
|
||||
Func<Task> act = async () => await _sut.Handle(query, cancellationToken);
|
||||
|
||||
// Assert
|
||||
await act.Should().NotThrowAsync();
|
||||
// Act & Assert
|
||||
Exception? exception = await Record.ExceptionAsync(async () =>
|
||||
await _sut.Handle(query, cancellationToken));
|
||||
Assert.Null(exception);
|
||||
_mockPlatformContextManager.Received(1).GetCurrentContext();
|
||||
}
|
||||
}
|
||||
+20
-21
@@ -2,7 +2,6 @@
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetFiles;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Files.Fixtures;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Files.Queries.GetFiles.Fixtures;
|
||||
@@ -57,20 +56,20 @@ public class GetFilesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<FileResponse>> result = await _sut.Handle(getFilesQuery, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeAssignableTo<IEnumerable<FileResponse>>();
|
||||
result.Value.Should().HaveCount(files.Count());
|
||||
Assert.False(result.IsError);
|
||||
Assert.IsAssignableFrom<IEnumerable<FileResponse>>(result.Value);
|
||||
Assert.Equal(files.Count(), result.Value.Count());
|
||||
|
||||
List<FileResponse> resultList = result.Value.ToList();
|
||||
List<File> filesList = files.ToList();
|
||||
|
||||
for (int i = 0; i < resultList.Count; i++)
|
||||
{
|
||||
resultList[i].Path.Should().Be(filesList[i].Id.Path);
|
||||
resultList[i].Name.Should().Be(filesList[i].Name);
|
||||
resultList[i].DateCreated.Should().Be(filesList[i].DateCreated.Value);
|
||||
resultList[i].DateModified.Should().Be(filesList[i].DateModified.Value);
|
||||
resultList[i].Size.Should().Be(filesList[i].Size);
|
||||
Assert.Equal(filesList[i].Id.Path, resultList[i].Path);
|
||||
Assert.Equal(filesList[i].Name, resultList[i].Name);
|
||||
Assert.Equal(filesList[i].DateCreated.Value, resultList[i].DateCreated);
|
||||
Assert.Equal(filesList[i].DateModified.Value, resultList[i].DateModified);
|
||||
Assert.Equal(filesList[i].Size, resultList[i].Size);
|
||||
}
|
||||
|
||||
_mockFileService.Received(1).GetFiles(getFilesQuery.Path!, getFilesQuery.IncludeHiddenElements);
|
||||
@@ -91,20 +90,20 @@ public class GetFilesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<FileResponse>> result = await _sut.Handle(getFilesQuery, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeAssignableTo<IEnumerable<FileResponse>>();
|
||||
result.Value.Should().HaveCount(files.Count());
|
||||
Assert.False(result.IsError);
|
||||
Assert.IsAssignableFrom<IEnumerable<FileResponse>>(result.Value);
|
||||
Assert.Equal(files.Count(), result.Value.Count());
|
||||
|
||||
List<FileResponse> resultList = result.Value.ToList();
|
||||
List<File> filesList = files.ToList();
|
||||
|
||||
for (int i = 0; i < resultList.Count; i++)
|
||||
{
|
||||
resultList[i].Path.Should().Be(filesList[i].Id.Path);
|
||||
resultList[i].Name.Should().Be(filesList[i].Name);
|
||||
resultList[i].DateCreated.Should().Be(filesList[i].DateCreated.Value);
|
||||
resultList[i].DateModified.Should().Be(filesList[i].DateModified.Value);
|
||||
resultList[i].Size.Should().Be(filesList[i].Size);
|
||||
Assert.Equal(filesList[i].Id.Path, resultList[i].Path);
|
||||
Assert.Equal(filesList[i].Name, resultList[i].Name);
|
||||
Assert.Equal(filesList[i].DateCreated.Value, resultList[i].DateCreated);
|
||||
Assert.Equal(filesList[i].DateModified.Value, resultList[i].DateModified);
|
||||
Assert.Equal(filesList[i].Size, resultList[i].Size);
|
||||
}
|
||||
|
||||
_mockFileService.Received(1).GetFiles(getFilesQuery.Path!, getFilesQuery.IncludeHiddenElements);
|
||||
@@ -123,8 +122,8 @@ public class GetFilesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<FileResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
_mockFileService.Received(1).GetFiles(query.Path!, query.IncludeHiddenElements);
|
||||
}
|
||||
|
||||
@@ -141,8 +140,8 @@ public class GetFilesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<FileResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeEmpty();
|
||||
Assert.False(result.IsError);
|
||||
Assert.Empty(result.Value);
|
||||
_mockFileService.Received(1).GetFiles(query.Path!, query.IncludeHiddenElements);
|
||||
}
|
||||
}
|
||||
+22
-23
@@ -2,7 +2,6 @@
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Files.Fixtures;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Files.Queries.GetTreeFiles.Fixtures;
|
||||
@@ -57,21 +56,21 @@ public class GetTreeFilesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _sut.Handle(getFilesQuery, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeAssignableTo<IEnumerable<FileSystemTreeNodeResponse>>();
|
||||
result.Value.Should().HaveCount(files.Count());
|
||||
Assert.False(result.IsError);
|
||||
Assert.IsAssignableFrom<IEnumerable<FileSystemTreeNodeResponse>>(result.Value);
|
||||
Assert.Equal(files.Count(), result.Value.Count());
|
||||
|
||||
List<FileSystemTreeNodeResponse> resultList = result.Value.ToList();
|
||||
List<File> filesList = files.ToList();
|
||||
|
||||
for (int i = 0; i < resultList.Count; i++)
|
||||
{
|
||||
resultList[i].Path.Should().Be(filesList[i].Id.Path);
|
||||
resultList[i].Name.Should().Be(filesList[i].Name);
|
||||
resultList[i].ItemType.Should().Be(FileSystemItemType.File);
|
||||
resultList[i].IsExpanded.Should().BeFalse();
|
||||
resultList[i].ChildrenLoaded.Should().BeFalse();
|
||||
resultList[i].Children.Should().BeEmpty();
|
||||
Assert.Equal(filesList[i].Id.Path, resultList[i].Path);
|
||||
Assert.Equal(filesList[i].Name, resultList[i].Name);
|
||||
Assert.Equal(FileSystemItemType.File, resultList[i].ItemType);
|
||||
Assert.False(resultList[i].IsExpanded);
|
||||
Assert.False(resultList[i].ChildrenLoaded);
|
||||
Assert.Empty(resultList[i].Children);
|
||||
}
|
||||
|
||||
_mockFileService.Received(1).GetFiles(getFilesQuery.Path!, getFilesQuery.IncludeHiddenElements);
|
||||
@@ -92,21 +91,21 @@ public class GetTreeFilesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _sut.Handle(getFilesQuery, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeAssignableTo<IEnumerable<FileSystemTreeNodeResponse>>();
|
||||
result.Value.Should().HaveCount(files.Count());
|
||||
Assert.False(result.IsError);
|
||||
Assert.IsAssignableFrom<IEnumerable<FileSystemTreeNodeResponse>>(result.Value);
|
||||
Assert.Equal(files.Count(), result.Value.Count());
|
||||
|
||||
List<FileSystemTreeNodeResponse> resultList = result.Value.ToList();
|
||||
List<File> filesList = files.ToList();
|
||||
|
||||
for (int i = 0; i < resultList.Count; i++)
|
||||
{
|
||||
resultList[i].Path.Should().Be(filesList[i].Id.Path);
|
||||
resultList[i].Name.Should().Be(filesList[i].Name);
|
||||
resultList[i].ItemType.Should().Be(FileSystemItemType.File);
|
||||
resultList[i].IsExpanded.Should().BeFalse();
|
||||
resultList[i].ChildrenLoaded.Should().BeFalse();
|
||||
resultList[i].Children.Should().BeEmpty();
|
||||
Assert.Equal(filesList[i].Id.Path, resultList[i].Path);
|
||||
Assert.Equal(filesList[i].Name, resultList[i].Name);
|
||||
Assert.Equal(FileSystemItemType.File, resultList[i].ItemType);
|
||||
Assert.False(resultList[i].IsExpanded);
|
||||
Assert.False(resultList[i].ChildrenLoaded);
|
||||
Assert.Empty(resultList[i].Children);
|
||||
}
|
||||
|
||||
_mockFileService.Received(1).GetFiles(getFilesQuery.Path!, getFilesQuery.IncludeHiddenElements);
|
||||
@@ -125,8 +124,8 @@ public class GetTreeFilesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
_mockFileService.Received(1).GetFiles(query.Path!, query.IncludeHiddenElements);
|
||||
}
|
||||
|
||||
@@ -143,8 +142,8 @@ public class GetTreeFilesQueryHandlerTests
|
||||
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeEmpty();
|
||||
Assert.False(result.IsError);
|
||||
Assert.Empty(result.Value);
|
||||
_mockFileService.Received(1).GetFiles(query.Path!, query.IncludeHiddenElements);
|
||||
}
|
||||
}
|
||||
+8
-9
@@ -2,7 +2,6 @@
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Commands.CombinePath;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Commands.CombinePath.Fixtures;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
@@ -49,9 +48,9 @@ public class CombinePathCommandHandlerTests
|
||||
ErrorOr<PathSegmentResponse> result = await _sut.Handle(combinePathCommand, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeOfType<PathSegmentResponse>();
|
||||
result.Value.Path.Should().Be(combinedPath);
|
||||
Assert.False(result.IsError);
|
||||
Assert.IsType<PathSegmentResponse>(result.Value);
|
||||
Assert.Equal(combinedPath, result.Value.Path);
|
||||
_mockPathService.Received(1).CombinePath(combinePathCommand.OriginalPath!, combinePathCommand.NewPath!);
|
||||
}
|
||||
|
||||
@@ -68,8 +67,8 @@ public class CombinePathCommandHandlerTests
|
||||
ErrorOr<PathSegmentResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
_mockPathService.Received(1).CombinePath(command.OriginalPath!, command.NewPath!);
|
||||
}
|
||||
|
||||
@@ -85,9 +84,9 @@ public class CombinePathCommandHandlerTests
|
||||
ErrorOr<PathSegmentResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeOfType<PathSegmentResponse>();
|
||||
result.Value.Path.Should().BeEmpty();
|
||||
Assert.False(result.IsError);
|
||||
Assert.IsType<PathSegmentResponse>(result.Value);
|
||||
Assert.Empty(result.Value.Path);
|
||||
_mockPathService.Received(1).CombinePath(command.OriginalPath!, command.NewPath!);
|
||||
}
|
||||
}
|
||||
+8
-9
@@ -2,7 +2,6 @@
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Commands.SplitPath;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Commands.SplitPath.Fixtures;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Fixtures;
|
||||
@@ -57,15 +56,15 @@ public class SplitPathCommandHandlerTests
|
||||
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.Handle(splitPathCommand, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeAssignableTo<IEnumerable<PathSegmentResponse>>();
|
||||
result.Value.Should().HaveCount(pathSegments.Count());
|
||||
Assert.False(result.IsError);
|
||||
Assert.IsAssignableFrom<IEnumerable<PathSegmentResponse>>(result.Value);
|
||||
Assert.Equal(pathSegments.Count(), result.Value.Count());
|
||||
|
||||
List<PathSegmentResponse> resultList = result.Value.ToList();
|
||||
List<PathSegment> segmentsList = pathSegments.ToList();
|
||||
|
||||
for (int i = 0; i < resultList.Count; i++)
|
||||
resultList[i].Path.Should().Be(segmentsList[i].Name);
|
||||
Assert.Equal(segmentsList[i].Name, resultList[i].Path);
|
||||
_mockPathService.Received(1).ParsePath(splitPathCommand.Path!);
|
||||
}
|
||||
|
||||
@@ -82,8 +81,8 @@ public class SplitPathCommandHandlerTests
|
||||
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
_mockPathService.Received(1).ParsePath(command.Path!);
|
||||
}
|
||||
|
||||
@@ -100,8 +99,8 @@ public class SplitPathCommandHandlerTests
|
||||
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeEmpty();
|
||||
Assert.False(result.IsError);
|
||||
Assert.Empty(result.Value);
|
||||
_mockPathService.Received(1).ParsePath(command.Path!);
|
||||
}
|
||||
}
|
||||
+12
-13
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathExists;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Queries.CheckPathExists.Fixtures;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
@@ -42,8 +41,8 @@ public class CheckPathExistsQueryHandlerTests
|
||||
ErrorOr<PathExistsResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Exists.Should().BeTrue();
|
||||
Assert.False(result.IsError);
|
||||
Assert.True(result.Value.Exists);
|
||||
_mockPathService.Received(1).Exists(query.Path!);
|
||||
}
|
||||
|
||||
@@ -58,8 +57,8 @@ public class CheckPathExistsQueryHandlerTests
|
||||
ErrorOr<PathExistsResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Exists.Should().BeTrue();
|
||||
Assert.False(result.IsError);
|
||||
Assert.True(result.Value.Exists);
|
||||
_mockPathService.Received(1).Exists(query.Path!);
|
||||
}
|
||||
|
||||
@@ -74,8 +73,8 @@ public class CheckPathExistsQueryHandlerTests
|
||||
ErrorOr<PathExistsResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Exists.Should().BeFalse();
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.Value.Exists);
|
||||
_mockPathService.Received(1).Exists(query.Path!, false);
|
||||
}
|
||||
|
||||
@@ -90,8 +89,8 @@ public class CheckPathExistsQueryHandlerTests
|
||||
ErrorOr<PathExistsResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Exists.Should().BeFalse();
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.Value.Exists);
|
||||
_mockPathService.Received(1).Exists(query.Path!);
|
||||
}
|
||||
|
||||
@@ -106,8 +105,8 @@ public class CheckPathExistsQueryHandlerTests
|
||||
ErrorOr<PathExistsResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Exists.Should().BeFalse();
|
||||
Assert.False(result.IsError);
|
||||
Assert.False(result.Value.Exists);
|
||||
_mockPathService.Received(1).Exists(Arg.Any<string>(), Arg.Any<bool>());
|
||||
}
|
||||
|
||||
@@ -123,8 +122,8 @@ public class CheckPathExistsQueryHandlerTests
|
||||
ErrorOr<PathExistsResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Exists.Should().BeTrue();
|
||||
Assert.False(result.IsError);
|
||||
Assert.True(result.Value.Exists);
|
||||
_mockPathService.Received(1).Exists(query.Path!);
|
||||
}
|
||||
}
|
||||
+7
-8
@@ -2,7 +2,6 @@
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathParent;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Fixtures;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Queries.GetPathParent.Fixtures;
|
||||
@@ -56,9 +55,9 @@ public class GetPathParentQueryHandlerTests
|
||||
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeAssignableTo<IEnumerable<PathSegmentResponse>>();
|
||||
result.Value.Should().BeEquivalentTo(pathSegmentResponses);
|
||||
Assert.False(result.IsError);
|
||||
Assert.IsAssignableFrom<IEnumerable<PathSegmentResponse>>(result.Value);
|
||||
Assert.Equal(pathSegmentResponses, result.Value);
|
||||
_mockPathService.Received(1).GoUpOneLevel(query.Path!);
|
||||
}
|
||||
|
||||
@@ -75,8 +74,8 @@ public class GetPathParentQueryHandlerTests
|
||||
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
_mockPathService.Received(1).GoUpOneLevel(query.Path!);
|
||||
}
|
||||
|
||||
@@ -93,8 +92,8 @@ public class GetPathParentQueryHandlerTests
|
||||
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeEmpty();
|
||||
Assert.False(result.IsError);
|
||||
Assert.Empty(result.Value);
|
||||
_mockPathService.Received(1).GoUpOneLevel(query.Path!);
|
||||
}
|
||||
}
|
||||
+8
-9
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathRoot;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Fixtures;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Queries.GetPathRoot.Fixtures;
|
||||
@@ -49,9 +48,9 @@ public class GetPathRootQueryHandlerTests
|
||||
ErrorOr<PathSegmentResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().NotBeNull();
|
||||
result.Value.Path.Should().Be(pathSegment.Name);
|
||||
Assert.False(result.IsError);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(pathSegment.Name, result.Value.Path);
|
||||
_mockPathService.Received(1).GetPathRoot(query.Path!);
|
||||
}
|
||||
|
||||
@@ -68,8 +67,8 @@ public class GetPathRootQueryHandlerTests
|
||||
ErrorOr<PathSegmentResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
_mockPathService.Received(1).GetPathRoot(query.Path!);
|
||||
}
|
||||
|
||||
@@ -87,9 +86,9 @@ public class GetPathRootQueryHandlerTests
|
||||
ErrorOr<PathSegmentResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().NotBeNull();
|
||||
result.Value.Path.Should().Be("/");
|
||||
Assert.False(result.IsError);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal("/", result.Value.Path);
|
||||
_mockPathService.Received(1).GetPathRoot(query.Path!);
|
||||
}
|
||||
}
|
||||
+9
-8
@@ -1,5 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathSeparator;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
@@ -42,8 +41,8 @@ public class GetPathSeparatorQueryHandlerTests
|
||||
PathSeparatorResponse result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Separator.Should().Be(expectedSeparator.ToString());
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(expectedSeparator.ToString(), result.Separator);
|
||||
|
||||
_mockPathService.Received(1);
|
||||
}
|
||||
@@ -61,8 +60,8 @@ public class GetPathSeparatorQueryHandlerTests
|
||||
PathSeparatorResponse result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Separator.Should().Be(separator.ToString());
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(separator.ToString(), result.Separator);
|
||||
_mockPathService.Received(1);
|
||||
}
|
||||
|
||||
@@ -79,7 +78,7 @@ public class GetPathSeparatorQueryHandlerTests
|
||||
PathSeparatorResponse result2 = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result1.Should().BeEquivalentTo(result2);
|
||||
Assert.Equal(result1, result2);
|
||||
_mockPathService.Received(2);
|
||||
}
|
||||
|
||||
@@ -91,9 +90,11 @@ public class GetPathSeparatorQueryHandlerTests
|
||||
using CancellationTokenSource cts = new();
|
||||
|
||||
// Act
|
||||
Func<Task> act = async () => await _sut.Handle(query, cts.Token);
|
||||
Exception? exception = await Record.ExceptionAsync(
|
||||
async () => await _sut.Handle(query, cts.Token)
|
||||
);
|
||||
|
||||
// Assert
|
||||
await act.Should().NotThrowAsync();
|
||||
Assert.Null(exception);
|
||||
}
|
||||
}
|
||||
+4
-5
@@ -1,5 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.ValidatePath;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Queries.ValidatePath.Fixtures;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
@@ -41,7 +40,7 @@ public class ValidatePathQueryHandlerTests
|
||||
PathValidResponse result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsValid.Should().BeTrue();
|
||||
Assert.True(result.IsValid);
|
||||
_mockPathService.Received(1).IsValidPath(query.Path!);
|
||||
}
|
||||
|
||||
@@ -56,7 +55,7 @@ public class ValidatePathQueryHandlerTests
|
||||
PathValidResponse result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsValid.Should().BeFalse();
|
||||
Assert.False(result.IsValid);
|
||||
_mockPathService.Received(1).IsValidPath(query.Path!);
|
||||
}
|
||||
|
||||
@@ -71,7 +70,7 @@ public class ValidatePathQueryHandlerTests
|
||||
PathValidResponse result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsValid.Should().BeFalse();
|
||||
Assert.False(result.IsValid);
|
||||
_mockPathService.Received(1).IsValidPath(Arg.Any<string>());
|
||||
}
|
||||
|
||||
@@ -86,7 +85,7 @@ public class ValidatePathQueryHandlerTests
|
||||
PathValidResponse result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsValid.Should().BeFalse();
|
||||
Assert.False(result.IsValid);
|
||||
_mockPathService.Received(1).IsValidPath(Arg.Any<string>());
|
||||
}
|
||||
}
|
||||
+6
-8
@@ -2,9 +2,7 @@
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Core.FileSystemManagement.Thumbnails.Queries.GetThumbnail;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Thumbnails.Fixtures;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Thumbnails;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
@@ -47,10 +45,10 @@ public class GetThumbnailQueryHandlerTests
|
||||
ErrorOr<ThumbnailResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().NotBeNull();
|
||||
result.Value.Type.Should().Be(thumbnail.Type);
|
||||
result.Value.Bytes.Should().BeEquivalentTo(thumbnail.Bytes);
|
||||
Assert.False(result.IsError);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(thumbnail.Type, result.Value.Type);
|
||||
Assert.Equal(thumbnail.Bytes, result.Value.Bytes);
|
||||
await _mockThumbnailService.Received(1).GetThumbnailAsync(query.Path!, query.Quality, Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -67,8 +65,8 @@ public class GetThumbnailQueryHandlerTests
|
||||
ErrorOr<ThumbnailResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
await _mockThumbnailService.Received(1).GetThumbnailAsync(query.Path!, query.Quality, Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
|
||||
+25
-26
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Users;
|
||||
using Lumina.Application.Common.DataAccess.Seed;
|
||||
@@ -86,10 +85,10 @@ public class SetupApplicationCommandHandlerTests
|
||||
ErrorOr<RegistrationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().NotBeNull();
|
||||
result.Value.Username.Should().Be(command.Username);
|
||||
result.Value.TotpSecret.Should().BeNull();
|
||||
Assert.False(result.IsError);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(command.Username, result.Value.Username);
|
||||
Assert.Null(result.Value.TotpSecret);
|
||||
|
||||
await _mockUserRepository.Received(1).GetAllAsync(Arg.Any<CancellationToken>());
|
||||
await _mockUserRepository.Received(1).InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>());
|
||||
@@ -123,10 +122,10 @@ public class SetupApplicationCommandHandlerTests
|
||||
ErrorOr<RegistrationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().NotBeNull();
|
||||
result.Value.Username.Should().Be(command.Username);
|
||||
result.Value.TotpSecret.Should().Be(qrCodeUri);
|
||||
Assert.False(result.IsError);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(command.Username, result.Value.Username);
|
||||
Assert.Equal(qrCodeUri, result.Value.TotpSecret);
|
||||
|
||||
await _mockUserRepository.Received(1).GetAllAsync(Arg.Any<CancellationToken>());
|
||||
await _mockUserRepository.Received(1).InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>());
|
||||
@@ -147,8 +146,8 @@ public class SetupApplicationCommandHandlerTests
|
||||
ErrorOr<RegistrationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authorization.AdminAccountAlreadyCreated);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authorization.AdminAccountAlreadyCreated, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetAllAsync(Arg.Any<CancellationToken>());
|
||||
await _mockUserRepository.DidNotReceive().InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>());
|
||||
@@ -169,8 +168,8 @@ public class SetupApplicationCommandHandlerTests
|
||||
ErrorOr<RegistrationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetAllAsync(Arg.Any<CancellationToken>());
|
||||
await _mockUserRepository.DidNotReceive().InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>());
|
||||
@@ -193,8 +192,8 @@ public class SetupApplicationCommandHandlerTests
|
||||
ErrorOr<RegistrationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetAllAsync(Arg.Any<CancellationToken>());
|
||||
await _mockUserRepository.Received(1).InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>());
|
||||
@@ -219,8 +218,8 @@ public class SetupApplicationCommandHandlerTests
|
||||
ErrorOr<RegistrationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
|
||||
await _mockDataSeedService.Received(1).SetDefaultAuthorizationPermissionsAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockDataSeedService.DidNotReceive().SetDefaultAuthorizationRolesAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
@@ -246,8 +245,8 @@ public class SetupApplicationCommandHandlerTests
|
||||
ErrorOr<RegistrationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
|
||||
await _mockDataSeedService.Received(1).SetDefaultAuthorizationPermissionsAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockDataSeedService.Received(1).SetDefaultAuthorizationRolesAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
@@ -276,8 +275,8 @@ public class SetupApplicationCommandHandlerTests
|
||||
ErrorOr<RegistrationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
|
||||
await _mockDataSeedService.Received(1).SetDefaultAuthorizationPermissionsAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockDataSeedService.Received(1).SetDefaultAuthorizationRolesAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
@@ -309,8 +308,8 @@ public class SetupApplicationCommandHandlerTests
|
||||
ErrorOr<RegistrationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
|
||||
await _mockDataSeedService.Received(1).SetDefaultAuthorizationPermissionsAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockDataSeedService.Received(1).SetDefaultAuthorizationRolesAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
@@ -341,9 +340,9 @@ public class SetupApplicationCommandHandlerTests
|
||||
ErrorOr<RegistrationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().NotBeNull();
|
||||
result.Value.Username.Should().Be(command.Username);
|
||||
Assert.False(result.IsError);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(command.Username, result.Value.Username);
|
||||
|
||||
await _mockDataSeedService.Received(1).SetDefaultAuthorizationPermissionsAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
await _mockDataSeedService.Received(1).SetDefaultAuthorizationRolesAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
|
||||
+3
-6
@@ -1,8 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Users;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
@@ -54,7 +51,7 @@ public class CheckInitializationQueryHandlerTests
|
||||
InitializationResponse result = await _sut.Handle(new CheckInitializationQuery(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsInitialized.Should().BeTrue();
|
||||
Assert.True(result.IsInitialized);
|
||||
await _mockUserRepository.Received(1).GetAllAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -69,7 +66,7 @@ public class CheckInitializationQueryHandlerTests
|
||||
InitializationResponse result = await _sut.Handle(new CheckInitializationQuery(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsInitialized.Should().BeFalse();
|
||||
Assert.False(result.IsInitialized);
|
||||
await _mockUserRepository.Received(1).GetAllAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -85,7 +82,7 @@ public class CheckInitializationQueryHandlerTests
|
||||
InitializationResponse result = await _sut.Handle(new CheckInitializationQuery(), CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsInitialized.Should().BeFalse();
|
||||
Assert.False(result.IsInitialized);
|
||||
await _mockUserRepository.Received(1).GetAllAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
}
|
||||
+20
-21
@@ -2,7 +2,6 @@
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Books;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
@@ -66,8 +65,8 @@ public class AddBookCommandHandlerTests
|
||||
ErrorOr<BookResponse> result = await _sut.Handle(bookCommand, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeOfType<BookResponse>();
|
||||
Assert.False(result.IsError);
|
||||
Assert.IsType<BookResponse>(result.Value);
|
||||
await _mockBookRepository.Received(1).InsertAsync(Arg.Any<BookEntity>(), Arg.Any<CancellationToken>());
|
||||
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -83,8 +82,8 @@ public class AddBookCommandHandlerTests
|
||||
ErrorOr<BookResponse> result = await _sut.Handle(bookCommand, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.Errors.Should().Contain(e => e.Description == Errors.Metadata.TitleCannotBeEmpty.Description);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Contains(result.Errors, e => e.Description == Errors.Metadata.TitleCannotBeEmpty.Description);
|
||||
await _mockBookRepository.DidNotReceive().InsertAsync(Arg.Any<BookEntity>(), Arg.Any<CancellationToken>());
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -102,8 +101,8 @@ public class AddBookCommandHandlerTests
|
||||
ErrorOr<BookResponse> result = await _sut.Handle(bookCommand, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.Errors.Should().Contain(Errors.WrittenContent.BookAlreadyExists);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Contains(Errors.WrittenContent.BookAlreadyExists, result.Errors);
|
||||
await _mockBookRepository.Received(1).InsertAsync(Arg.Any<BookEntity>(), Arg.Any<CancellationToken>());
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -119,8 +118,8 @@ public class AddBookCommandHandlerTests
|
||||
ErrorOr<BookResponse> result = await _sut.Handle(bookCommand, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.Errors.Should().Contain(e => e.Description == Errors.WrittenContent.InvalidIsbn13Format.Description);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Contains(result.Errors, e => e.Description == Errors.WrittenContent.InvalidIsbn13Format.Description);
|
||||
await _mockBookRepository.DidNotReceive().InsertAsync(Arg.Any<BookEntity>(), Arg.Any<CancellationToken>());
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -136,8 +135,8 @@ public class AddBookCommandHandlerTests
|
||||
ErrorOr<BookResponse> result = await _sut.Handle(bookCommand, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.Errors.Should().Contain(e => e.Description == Errors.Metadata.RatingValueMustBePositive.Description);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Contains(result.Errors, e => e.Description == Errors.Metadata.RatingValueMustBePositive.Description);
|
||||
await _mockBookRepository.DidNotReceive().InsertAsync(Arg.Any<BookEntity>(), Arg.Any<CancellationToken>());
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -159,8 +158,8 @@ public class AddBookCommandHandlerTests
|
||||
ErrorOr<BookResponse> result = await _sut.Handle(bookCommand, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.Errors.Should().Contain(e => e.Description == Errors.Metadata.GenreNameCannotBeEmpty.Description);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Contains(result.Errors, e => e.Description == Errors.Metadata.GenreNameCannotBeEmpty.Description);
|
||||
await _mockBookRepository.DidNotReceive().InsertAsync(Arg.Any<BookEntity>(), Arg.Any<CancellationToken>());
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -182,8 +181,8 @@ public class AddBookCommandHandlerTests
|
||||
ErrorOr<BookResponse> result = await _sut.Handle(bookCommand, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.Errors.Should().Contain(e => e.Description == Errors.Metadata.TagNameCannotBeEmpty.Description);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Contains(result.Errors, e => e.Description == Errors.Metadata.TagNameCannotBeEmpty.Description);
|
||||
await _mockBookRepository.DidNotReceive().InsertAsync(Arg.Any<BookEntity>(), Arg.Any<CancellationToken>());
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -212,8 +211,8 @@ public class AddBookCommandHandlerTests
|
||||
ErrorOr<BookResponse> result = await _sut.Handle(bookCommand, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.Errors.Should().Contain(e => e.Description == Errors.Metadata.ReReleaseDateCannotBeEarlierThanOriginalReleaseDate.Description);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Contains(result.Errors, e => e.Description == Errors.Metadata.ReReleaseDateCannotBeEarlierThanOriginalReleaseDate.Description);
|
||||
await _mockBookRepository.DidNotReceive().InsertAsync(Arg.Any<BookEntity>(), Arg.Any<CancellationToken>());
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -235,8 +234,8 @@ public class AddBookCommandHandlerTests
|
||||
ErrorOr<BookResponse> result = await _sut.Handle(bookCommand, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.Errors.Should().Contain(e => e.Description == Errors.Metadata.LanguageCodeCannotBeEmpty.Description);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Contains(result.Errors, e => e.Description == Errors.Metadata.LanguageCodeCannotBeEmpty.Description);
|
||||
await _mockBookRepository.DidNotReceive().InsertAsync(Arg.Any<BookEntity>(), Arg.Any<CancellationToken>());
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -258,8 +257,8 @@ public class AddBookCommandHandlerTests
|
||||
ErrorOr<BookResponse> result = await _sut.Handle(bookCommand, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.Errors.Should().Contain(e => e.Description == Errors.Metadata.LanguageCodeCannotBeEmpty.Description);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Contains(result.Errors, e => e.Description == Errors.Metadata.LanguageCodeCannotBeEmpty.Description);
|
||||
await _mockBookRepository.DidNotReceive().InsertAsync(Arg.Any<BookEntity>(), Arg.Any<CancellationToken>());
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
+10
-11
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Users;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
@@ -76,8 +75,8 @@ public class ChangePasswordCommandHandlerTests
|
||||
ErrorOr<ChangePasswordResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.IsPasswordChanged.Should().BeTrue();
|
||||
Assert.False(result.IsError);
|
||||
Assert.True(result.Value.IsPasswordChanged);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>());
|
||||
_mockHashService.Received(1).CheckStringAgainstHash(currentPassword, "hashedCurrentPassword");
|
||||
@@ -99,8 +98,8 @@ public class ChangePasswordCommandHandlerTests
|
||||
ErrorOr<ChangePasswordResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authentication.UsernameDoesNotExist);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authentication.UsernameDoesNotExist, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(command.Username!, Arg.Any<CancellationToken>());
|
||||
await _mockUserRepository.DidNotReceive().UpdateAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>());
|
||||
@@ -129,8 +128,8 @@ public class ChangePasswordCommandHandlerTests
|
||||
ErrorOr<ChangePasswordResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authentication.InvalidCurrentPassword);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authentication.InvalidCurrentPassword, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>());
|
||||
_mockHashService.Received(1).CheckStringAgainstHash(incorrectPassword, Uri.UnescapeDataString(user.Password));
|
||||
@@ -167,8 +166,8 @@ public class ChangePasswordCommandHandlerTests
|
||||
ErrorOr<ChangePasswordResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>());
|
||||
_mockHashService.Received(1).CheckStringAgainstHash(currentPassword, "hashedCurrentPassword");
|
||||
@@ -197,8 +196,8 @@ public class ChangePasswordCommandHandlerTests
|
||||
ErrorOr<ChangePasswordResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(command.Username!, Arg.Any<CancellationToken>());
|
||||
await _mockUserRepository.DidNotReceive().InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>());
|
||||
|
||||
+16
-17
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Users;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
@@ -82,8 +81,8 @@ public class RecoverPasswordCommandHandlerTests
|
||||
ErrorOr<RecoverPasswordResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.IsPasswordReset.Should().BeTrue();
|
||||
Assert.False(result.IsError);
|
||||
Assert.True(result.Value.IsPasswordReset);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>());
|
||||
_mockTotpTokenGenerator.Received(1).ValidateToken(Arg.Any<byte[]>(), totpCode);
|
||||
@@ -105,8 +104,8 @@ public class RecoverPasswordCommandHandlerTests
|
||||
ErrorOr<RecoverPasswordResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authentication.UsernameDoesNotExist);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authentication.UsernameDoesNotExist, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(command.Username!, Arg.Any<CancellationToken>());
|
||||
await _mockUserRepository.DidNotReceive().UpdateAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>());
|
||||
@@ -130,8 +129,8 @@ public class RecoverPasswordCommandHandlerTests
|
||||
ErrorOr<RecoverPasswordResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authentication.PasswordResetAlreadyRequested);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authentication.PasswordResetAlreadyRequested, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>());
|
||||
await _mockUserRepository.DidNotReceive().UpdateAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>());
|
||||
@@ -154,8 +153,8 @@ public class RecoverPasswordCommandHandlerTests
|
||||
ErrorOr<RecoverPasswordResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authentication.InvalidTotpCode);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authentication.InvalidTotpCode, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>());
|
||||
await _mockUserRepository.DidNotReceive().UpdateAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>());
|
||||
@@ -186,8 +185,8 @@ public class RecoverPasswordCommandHandlerTests
|
||||
ErrorOr<RecoverPasswordResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authentication.InvalidTotpCode);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authentication.InvalidTotpCode, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>());
|
||||
_mockTotpTokenGenerator.Received(1).ValidateToken(Arg.Any<byte[]>(), totpCode);
|
||||
@@ -222,8 +221,8 @@ public class RecoverPasswordCommandHandlerTests
|
||||
ErrorOr<RecoverPasswordResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>());
|
||||
_mockTotpTokenGenerator.Received(1).ValidateToken(Arg.Any<byte[]>(), totpCode);
|
||||
@@ -251,8 +250,8 @@ public class RecoverPasswordCommandHandlerTests
|
||||
ErrorOr<RecoverPasswordResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(command.Username!, Arg.Any<CancellationToken>());
|
||||
await _mockUserRepository.DidNotReceive().InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>());
|
||||
@@ -277,8 +276,8 @@ public class RecoverPasswordCommandHandlerTests
|
||||
ErrorOr<RecoverPasswordResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authentication.InvalidTotpCode);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authentication.InvalidTotpCode, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any<CancellationToken>());
|
||||
_mockTotpTokenGenerator.DidNotReceive().ValidateToken(Arg.Any<byte[]>(), Arg.Any<string>());
|
||||
|
||||
+12
-13
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Users;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
@@ -88,9 +87,9 @@ public class RegisterUserCommandHandlerTests
|
||||
ErrorOr<RegistrationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Username.Should().Be(command.Username);
|
||||
result.Value.TotpSecret.Should().Be(qrCodeUri);
|
||||
Assert.False(result.IsError);
|
||||
Assert.Equal(command.Username, result.Value.Username);
|
||||
Assert.Equal(qrCodeUri, result.Value.TotpSecret);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(command.Username!, Arg.Any<CancellationToken>());
|
||||
_mockHashService.Received(1).HashString(command.Password!);
|
||||
@@ -119,9 +118,9 @@ public class RegisterUserCommandHandlerTests
|
||||
ErrorOr<RegistrationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Username.Should().Be(command.Username);
|
||||
result.Value.TotpSecret.Should().BeNull();
|
||||
Assert.False(result.IsError);
|
||||
Assert.Equal(command.Username, result.Value.Username);
|
||||
Assert.Null(result.Value.TotpSecret);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(command.Username!, Arg.Any<CancellationToken>());
|
||||
_mockHashService.Received(1).HashString(command.Password!);
|
||||
@@ -146,8 +145,8 @@ public class RegisterUserCommandHandlerTests
|
||||
ErrorOr<RegistrationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authentication.UsernameAlreadyExists);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authentication.UsernameAlreadyExists, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(command.Username!, Arg.Any<CancellationToken>());
|
||||
await _mockUserRepository.DidNotReceive().InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>());
|
||||
@@ -170,8 +169,8 @@ public class RegisterUserCommandHandlerTests
|
||||
ErrorOr<RegistrationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(command.Username!, Arg.Any<CancellationToken>());
|
||||
await _mockUserRepository.Received(1).InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>());
|
||||
@@ -192,8 +191,8 @@ public class RegisterUserCommandHandlerTests
|
||||
ErrorOr<RegistrationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).GetByUsernameAsync(command.Username!, Arg.Any<CancellationToken>());
|
||||
await _mockUserRepository.DidNotReceive().InsertAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>());
|
||||
|
||||
+7
-7
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Users;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
@@ -15,6 +14,7 @@ using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
@@ -68,8 +68,8 @@ public class GetUsersQueryHandlerTests
|
||||
ErrorOr<IEnumerable<UserResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authorization.NotAuthorized);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockUserRepository.DidNotReceive().GetAllAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ public class GetUsersQueryHandlerTests
|
||||
ErrorOr<IEnumerable<UserResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -110,7 +110,7 @@ public class GetUsersQueryHandlerTests
|
||||
ErrorOr<IEnumerable<UserResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().HaveCount(2);
|
||||
Assert.False(result.IsError);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
}
|
||||
}
|
||||
+29
-30
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Users;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
@@ -85,11 +84,11 @@ public class LoginUserQueryHandlerTests
|
||||
ErrorOr<LoginResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Id.Should().Be(user.Id);
|
||||
result.Value.Username.Should().Be(user.Username);
|
||||
result.Value.Token.Should().Be(jwtToken);
|
||||
result.Value.UsesTotp.Should().BeFalse();
|
||||
Assert.False(result.IsError);
|
||||
Assert.Equal(user.Id, result.Value.Id);
|
||||
Assert.Equal(user.Username, result.Value.Username);
|
||||
Assert.Equal(jwtToken, result.Value.Token);
|
||||
Assert.False(result.Value.UsesTotp);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -124,11 +123,11 @@ public class LoginUserQueryHandlerTests
|
||||
ErrorOr<LoginResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Id.Should().Be(user.Id);
|
||||
result.Value.Username.Should().Be(user.Username);
|
||||
result.Value.Token.Should().Be(jwtToken);
|
||||
result.Value.UsesTotp.Should().BeTrue();
|
||||
Assert.False(result.IsError);
|
||||
Assert.Equal(user.Id, result.Value.Id);
|
||||
Assert.Equal(user.Username, result.Value.Username);
|
||||
Assert.Equal(jwtToken, result.Value.Token);
|
||||
Assert.True(result.Value.UsesTotp);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -144,8 +143,8 @@ public class LoginUserQueryHandlerTests
|
||||
ErrorOr<LoginResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authentication.InvalidUsernameOrPassword);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authentication.InvalidUsernameOrPassword, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -170,8 +169,8 @@ public class LoginUserQueryHandlerTests
|
||||
ErrorOr<LoginResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authentication.InvalidUsernameOrPassword);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authentication.InvalidUsernameOrPassword, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -200,8 +199,8 @@ public class LoginUserQueryHandlerTests
|
||||
ErrorOr<LoginResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authentication.TempPasswordExpired);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authentication.TempPasswordExpired, result.FirstError);
|
||||
|
||||
await _mockUserRepository.Received(1).UpdateAsync(Arg.Is<UserEntity>(u =>
|
||||
u.TempPassword == null && u.TempPasswordCreated == null),
|
||||
@@ -240,11 +239,11 @@ public class LoginUserQueryHandlerTests
|
||||
ErrorOr<LoginResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Id.Should().Be(user.Id);
|
||||
result.Value.Username.Should().Be(user.Username);
|
||||
result.Value.Token.Should().Be(jwtToken);
|
||||
result.Value.UsesTotp.Should().BeFalse();
|
||||
Assert.False(result.IsError);
|
||||
Assert.Equal(user.Id, result.Value.Id);
|
||||
Assert.Equal(user.Username, result.Value.Username);
|
||||
Assert.Equal(jwtToken, result.Value.Token);
|
||||
Assert.False(result.Value.UsesTotp);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -270,8 +269,8 @@ public class LoginUserQueryHandlerTests
|
||||
ErrorOr<LoginResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authentication.InvalidTotpCode);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authentication.InvalidTotpCode, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -303,8 +302,8 @@ public class LoginUserQueryHandlerTests
|
||||
ErrorOr<LoginResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authentication.InvalidTotpCode);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authentication.InvalidTotpCode, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -321,8 +320,8 @@ public class LoginUserQueryHandlerTests
|
||||
ErrorOr<LoginResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -351,8 +350,8 @@ public class LoginUserQueryHandlerTests
|
||||
ErrorOr<LoginResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authentication.InvalidUsernameOrPassword);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authentication.InvalidUsernameOrPassword, result.FirstError);
|
||||
|
||||
_mockHashService.Received(1).CheckStringAgainstHash(password, hashedPassword);
|
||||
_mockHashService.Received(1).CheckStringAgainstHash(password, hashedTempPassword);
|
||||
|
||||
+18
-19
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Authorization;
|
||||
@@ -79,8 +78,8 @@ public class UpdateUserRoleAndPermissionsCommandHandlerTests
|
||||
ErrorOr<AuthorizationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(ApplicationErrors.Authorization.NotAuthorized);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(ApplicationErrors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockUserRepository.DidNotReceive().UpdateAsync(Arg.Any<UserEntity>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -98,8 +97,8 @@ public class UpdateUserRoleAndPermissionsCommandHandlerTests
|
||||
ErrorOr<AuthorizationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(DomainErrors.Users.UserDoesNotExist);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(DomainErrors.Users.UserDoesNotExist, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -120,8 +119,8 @@ public class UpdateUserRoleAndPermissionsCommandHandlerTests
|
||||
ErrorOr<AuthorizationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(ApplicationErrors.Authorization.RoleNotFound);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(ApplicationErrors.Authorization.RoleNotFound, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -166,8 +165,8 @@ public class UpdateUserRoleAndPermissionsCommandHandlerTests
|
||||
ErrorOr<AuthorizationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(ApplicationErrors.Authorization.CannotRemoveLastAdmin);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(ApplicationErrors.Authorization.CannotRemoveLastAdmin, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -196,8 +195,8 @@ public class UpdateUserRoleAndPermissionsCommandHandlerTests
|
||||
ErrorOr<AuthorizationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -246,10 +245,10 @@ public class UpdateUserRoleAndPermissionsCommandHandlerTests
|
||||
ErrorOr<AuthorizationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.UserId.Should().Be(command.UserId);
|
||||
result.Value.Role.Should().Be(role.RoleName);
|
||||
result.Value.Permissions.Should().HaveCount(command.Permissions.Count);
|
||||
Assert.False(result.IsError);
|
||||
Assert.Equal(command.UserId, result.Value.UserId);
|
||||
Assert.Equal(role.RoleName, result.Value.Role);
|
||||
Assert.Equal(command.Permissions.Count, result.Value.Permissions.Count);
|
||||
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -290,8 +289,8 @@ public class UpdateUserRoleAndPermissionsCommandHandlerTests
|
||||
ErrorOr<AuthorizationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -325,7 +324,7 @@ public class UpdateUserRoleAndPermissionsCommandHandlerTests
|
||||
ErrorOr<AuthorizationResponse> result = await _sut.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
}
|
||||
}
|
||||
+14
-15
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.Errors;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
@@ -53,10 +52,10 @@ public class GetAuthorizationQueryHandlerTests
|
||||
ErrorOr<AuthorizationResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.UserId.Should().Be(userId);
|
||||
result.Value.Role.Should().BeEquivalentTo(authEntity.Role);
|
||||
result.Value.Permissions.Should().BeEquivalentTo(authEntity.Permissions);
|
||||
Assert.False(result.IsError);
|
||||
Assert.Equal(userId, result.Value.UserId);
|
||||
Assert.Equal(authEntity.Role, result.Value.Role);
|
||||
Assert.Equal(authEntity.Permissions, result.Value.Permissions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -79,10 +78,10 @@ public class GetAuthorizationQueryHandlerTests
|
||||
ErrorOr<AuthorizationResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.UserId.Should().Be(targetUserId);
|
||||
result.Value.Role.Should().BeEquivalentTo(targetAuthEntity.Role);
|
||||
result.Value.Permissions.Should().BeEquivalentTo(targetAuthEntity.Permissions);
|
||||
Assert.False(result.IsError);
|
||||
Assert.Equal(targetUserId, result.Value.UserId);
|
||||
Assert.Equal(targetAuthEntity.Role, result.Value.Role);
|
||||
Assert.Equal(targetAuthEntity.Permissions, result.Value.Permissions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -102,8 +101,8 @@ public class GetAuthorizationQueryHandlerTests
|
||||
ErrorOr<AuthorizationResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authorization.NotAuthorized);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authorization.NotAuthorized, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -123,8 +122,8 @@ public class GetAuthorizationQueryHandlerTests
|
||||
ErrorOr<AuthorizationResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -147,7 +146,7 @@ public class GetAuthorizationQueryHandlerTests
|
||||
ErrorOr<AuthorizationResponse> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
}
|
||||
}
|
||||
+9
-11
@@ -1,7 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Users;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
@@ -70,8 +68,8 @@ public class GetUserPermissionsQueryHandlerTests
|
||||
ErrorOr<IEnumerable<PermissionResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authorization.NotAuthorized);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockUserRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -91,8 +89,8 @@ public class GetUserPermissionsQueryHandlerTests
|
||||
ErrorOr<IEnumerable<PermissionResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -110,8 +108,8 @@ public class GetUserPermissionsQueryHandlerTests
|
||||
ErrorOr<IEnumerable<PermissionResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authentication.UsernameDoesNotExist);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authentication.UsernameDoesNotExist, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -149,8 +147,8 @@ public class GetUserPermissionsQueryHandlerTests
|
||||
ErrorOr<IEnumerable<PermissionResponse>> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().HaveCount(1);
|
||||
result.Value.First().PermissionName.Should().Be(AuthorizationPermission.CanViewUsers);
|
||||
Assert.False(result.IsError);
|
||||
Assert.Single(result.Value);
|
||||
Assert.Equal(AuthorizationPermission.CanViewUsers, result.Value.First().PermissionName);
|
||||
}
|
||||
}
|
||||
+11
-12
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Users;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
@@ -67,8 +66,8 @@ public class GetUserRoleQueryHandlerTests
|
||||
ErrorOr<RoleResponse?> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authorization.NotAuthorized);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authorization.NotAuthorized, result.FirstError);
|
||||
await _mockUserRepository.DidNotReceive().GetByIdAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -88,8 +87,8 @@ public class GetUserRoleQueryHandlerTests
|
||||
ErrorOr<RoleResponse?> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(error);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(error, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -107,8 +106,8 @@ public class GetUserRoleQueryHandlerTests
|
||||
ErrorOr<RoleResponse?> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Authentication.UsernameDoesNotExist);
|
||||
Assert.True(result.IsError);
|
||||
Assert.Equal(Errors.Authentication.UsernameDoesNotExist, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -127,8 +126,8 @@ public class GetUserRoleQueryHandlerTests
|
||||
ErrorOr<RoleResponse?> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().BeNull();
|
||||
Assert.False(result.IsError);
|
||||
Assert.Null(result.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -163,8 +162,8 @@ public class GetUserRoleQueryHandlerTests
|
||||
ErrorOr<RoleResponse?> result = await _sut.Handle(query, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().NotBeNull();
|
||||
result.Value!.RoleName.Should().Be("TestRole");
|
||||
Assert.False(result.IsError);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Contains("TestRole", result.Value!.RoleName);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user