eliminates region sections

This commit is contained in:
BinaryAlley committed 2024-10-12 22:03:57 +03:00
1 parent 705c02b90d
commit 405fc1ff9a
370 files changed
+47 -1618

No files matched your search

@@ -21,12 +21,9 @@ namespace Lumina.Application.UnitTests.Common.Behaviors;
[ExcludeFromCodeCoverage]
public class ValidationBehaviorTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IValidator<ValidationBehaviorFixture> _mockValidator;
private readonly MessageHandlerDelegate<ValidationBehaviorFixture, ErrorOr<ValidationBehaviorTestResponse>> _nextDelegate;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="ValidationBehaviorTests"/> class.
/// </summary>
@@ -35,9 +32,7 @@ public class ValidationBehaviorTests
_mockValidator = Substitute.For<IValidator<ValidationBehaviorFixture>>();
_nextDelegate = Substitute.For<MessageHandlerDelegate<ValidationBehaviorFixture, ErrorOr<ValidationBehaviorTestResponse>>>();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task Handle_WhenValidatorIsNull_ShouldInvokeNextDelegate()
{
@@ -102,5 +97,4 @@ public class ValidationBehaviorTests
await _mockValidator.Received(1).ValidateAsync(request, Arg.Any<CancellationToken>());
await _nextDelegate.DidNotReceive().Invoke(request, Arg.Any<CancellationToken>());
}
#endregion
}
@@ -18,11 +18,8 @@ namespace Lumina.Application.UnitTests.Common.Converters;
[ExcludeFromCodeCoverage]
public class OptionalJsonConverterFactoryTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly OptionalJsonConverterFactory _factory;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="OptionalJsonConverterFactoryTests"/> class.
/// </summary>
@@ -30,9 +27,7 @@ public class OptionalJsonConverterFactoryTests
{
_factory = new OptionalJsonConverterFactory();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void CanConvert_WhenTypeIsOptional_ShouldReturnTrue()
{
@@ -113,5 +108,4 @@ public class OptionalJsonConverterFactoryTests
// Assert
converter.Should().BeOfType<OptionalJsonConverter<OptionalJsonConverterFactoryFixture>>();
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Application.UnitTests.Common.Converters;
[ExcludeFromCodeCoverage]
public class OptionalJsonConverterTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly JsonSerializerOptions _options;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="OptionalJsonConverterTests"/> class.
/// </summary>
@@ -28,9 +25,7 @@ public class OptionalJsonConverterTests
_options.Converters.Add(new OptionalJsonConverter<string>());
_options.Converters.Add(new OptionalJsonConverter<int>());
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Read_WhenJsonIsNull_ShouldReturnNone()
{
@@ -138,5 +133,4 @@ public class OptionalJsonConverterTests
// Assert
deserialized.Should().Be(original);
}
#endregion
}
@@ -20,13 +20,10 @@ namespace Lumina.Application.UnitTests.Common.Mapping.FileManagement;
[ExcludeFromCodeCoverage]
public class DirectoryMappingConfigTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly TypeAdapterConfig _config;
private readonly DirectoryMappingConfig _directoryMappingConfig;
private readonly FileSystemTreeMappingConfig _fileSystemTreeMappingConfig;
#endregion
#region ====================================================================== CTOR =====================================================================================
public DirectoryMappingConfigTests()
{
_config = new TypeAdapterConfig();
@@ -35,9 +32,7 @@ public class DirectoryMappingConfigTests
_directoryMappingConfig.Register(_config);
_fileSystemTreeMappingConfig.Register(_config);
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Register_WhenMappingDirectoryToFileSystemTreeNodeResponse_ShouldMapCorrectly()
{
@@ -115,5 +110,4 @@ public class DirectoryMappingConfigTests
result.DateCreated.Should().BeOnOrAfter(beforeMapping).And.BeOnOrBefore(afterMapping);
result.DateModified.Should().BeOnOrAfter(beforeMapping).And.BeOnOrBefore(afterMapping);
}
#endregion
}
@@ -16,13 +16,10 @@ namespace Lumina.Application.UnitTests.Common.Mapping.FileManagement;
[ExcludeFromCodeCoverage]
public class FileMappingConfigTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly TypeAdapterConfig _config;
private readonly FileMappingConfig _fileMappingConfig;
private readonly FileSystemTreeMappingConfig _fileSystemTreeMappingConfig;
#endregion
#region ====================================================================== CTOR =====================================================================================
public FileMappingConfigTests()
{
_config = new TypeAdapterConfig();
@@ -31,9 +28,7 @@ public class FileMappingConfigTests
_fileMappingConfig.Register(_config);
_fileSystemTreeMappingConfig.Register(_config);
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Register_WhenMappingFileToFileSystemTreeNodeResponse_ShouldMapCorrectly()
{
@@ -91,5 +86,4 @@ public class FileMappingConfigTests
result.DateModified.Should().Be(default);
result.Size.Should().Be(file.Size);
}
#endregion
}
@@ -18,21 +18,16 @@ namespace Lumina.Application.UnitTests.Common.Mapping.FileManagement;
[ExcludeFromCodeCoverage]
public class FileSystemTreeMappingConfigTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly TypeAdapterConfig _config;
private readonly FileSystemTreeMappingConfig _fileSystemTreeMappingConfig;
#endregion
#region ====================================================================== CTOR =====================================================================================
public FileSystemTreeMappingConfigTests()
{
_config = new TypeAdapterConfig();
_fileSystemTreeMappingConfig = new FileSystemTreeMappingConfig();
_fileSystemTreeMappingConfig.Register(_config);
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Register_WhenMappingWindowsRootItemToFileSystemTreeNodeResponse_ShouldMapCorrectly()
{
@@ -160,5 +155,4 @@ public class FileSystemTreeMappingConfigTests
result.ChildrenLoaded.Should().BeFalse();
result.Children.Should().BeEmpty();
}
#endregion
}
@@ -17,21 +17,16 @@ namespace Lumina.Application.UnitTests.Common.Mapping.FileManagement;
[ExcludeFromCodeCoverage]
public class PathSegmentMappingConfigTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly TypeAdapterConfig _config;
private readonly PathSegmentMappingConfig _pathSegmentMappingConfig;
#endregion
#region ====================================================================== CTOR =====================================================================================
public PathSegmentMappingConfigTests()
{
_config = new TypeAdapterConfig();
_pathSegmentMappingConfig = new PathSegmentMappingConfig();
_pathSegmentMappingConfig.Register(_config);
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Register_WhenMappingPathSegmentToPathSegmentResponse_ShouldMapCorrectly()
{
@@ -90,5 +85,4 @@ public class PathSegmentMappingConfigTests
results[i].Path.Should().Be(pathSegments[i].Name);
}
}
#endregion
}
@@ -18,13 +18,10 @@ namespace Lumina.Application.UnitTests.Common.Mapping.FileManagement;
[ExcludeFromCodeCoverage]
public class ThumbnailMappingConfigTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly TypeAdapterConfig _config;
private readonly ThumbnailMappingConfig _thumbnailMappingConfig;
private readonly Faker _faker;
#endregion
#region ====================================================================== CTOR =====================================================================================
public ThumbnailMappingConfigTests()
{
_config = new TypeAdapterConfig();
@@ -32,9 +29,7 @@ public class ThumbnailMappingConfigTests
_thumbnailMappingConfig.Register(_config);
_faker = new Faker();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Register_WhenMappingThumbnailToThumbnailResponse_ShouldMapCorrectly()
{
@@ -111,5 +106,4 @@ public class ThumbnailMappingConfigTests
results[i].Bytes.Should().BeEquivalentTo(thumbnails[i].Bytes);
}
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.Application.UnitTests.Common.Setup;
[ExcludeFromCodeCoverage]
public static class BogusExtensions
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Adds <see cref="DateOnly"/> random data generation support to the <see cref="Faker"/> class.
/// </summary>
@@ -36,5 +35,4 @@ public static class BogusExtensions
DateTime endDateTime = end.ToDateTime(TimeOnly.MinValue);
return System.DateOnly.FromDateTime(faker.Date.Between(startDateTime, endDateTime));
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.Application.UnitTests.Common.Setup;
[ExcludeFromCodeCoverage]
public class DateOnlySpecimenBuilder : ISpecimenBuilder
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Adds <see cref="DateOnly"/> support to the AutoFixture library.
/// </summary>
@@ -25,5 +24,4 @@ public class DateOnlySpecimenBuilder : ISpecimenBuilder
return DateOnly.FromDateTime(DateTime.Now);
return new NoSpecimen();
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.Application.UnitTests.Common.Setup;
[ExcludeFromCodeCoverage]
public class NullableDateOnlySpecimenBuilder : ISpecimenBuilder
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Adds <see cref="DateOnly?"/> support to the AutoFixture library.
/// </summary>
@@ -25,5 +24,4 @@ public class NullableDateOnlySpecimenBuilder : ISpecimenBuilder
return (DateOnly?)DateOnly.FromDateTime(DateTime.Now);
return new NoSpecimen();
}
#endregion
}
@@ -19,11 +19,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Directories.Fixtures;
[ExcludeFromCodeCoverage]
public class DirectoryFixture
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly Faker _faker;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="DirectoryFixture"/> class.
/// </summary>
@@ -31,9 +28,7 @@ public class DirectoryFixture
{
_faker = new Faker();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid <see cref="Directory"/>.
/// </summary>
@@ -112,5 +107,4 @@ public class DirectoryFixture
}
return CreateDirectory(childItems: childItems);
}
#endregion
}
@@ -14,12 +14,9 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Directories.Fixtures;
[ExcludeFromCodeCoverage]
public class DirectoryResponseFixture
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly Faker _faker = new();
private readonly FileSystemItemModelFixture _fileSystemItemModelFixture = new();
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid <see cref="DirectoryResponse"/>.
/// </summary>
@@ -46,5 +43,4 @@ public class DirectoryResponseFixture
{
return Enumerable.Range(0, count).Select(_ => Create(itemCount)).ToList();
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Directories.Fixtures;
[ExcludeFromCodeCoverage]
public class FileSystemItemModelFixture
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly Faker _faker = new();
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid <see cref="FileSystemItemModel"/>.
/// </summary>
@@ -42,5 +39,4 @@ public class FileSystemItemModelFixture
{
return Enumerable.Range(0, count).Select(_ => Create()).ToList();
}
#endregion
}
@@ -15,11 +15,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Directories.Fixtures;
[ExcludeFromCodeCoverage]
public class FileSystemTreeNodeResponseFixture
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly Faker _faker = new();
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a single <see cref="FileSystemTreeNodeResponse"/> with a nested structure.
/// </summary>
@@ -58,5 +55,4 @@ public class FileSystemTreeNodeResponseFixture
{
return Enumerable.Range(0, count).Select(_ => Create(0, maxDepth, maxChildren)).ToList();
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Directories.Queries.G
[ExcludeFromCodeCoverage]
public class GetDirectoriesQueryFixture
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid query to get directories.
/// </summary>
@@ -28,5 +27,4 @@ public class GetDirectoriesQueryFixture
.RuleFor(x => x.Path, f => f.System.DirectoryPath())
.RuleFor(x => x.IncludeHiddenElements, f => includeHiddenElements);
}
#endregion
}
@@ -27,16 +27,13 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Directories.Queries.G
[ExcludeFromCodeCoverage]
public class GetDirectoriesQueryHandlerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
private readonly IMapper _mockMapper;
private readonly IDirectoryService _mockDirectoryService;
private readonly GetDirectoriesQueryHandler _sut;
private readonly DirectoryFixture _directoryFixture;
private readonly DirectoryResponseFixture _directoryResponseFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetDirectoriesQueryHandlerTests"/> class.
/// </summary>
@@ -49,9 +46,7 @@ public class GetDirectoriesQueryHandlerTests
_directoryFixture = new DirectoryFixture();
_directoryResponseFixture = new DirectoryResponseFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task Handle_WhenCalledWithValidQueryWithoutFilesIncluded_ShouldReturnSuccessResult()
{
@@ -139,5 +134,4 @@ public class GetDirectoriesQueryHandlerTests
result.Value.Should().BeEmpty();
_mockDirectoryService.Received(1).GetSubdirectories(query.Path, query.IncludeHiddenElements);
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Directories.Queries.G
[ExcludeFromCodeCoverage]
public class GetDirectoriesQueryValidatorTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly GetDirectoriesQueryValidator _validator;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetDirectoriesQueryValidatorTests"/> class.
/// </summary>
@@ -26,9 +23,7 @@ public class GetDirectoriesQueryValidatorTests
{
_validator = new GetDirectoriesQueryValidator();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Validate_WhenPathIsNull_ShouldHaveValidationError()
{
@@ -115,5 +110,4 @@ public class GetDirectoriesQueryValidatorTests
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.IncludeHiddenElements);
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Directories.Queries.G
[ExcludeFromCodeCoverage]
public class GetDirectoryTreeQueryFixture
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid query to get directory tree.
/// </summary>
@@ -31,5 +30,4 @@ public class GetDirectoryTreeQueryFixture
.RuleFor(x => x.IncludeFiles, f => includeFiles)
.RuleFor(x => x.IncludeHiddenElements, f => includeHiddenElements);
}
#endregion
}
@@ -29,7 +29,6 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Directories.Queries.G
[ExcludeFromCodeCoverage]
public class GetDirectoryTreeQueryHandlerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
private readonly IDriveService _mockDriveService;
private readonly IDirectoryService _mockDirectoryService;
@@ -40,9 +39,7 @@ public class GetDirectoryTreeQueryHandlerTests
private readonly DirectoryFixture _directoryFixture;
private readonly PathSegmentFixture _pathSegmentFixture;
private readonly FileFixture _fileFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetDirectoryTreeQueryHandlerTests"/> class.
/// </summary>
@@ -59,9 +56,7 @@ public class GetDirectoryTreeQueryHandlerTests
_pathSegmentFixture = new PathSegmentFixture();
_fileFixture = new FileFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task Handle_WhenCalledWithValidQueryAndNoIncludeFiles_ShouldReturnSuccessResult()
{
@@ -391,5 +386,4 @@ public class GetDirectoryTreeQueryHandlerTests
result.Value.First().Children.Should().HaveCount(2);
_mockDirectoryService.Received(1).GetSubdirectories(Arg.Any<string>(), false);
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Directories.Queries.G
[ExcludeFromCodeCoverage]
public class GetDirectoryTreeQueryValidatorTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly GetDirectoryTreeQueryValidator _validator;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetDirectoryTreeQueryValidatorTests"/> class.
/// </summary>
@@ -26,9 +23,7 @@ public class GetDirectoryTreeQueryValidatorTests
{
_validator = new GetDirectoryTreeQueryValidator();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Validate_WhenPathIsNull_ShouldHaveValidationError()
{
@@ -143,5 +138,4 @@ public class GetDirectoryTreeQueryValidatorTests
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.IncludeFiles);
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Directories.Queries.G
[ExcludeFromCodeCoverage]
public class GetTreeDirectoriesQueryFixture
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid query to get tree directories.
/// </summary>
@@ -28,5 +27,4 @@ public class GetTreeDirectoriesQueryFixture
.RuleFor(x => x.Path, f => f.System.DirectoryPath())
.RuleFor(x => x.IncludeHiddenElements, f => includeHiddenElements);
}
#endregion
}
@@ -32,7 +32,6 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Directories.Queries.G
[ExcludeFromCodeCoverage]
public class GetTreeDirectoriesQueryHandlerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
private readonly IMapper _mockMapper;
private readonly IDirectoryService _mockDirectoryService;
@@ -40,9 +39,7 @@ public class GetTreeDirectoriesQueryHandlerTests
private readonly GetTreeDirectoriesQueryFixture _getTreeDirectoriesQueryFixture;
private readonly DirectoryFixture _directoryFixture;
private readonly FileSystemTreeNodeResponseFixture _fileSystemTreeNodeResponseFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetTreeDirectoriesQueryHandlerTests"/> class.
/// </summary>
@@ -56,9 +53,7 @@ public class GetTreeDirectoriesQueryHandlerTests
_directoryFixture = new DirectoryFixture();
_fileSystemTreeNodeResponseFixture = new FileSystemTreeNodeResponseFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task Handle_WhenCalledWithValidQueryWithoutFilesIncluded_ShouldReturnSuccessResult()
{
@@ -170,5 +165,4 @@ public class GetTreeDirectoriesQueryHandlerTests
result.Value.Should().BeEquivalentTo(nestedResponses, options => options.IncludingNestedObjects());
result.Value.Any(r => r.Children.Count != 0).Should().BeTrue();
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Directories.Queries.G
[ExcludeFromCodeCoverage]
public class GetTreeDirectoriesQueryValidatorTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly GetTreeDirectoriesQueryValidator _validator;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetTreeDirectoriesQueryValidatorTests"/> class.
/// </summary>
@@ -26,9 +23,7 @@ public class GetTreeDirectoriesQueryValidatorTests
{
_validator = new GetTreeDirectoriesQueryValidator();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Validate_WhenPathIsNull_ShouldHaveValidationError()
{
@@ -115,5 +110,4 @@ public class GetTreeDirectoriesQueryValidatorTests
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.IncludeHiddenElements);
}
#endregion
}
@@ -15,11 +15,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Drives.Queries.GetDri
[ExcludeFromCodeCoverage]
public class GetDrivesQueryFixture
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly Faker _faker = new();
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a single <see cref="FileSystemTreeNodeResponse"/> with a nested structure.
/// </summary>
@@ -58,5 +55,4 @@ public class GetDrivesQueryFixture
{
return Enumerable.Range(0, count).Select(_ => Create(0, maxDepth, maxChildren)).ToList();
}
#endregion
}
@@ -26,15 +26,12 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Drives.Queries.GetDri
[ExcludeFromCodeCoverage]
public class GetDrivesQueryHandlerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
private readonly IMapper _mockMapper;
private readonly IDriveService _mockDriveService;
private readonly GetDrivesQueryHandler _sut;
private readonly GetDrivesQueryFixture _getDrivesQueryFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetDrivesQueryHandlerTests"/> class.
/// </summary>
@@ -46,9 +43,7 @@ public class GetDrivesQueryHandlerTests
_sut = new GetDrivesQueryHandler(_mockDriveService, _mockMapper);
_getDrivesQueryFixture = new GetDrivesQueryFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task Handle_WhenCalled_ShouldReturnSuccessResult()
{
@@ -119,5 +114,4 @@ public class GetDrivesQueryHandlerTests
_mockDriveService.Received(1).GetDrives();
_mockMapper.Received(1).Map<IEnumerable<FileSystemTreeNodeResponse>>(Arg.Any<IEnumerable<FileSystemItem>>());
}
#endregion
}
@@ -21,14 +21,11 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.FileSystem.Queries.Ge
[ExcludeFromCodeCoverage]
public class GetFileSystemQueryHandlerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
private readonly IPlatformContextManager _mockPlatformContextManager;
private readonly IPlatformContext _mockPlatformContext;
private readonly GetFileSystemQueryHandler _sut;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetFileSystemQueryHandlerTests"/> class.
/// </summary>
@@ -40,9 +37,7 @@ public class GetFileSystemQueryHandlerTests
_mockPlatformContextManager.GetCurrentContext().Returns(_mockPlatformContext);
_sut = new GetFileSystemQueryHandler(_mockPlatformContextManager);
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Theory]
[InlineData(PlatformType.Unix)]
[InlineData(PlatformType.Windows)]
@@ -110,5 +105,4 @@ public class GetFileSystemQueryHandlerTests
await act.Should().NotThrowAsync();
_mockPlatformContextManager.Received(1).GetCurrentContext();
}
#endregion
}
@@ -18,11 +18,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Files.Fixtures;
[ExcludeFromCodeCoverage]
public class FileFixture
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly Faker _faker;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="FileFixture"/> class.
/// </summary>
@@ -30,9 +27,7 @@ public class FileFixture
{
_faker = new Faker();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid <see cref="File"/>.
/// </summary>
@@ -84,5 +79,4 @@ public class FileFixture
FileSystemItemStatus.Accessible
).Value;
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Files.Fixtures;
[ExcludeFromCodeCoverage]
public class FileResponseFixture
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly Faker _faker = new();
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid <see cref="FileResponse"/>.
/// </summary>
@@ -43,5 +40,4 @@ public class FileResponseFixture
{
return Enumerable.Range(0, count).Select(_ => Create()).ToList();
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Files.Queries.GetFile
[ExcludeFromCodeCoverage]
public class GetFilesQueryFixture
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid query to get files.
/// </summary>
@@ -28,5 +27,4 @@ public class GetFilesQueryFixture
.RuleFor(x => x.Path, f => f.System.FilePath())
.RuleFor(x => x.IncludeHiddenElements, f => includeHiddenElements);
}
#endregion
}
@@ -28,16 +28,13 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Files.Queries.GetFile
[ExcludeFromCodeCoverage]
public class GetFilesQueryHandlerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
private readonly IMapper _mockMapper;
private readonly IFileService _mockFileService;
private readonly GetFilesQueryHandler _sut;
private readonly FileFixture _fileFixture;
private readonly FileResponseFixture _fileResponseFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetFilesQueryHandlerTests"/> class.
/// </summary>
@@ -50,9 +47,7 @@ public class GetFilesQueryHandlerTests
_fileFixture = new FileFixture();
_fileResponseFixture = new FileResponseFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task Handle_WhenCalledWithValidQueryWithoutHiddenFiles_ShouldReturnSuccessResult()
{
@@ -145,5 +140,4 @@ public class GetFilesQueryHandlerTests
_mockFileService.Received(1).GetFiles(query.Path, query.IncludeHiddenElements);
_mockMapper.Received(1).Map<IEnumerable<FileResponse>>(Arg.Is<IEnumerable<File>>(f => !f.Any()));
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Files.Queries.GetFile
[ExcludeFromCodeCoverage]
public class GetFilesQueryValidatorTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly GetFilesQueryValidator _validator;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetFilesQueryValidatorTests"/> class.
/// </summary>
@@ -26,9 +23,7 @@ public class GetFilesQueryValidatorTests
{
_validator = new GetFilesQueryValidator();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Validate_WhenPathIsNull_ShouldHaveValidationError()
{
@@ -115,5 +110,4 @@ public class GetFilesQueryValidatorTests
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.IncludeHiddenElements);
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Files.Queries.GetTree
[ExcludeFromCodeCoverage]
public class GetTreeFilesQueryFixture
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid query to get files.
/// </summary>
@@ -28,5 +27,4 @@ public class GetTreeFilesQueryFixture
.RuleFor(x => x.Path, f => f.System.FilePath())
.RuleFor(x => x.IncludeHiddenElements, f => includeHiddenElements);
}
#endregion
}
@@ -27,16 +27,13 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Files.Queries.GetTree
[ExcludeFromCodeCoverage]
public class GetTreeFilesQueryHandlerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
private readonly IMapper _mockMapper;
private readonly IFileService _mockFileService;
private readonly GetTreeFilesQueryHandler _sut;
private readonly FileFixture _fileFixture;
private readonly FileSystemTreeNodeResponseFixture _fileSystemTreeNodeResponseFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetTreeFilesQueryHandler"/> class.
/// </summary>
@@ -49,9 +46,7 @@ public class GetTreeFilesQueryHandlerTests
_fileFixture = new FileFixture();
_fileSystemTreeNodeResponseFixture = new FileSystemTreeNodeResponseFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task Handle_WhenCalledWithValidQueryWithoutHiddenFiles_ShouldReturnSuccessResult()
{
@@ -139,5 +134,4 @@ public class GetTreeFilesQueryHandlerTests
result.Value.Should().BeEmpty();
_mockFileService.Received(1).GetFiles(query.Path, query.IncludeHiddenElements);
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Files.Queries.GetTree
[ExcludeFromCodeCoverage]
public class GetTreeFilesQueryValidatorTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly GetTreeFilesQueryValidator _validator;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetTreeFilesQueryValidatorTests"/> class.
/// </summary>
@@ -26,9 +23,7 @@ public class GetTreeFilesQueryValidatorTests
{
_validator = new GetTreeFilesQueryValidator();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Validate_WhenPathIsNull_ShouldHaveValidationError()
{
@@ -115,5 +110,4 @@ public class GetTreeFilesQueryValidatorTests
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.IncludeHiddenElements);
}
#endregion
}
@@ -21,13 +21,10 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Commands.Combine
[ExcludeFromCodeCoverage]
public class CombinePathCommandHandlerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
private readonly IPathService _mockPathService;
private readonly CombinePathCommandHandler _sut;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="CombinePathCommandHandlerTests"/> class.
/// </summary>
@@ -37,9 +34,7 @@ public class CombinePathCommandHandlerTests
_mockPathService = Substitute.For<IPathService>();
_sut = new CombinePathCommandHandler(_mockPathService);
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task Handle_WhenCalledWithValidCommand_ShouldReturnSuccessResult()
{
@@ -95,5 +90,4 @@ public class CombinePathCommandHandlerTests
result.Value.Path.Should().BeEmpty();
_mockPathService.Received(1).CombinePath(command.OriginalPath, command.NewPath);
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Commands.Combine
[ExcludeFromCodeCoverage]
public class CombinePathCommandValidatorTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly CombinePathCommandValidator _validator;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="CombinePathCommandValidatorTests"/> class.
/// </summary>
@@ -26,9 +23,7 @@ public class CombinePathCommandValidatorTests
{
_validator = new CombinePathCommandValidator();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Validate_WhenOriginalPathIsNull_ShouldHaveValidationError()
{
@@ -133,5 +128,4 @@ public class CombinePathCommandValidatorTests
result.ShouldNotHaveValidationErrorFor(x => x.OriginalPath);
result.ShouldNotHaveValidationErrorFor(x => x.NewPath);
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Commands.Combine
[ExcludeFromCodeCoverage]
public class CombinePathCommandFixture
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid command to combine paths.
/// </summary>
@@ -27,5 +26,4 @@ public class CombinePathCommandFixture
.RuleFor(x => x.OriginalPath, f => f.System.FilePath())
.RuleFor(x => x.NewPath, f => f.System.FilePath());
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Commands.SplitPa
[ExcludeFromCodeCoverage]
public class SplitPathCommandFixture
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid command for splitting paths.
/// </summary>
@@ -25,5 +24,4 @@ public class SplitPathCommandFixture
))
.RuleFor(x => x.Path, f => f.System.FilePath());
}
#endregion
}
@@ -29,7 +29,6 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Commands.SplitPa
[ExcludeFromCodeCoverage]
public class SplitPathCommandHandlerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
private readonly IMapper _mockMapper;
private readonly IPathService _mockPathService;
@@ -38,9 +37,7 @@ public class SplitPathCommandHandlerTests
private readonly PathSegmentResponseFixture _pathSegmentResponseFixture;
private readonly PathSegmentMappingConfig _pathSegmentMappingConfig;
private readonly TypeAdapterConfig _config;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="SplitPathCommandHandlerTests"/> class.
/// </summary>
@@ -57,9 +54,7 @@ public class SplitPathCommandHandlerTests
_pathSegmentMappingConfig = new PathSegmentMappingConfig();
_pathSegmentMappingConfig.Register(_config);
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task Handle_WhenCalledWithValidCommand_ShouldReturnSuccessResult()
{
@@ -126,5 +121,4 @@ public class SplitPathCommandHandlerTests
_mockPathService.Received(1).ParsePath(command.Path);
_mockMapper.Received(1).Map<IEnumerable<PathSegmentResponse>>(Arg.Any<IEnumerable<PathSegment>>());
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Commands.SplitPa
[ExcludeFromCodeCoverage]
public class SplitPathCommandValidatorTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly SplitPathCommandValidator _validator;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="SplitPathCommandValidatorTests"/> class.
/// </summary>
@@ -26,9 +23,7 @@ public class SplitPathCommandValidatorTests
{
_validator = new SplitPathCommandValidator();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Validate_WhenPathIsNull_ShouldHaveValidationError()
{
@@ -87,5 +82,4 @@ public class SplitPathCommandValidatorTests
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.Path);
}
#endregion
}
@@ -16,11 +16,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Fixtures;
[ExcludeFromCodeCoverage]
public class PathSegmentFixture
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly Faker _faker;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="PathSegmentFixture"/> class.
/// </summary>
@@ -28,9 +25,7 @@ public class PathSegmentFixture
{
_faker = new Faker();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid <see cref="PathSegment"/>.
/// </summary>
@@ -60,5 +55,4 @@ public class PathSegmentFixture
{
return Enumerable.Range(0, count).Select(_ => CreatePathSegment()).ToList();
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Fixtures;
[ExcludeFromCodeCoverage]
public class PathSegmentResponseFixture
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly Faker _faker = new();
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid <see cref="PathSegmentResponse"/>.
/// </summary>
@@ -37,5 +34,4 @@ public class PathSegmentResponseFixture
{
return Enumerable.Range(0, count).Select(_ => Create()).ToList();
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Fixtures;
[ExcludeFromCodeCoverage]
public class PathSeparatorResponseFixture
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly Faker _faker = new();
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid <see cref="PathSeparatorResponse"/>.
/// </summary>
@@ -37,5 +34,4 @@ public class PathSeparatorResponseFixture
{
return Enumerable.Range(0, count).Select(_ => Create()).ToList();
}
#endregion
}
@@ -18,12 +18,9 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Queries.CheckPat
[ExcludeFromCodeCoverage]
public class CheckPathExistsQueryHandlerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IPathService _mockPathService;
private readonly CheckPathExistsQueryHandler _sut;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="CheckPathExistsQueryHandlerTests"/> class.
/// </summary>
@@ -32,9 +29,7 @@ public class CheckPathExistsQueryHandlerTests
_mockPathService = Substitute.For<IPathService>();
_sut = new CheckPathExistsQueryHandler(_mockPathService);
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task Handle_WhenPathExistsAndIsNotHidden_ShouldReturnTrueResponse()
{
@@ -125,5 +120,4 @@ public class CheckPathExistsQueryHandlerTests
result.Exists.Should().BeTrue();
_mockPathService.Received(1).Exists(query.Path);
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Queries.CheckPat
[ExcludeFromCodeCoverage]
public class CheckPathExistsQueryValidatorTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly CheckPathExistsQueryValidator _validator;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="CheckPathExistsQueryValidatorTests"/> class.
/// </summary>
@@ -26,9 +23,7 @@ public class CheckPathExistsQueryValidatorTests
{
_validator = new CheckPathExistsQueryValidator();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Validate_WhenPathIsNull_ShouldHaveValidationError()
{
@@ -87,5 +82,4 @@ public class CheckPathExistsQueryValidatorTests
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.Path);
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Queries.CheckPat
[ExcludeFromCodeCoverage]
public class CheckPathExistsQueryFixture
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid query to check if paths exist.
/// </summary>
@@ -28,5 +27,4 @@ public class CheckPathExistsQueryFixture
.RuleFor(x => x.Path, f => f.System.FilePath())
.RuleFor(x => x.IncludeHiddenElements, includeHiddenElements);
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Queries.GetPathP
[ExcludeFromCodeCoverage]
public class GetPathParentQueryFixture
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid query to check if paths exist.
/// </summary>
@@ -25,5 +24,4 @@ public class GetPathParentQueryFixture
))
.RuleFor(x => x.Path, f => f.System.FilePath());
}
#endregion
}
@@ -26,16 +26,13 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Queries.GetPathP
[ExcludeFromCodeCoverage]
public class GetPathParentQueryHandlerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
private readonly IMapper _mockMapper;
private readonly IPathService _mockPathService;
private readonly GetPathParentQueryHandler _sut;
private readonly PathSegmentFixture _pathSegmentFixture;
private readonly PathSegmentResponseFixture _pathSegmentResponseFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
public GetPathParentQueryHandlerTests()
{
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
@@ -45,9 +42,7 @@ public class GetPathParentQueryHandlerTests
_pathSegmentFixture = new PathSegmentFixture();
_pathSegmentResponseFixture = new PathSegmentResponseFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task Handle_WhenCalledWithValidQuery_ShouldReturnSuccessResult()
{
@@ -114,5 +109,4 @@ public class GetPathParentQueryHandlerTests
_mockPathService.Received(1).GoUpOneLevel(query.Path);
_mockMapper.Received(1).Map<IEnumerable<PathSegmentResponse>>(Arg.Is<IEnumerable<PathSegment>>(p => !p.Any()));
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Queries.GetPathP
[ExcludeFromCodeCoverage]
public class GetPathParentQueryValidatorTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly GetPathParentQueryValidator _validator;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetPathParentQueryValidatorTests"/> class.
/// </summary>
@@ -26,9 +23,7 @@ public class GetPathParentQueryValidatorTests
{
_validator = new GetPathParentQueryValidator();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Validate_WhenPathIsNull_ShouldHaveValidationError()
{
@@ -87,5 +82,4 @@ public class GetPathParentQueryValidatorTests
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.Path);
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Queries.GetPathR
[ExcludeFromCodeCoverage]
public class GetPathRootQueryFixture
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid query to check if paths exist.
/// </summary>
@@ -25,5 +24,4 @@ public class GetPathRootQueryFixture
))
.RuleFor(x => x.Path, f => f.System.FilePath());
}
#endregion
}
@@ -24,16 +24,13 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Queries.GetPathR
[ExcludeFromCodeCoverage]
public class GetPathRootQueryHandlerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
private readonly IMapper _mockMapper;
private readonly IPathService _mockPathService;
private readonly GetPathRootQueryHandler _sut;
private readonly PathSegmentFixture _pathSegmentFixture;
private readonly PathSegmentResponseFixture _pathSegmentResponseFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetPathRootQueryHandlerTests"/> class.
/// </summary>
@@ -46,9 +43,7 @@ public class GetPathRootQueryHandlerTests
_pathSegmentFixture = new PathSegmentFixture();
_pathSegmentResponseFixture = new PathSegmentResponseFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task Handle_WhenCalledWithValidQuery_ShouldReturnSuccessResult()
{
@@ -115,5 +110,4 @@ public class GetPathRootQueryHandlerTests
_mockPathService.Received(1).GetPathRoot(query.Path);
_mockMapper.Received(1).Map<PathSegmentResponse>(Arg.Is<PathSegment>(p => p == rootPathSegment));
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Queries.GetPathR
[ExcludeFromCodeCoverage]
public class GetPathRootQueryValidatorTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly GetPathRootQueryValidator _validator;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetPathRootQueryValidatorTests"/> class.
/// </summary>
@@ -26,9 +23,7 @@ public class GetPathRootQueryValidatorTests
{
_validator = new GetPathRootQueryValidator();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Validate_WhenPathIsNull_ShouldHaveValidationError()
{
@@ -87,5 +82,4 @@ public class GetPathRootQueryValidatorTests
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.Path);
}
#endregion
}
@@ -18,12 +18,9 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Queries.GetPathS
[ExcludeFromCodeCoverage]
public class GetPathSeparatorQueryHandlerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IPathService _mockPathService;
private readonly GetPathSeparatorQueryHandler _sut;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetPathSeparatorQueryHandlerTests"/> class.
/// </summary>
@@ -32,9 +29,7 @@ public class GetPathSeparatorQueryHandlerTests
_mockPathService = Substitute.For<IPathService>();
_sut = new GetPathSeparatorQueryHandler(_mockPathService);
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task Handle_WhenCalled_ShouldReturnPathSeparatorResponse()
{
@@ -101,5 +96,4 @@ public class GetPathSeparatorQueryHandlerTests
// Assert
await act.Should().NotThrowAsync();
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Queries.Validate
[ExcludeFromCodeCoverage]
public class ValidatePathQueryFixure
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid query to check if paths exist.
/// </summary>
@@ -25,5 +24,4 @@ public class ValidatePathQueryFixure
))
.RuleFor(x => x.Path, f => f.System.FilePath());
}
#endregion
}
@@ -18,12 +18,9 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Queries.Validate
[ExcludeFromCodeCoverage]
public class ValidatePathQueryHandlerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IPathService _mockPathService;
private readonly ValidatePathQueryHandler _sut;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="ValidatePathQueryHandlerTests"/> class.
/// </summary>
@@ -32,9 +29,7 @@ public class ValidatePathQueryHandlerTests
_mockPathService = Substitute.For<IPathService>();
_sut = new ValidatePathQueryHandler(_mockPathService);
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task Handle_WhenCalledWithValidPath_ShouldReturnTrueResponse()
{
@@ -94,5 +89,4 @@ public class ValidatePathQueryHandlerTests
result.IsValid.Should().BeFalse();
_mockPathService.Received(1).IsValidPath(Arg.Any<string>());
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Pahs.Queries.Validate
[ExcludeFromCodeCoverage]
public class ValidatePathQueryValidatorTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly ValidatePathQueryValidator _validator;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="ValidatePathQueryValidatorTests"/> class.
/// </summary>
@@ -26,9 +23,7 @@ public class ValidatePathQueryValidatorTests
{
_validator = new ValidatePathQueryValidator();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Validate_WhenPathIsNull_ShouldHaveValidationError()
{
@@ -87,5 +82,4 @@ public class ValidatePathQueryValidatorTests
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.Path);
}
#endregion
}
@@ -13,7 +13,6 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Thumbnails.Fixtures;
[ExcludeFromCodeCoverage]
public class ThumbnailResponseFixture
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid query to get a thumbnail.
/// </summary>
@@ -28,5 +27,4 @@ public class ThumbnailResponseFixture
.RuleFor(x => x.Type, f => f.PickRandom<ImageType>())
.RuleFor(x => x.Bytes, f => f.Random.Bytes(20));
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Thumbnails.Queries.Ge
[ExcludeFromCodeCoverage]
public class GetThumbnailQueryFixture
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid query to get a thumbnail.
/// </summary>
@@ -27,5 +26,4 @@ public class GetThumbnailQueryFixture
.RuleFor(x => x.Path, f => f.System.FilePath())
.RuleFor(x => x.Quality, f => f.Random.Int());
}
#endregion
}
@@ -23,14 +23,11 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Thumbnails.Queries.Ge
[ExcludeFromCodeCoverage]
public class GetThumbnailQueryHandlerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
private readonly IThumbnailService _mockThumbnailService;
private readonly IMapper _mockMapper;
private readonly GetThumbnailQueryHandler _sut;
#endregion
#region ====================================================================== CTOR =====================================================================================
public GetThumbnailQueryHandlerTests()
{
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
@@ -38,9 +35,7 @@ public class GetThumbnailQueryHandlerTests
_mockMapper = Substitute.For<IMapper>();
_sut = new GetThumbnailQueryHandler(_mockThumbnailService, _mockMapper);
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task Handle_WhenCalledWithValidQuery_ShouldReturnSuccessResult()
{
@@ -100,5 +95,4 @@ public class GetThumbnailQueryHandlerTests
await _mockThumbnailService.Received(1).GetThumbnailAsync(query.Path, query.Quality, cts.Token);
_mockMapper.DidNotReceive().Map<ThumbnailResponse>(Arg.Any<Thumbnail>());
}
#endregion
}
@@ -13,11 +13,8 @@ namespace Lumina.Application.UnitTests.Core.FileManagement.Thumbnails.Queries.Ge
[ExcludeFromCodeCoverage]
public class GetThumbnailQueryValidatorTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly GetThumbnailQueryValidator _validator;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetThumbnailQueryValidatorTests"/> class.
/// </summary>
@@ -25,9 +22,7 @@ public class GetThumbnailQueryValidatorTests
{
_validator = new GetThumbnailQueryValidator();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Validate_WhenPathIsNull_ShouldHaveValidationError()
{
@@ -106,5 +101,4 @@ public class GetThumbnailQueryValidatorTests
result.ShouldNotHaveValidationErrorFor(x => x.Quality);
}
#endregion
}
@@ -29,16 +29,13 @@ namespace Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.B
[ExcludeFromCodeCoverage]
public class AddBookCommandHandlerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
private readonly IUnitOfWork _mockUnitOfWork;
private readonly IMapper _mockMapper;
private readonly IBookRepository _mockBookRepository;
private readonly AddBookCommandHandler _sut;
private readonly AddBookCommandFixture _commandBookFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="AddBookCommandHandlerTests"/> class.
/// </summary>
@@ -57,9 +54,7 @@ public class AddBookCommandHandlerTests
_sut = new AddBookCommandHandler(_mockUnitOfWork, _mockMapper);
_commandBookFixture = new AddBookCommandFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task Handle_WhenCalledWithValidCommand_ShouldReturnSuccessResult()
{
@@ -274,5 +269,4 @@ public class AddBookCommandHandlerTests
await _mockBookRepository.DidNotReceive().InsertAsync(Arg.Any<BookModel>(), Arg.Any<CancellationToken>());
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
}
#endregion
}
@@ -18,12 +18,9 @@ namespace Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.B
[ExcludeFromCodeCoverage]
public class AddBookCommandValidatorTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly AddBookCommandFixture _commandBookFixture;
private readonly AddBookCommandValidator _validator;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="AddBookCommandValidatorTests"/> class.
/// </summary>
@@ -32,9 +29,7 @@ public class AddBookCommandValidatorTests
_validator = new AddBookCommandValidator();
_commandBookFixture = new AddBookCommandFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Validate_WhenTitleIsNull_ShouldHaveValidationError()
{
@@ -1893,5 +1888,4 @@ public class AddBookCommandValidatorTests
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.Ratings[0].VoteCount);
}
#endregion
}
@@ -22,13 +22,10 @@ namespace Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.B
[ExcludeFromCodeCoverage]
public class AddBookCommandFixture
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly Fixture _fixture;
private readonly Random _random = new();
private readonly Faker _faker;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="AddBookCommandFixture"/> class.
/// </summary>
@@ -39,9 +36,7 @@ public class AddBookCommandFixture
_fixture.Customizations.Add(new NullableDateOnlySpecimenBuilder());
_faker = new Faker();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid command to add a book.
/// </summary>
@@ -343,5 +338,4 @@ public class AddBookCommandFixture
{
return input?.Length > maxLength ? input[..maxLength] : input;
}
#endregion
}
@@ -23,11 +23,8 @@ namespace Lumina.DataAccess.UnitTests.Common.DependencyInjection;
[ExcludeFromCodeCoverage]
public class DataAccessLayerServicesTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="DataAccessLayerServicesTests"/> class.
/// </summary>
@@ -35,9 +32,7 @@ public class DataAccessLayerServicesTests
{
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void AddDataAccessLayerServices_WhenBasePathExists_ShouldAddServices()
{
@@ -88,5 +83,4 @@ public class DataAccessLayerServicesTests
IBookRepository? repository = serviceProvider.GetService<IBookRepository>();
repository.Should().NotBeNull();
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.DataAccess.UnitTests.Common.Setup;
[ExcludeFromCodeCoverage]
public static class BogusExtensions
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Adds <see cref="DateOnly"/> random data generation support to the <see cref="Faker"/> class.
/// </summary>
@@ -36,5 +35,4 @@ public static class BogusExtensions
DateTime endDateTime = end.ToDateTime(TimeOnly.MinValue);
return System.DateOnly.FromDateTime(faker.Date.Between(startDateTime, endDateTime));
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.DataAccess.UnitTests.Common.Setup;
[ExcludeFromCodeCoverage]
public class DateOnlySpecimenBuilder : ISpecimenBuilder
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Adds <see cref="DateOnly"/> support to the AutoFixture library.
/// </summary>
@@ -25,5 +24,4 @@ public class DateOnlySpecimenBuilder : ISpecimenBuilder
return DateOnly.FromDateTime(DateTime.Now);
return new NoSpecimen();
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.DataAccess.UnitTests.Common.Setup;
[ExcludeFromCodeCoverage]
public class NullableDateOnlySpecimenBuilder : ISpecimenBuilder
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Adds <see cref="DateOnly?"/> support to the AutoFixture library.
/// </summary>
@@ -25,5 +24,4 @@ public class NullableDateOnlySpecimenBuilder : ISpecimenBuilder
return (DateOnly?)DateOnly.FromDateTime(DateTime.Now);
return new NoSpecimen();
}
#endregion
}
@@ -26,13 +26,10 @@ namespace Lumina.DataAccess.UnitTests.Core.Repositories.Books;
[ExcludeFromCodeCoverage]
public class BookRepositoryTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly LuminaDbContext _mockContext;
private readonly BookRepository _sut;
private readonly BookModelFixture _bookModelFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="BookRepositoryTests"/> class.
/// </summary>
@@ -42,9 +39,7 @@ public class BookRepositoryTests
_sut = new BookRepository(_mockContext);
_bookModelFixture = new BookModelFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task InsertAsync_WhenBookDoesNotExist_ShouldAddBookToContextAndReturnCreated()
{
@@ -194,5 +189,4 @@ public class BookRepositoryTests
retrievedBook.Genres.Should().HaveCount(2);
retrievedBook.ISBNs.Should().HaveCount(2);
}
#endregion
}
@@ -19,13 +19,10 @@ namespace Lumina.DataAccess.UnitTests.Core.Repositories.Books.Fixtures;
[ExcludeFromCodeCoverage]
public class BookModelFixture
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly Fixture _fixture;
private readonly Random _random = new();
private readonly Faker _faker;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="BookModelFixture"/> class.
/// </summary>
@@ -37,9 +34,7 @@ public class BookModelFixture
_faker = new Faker();
ConfigureCustomTypes();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid BookModel.
/// </summary>
@@ -204,5 +199,4 @@ public class BookModelFixture
_fixture.Create<int>()
));
}
#endregion
}
@@ -17,11 +17,8 @@ namespace Lumina.DataAccess.UnitTests.Core.Repositories.Common.Factory;
[ExcludeFromCodeCoverage]
public class RepositoryDictionaryTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="RepositoryDictionaryTests"/> class.
/// </summary>
@@ -29,9 +26,7 @@ public class RepositoryDictionaryTests
{
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Add_WhenValidRepositoryItemIsAdded_ShouldIncreaseCount()
{
@@ -111,5 +106,4 @@ public class RepositoryDictionaryTests
Action act = () => repositoryDictionary.Add(nonRepository);
act.Should().Throw<ArgumentException>().WithMessage("Value must implement IRepository interface!");
}
#endregion
}
@@ -16,7 +16,6 @@ namespace Lumina.DataAccess.UnitTests.Core.Repositories.Common.Factory;
[ExcludeFromCodeCoverage]
public class RepositoryFactoryTests
{
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void CreateRepository_WhenCalled_ShouldReturnCorrectRepository()
{
@@ -47,7 +46,6 @@ public class RepositoryFactoryTests
Action act = () => repositoryFactory.CreateRepository<IUnregisteredRepository>();
act.Should().Throw<InvalidOperationException>().WithMessage("No service for type 'Lumina.DataAccess.UnitTests.Core.Repositories.Common.Factory.IUnregisteredRepository' has been registered.");
}
#endregion
}
public interface IUnregisteredRepository { }
@@ -24,11 +24,8 @@ namespace Lumina.DataAccess.UnitTests.Core.UoW;
[ExcludeFromCodeCoverage]
public class UnitOfWorkTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="UnitOfWorkTests"/> class.
/// </summary>
@@ -43,9 +40,7 @@ public class UnitOfWorkTests
return Substitute.ForPartsOf<LuminaDbContext>(options);
}));
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void ResetRepositories_WhenCalled_ShouldClearAllRepositories()
{
@@ -140,5 +135,4 @@ public class UnitOfWorkTests
// Assert
await dbContext.Received(1).SaveChangesAsync(cancellationToken);
}
#endregion
}
@@ -12,7 +12,6 @@ namespace Lumina.Domain.UnitTests.Common.Primitives;
[ExcludeFromCodeCoverage]
public class OptionalTests
{
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Some_WhenCreatingOptionalWithValue_ShouldHaveValueAndCorrectValue()
{
@@ -133,5 +132,4 @@ public class OptionalTests
// Assert
result.Should().BeEmpty();
}
#endregion
}
@@ -20,7 +20,6 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Entiti
[ExcludeFromCodeCoverage]
public class DirectoryTests
{
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Create_WhenCalledWithValidParameters_ShouldReturnSuccessfulResult()
{
@@ -134,5 +133,4 @@ public class DirectoryTests
result.IsError.Should().BeFalse();
directory.Items.Should().NotContain(item);
}
#endregion
}
@@ -18,7 +18,6 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Entiti
[ExcludeFromCodeCoverage]
public class FileTests
{
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Create_WhenCalledWithValidParameters_ShouldReturnSuccessfulResult()
{
@@ -154,5 +153,4 @@ public class FileTests
result.FirstError.Should().Be(Errors.FileManagement.NameCannotBeEmpty);
file.Name.Should().Be("file.txt");
}
#endregion
}
@@ -19,11 +19,8 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Entiti
[ExcludeFromCodeCoverage]
public class DirectoryFixture
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly Faker _faker;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="DirectoryFixture"/> class.
/// </summary>
@@ -31,9 +28,7 @@ public class DirectoryFixture
{
_faker = new Faker();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid <see cref="Directory"/>.
/// </summary>
@@ -112,5 +107,4 @@ public class DirectoryFixture
}
return CreateDirectory(childItems: childItems);
}
#endregion
}
@@ -18,11 +18,8 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Entiti
[ExcludeFromCodeCoverage]
public class FileFixture
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly Faker _faker;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="FileFixture"/> class.
/// </summary>
@@ -30,9 +27,7 @@ public class FileFixture
{
_faker = new Faker();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid <see cref="File"/>.
/// </summary>
@@ -84,5 +79,4 @@ public class FileFixture
FileSystemItemStatus.Accessible
).Value;
}
#endregion
}
@@ -15,7 +15,6 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Entiti
[ExcludeFromCodeCoverage]
public class UnixRootItemFixture
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid <see cref="UnixRootItem"/>.
/// </summary>
@@ -29,5 +28,4 @@ public class UnixRootItemFixture
throw new InvalidOperationException("Failed to create UnixRootItem: " + string.Join(", ", unixRootItemResult.Errors));
return unixRootItemResult.Value;
}
#endregion
}
@@ -17,7 +17,6 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Entiti
[ExcludeFromCodeCoverage]
public class UnixRootItemTests
{
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Create_WhenCalledWithDefaultStatus_ShouldReturnSuccessfulResult()
{
@@ -102,5 +101,4 @@ public class UnixRootItemTests
result.FirstError.Should().Be(Errors.FileManagement.ParentNodeCannotBeNull);
unixRootItem.Parent.HasValue.Should().BeFalse();
}
#endregion
}
@@ -18,7 +18,6 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Entiti
[ExcludeFromCodeCoverage]
public class WindowsRootItemTests
{
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Create_WhenCalledWithValidParameters_ShouldReturnSuccessfulResult()
{
@@ -144,5 +143,4 @@ public class WindowsRootItemTests
result.FirstError.Should().Be(Errors.FileManagement.ParentNodeCannotBeNull);
windowsRootItem.Parent.HasValue.Should().BeFalse();
}
#endregion
}
@@ -22,12 +22,9 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate;
[ExcludeFromCodeCoverage]
public class FileSystemItemTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
private readonly FileSystemPathIdFixture _fileSystemPathIdFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="FileSystemItemTests"/> class.
/// </summary>
@@ -36,9 +33,7 @@ public class FileSystemItemTests
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
_fileSystemPathIdFixture = new FileSystemPathIdFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Constructor_WhenCalled_ShouldSetPropertiesCorrectly()
{
@@ -172,5 +167,4 @@ public class FileSystemItemTests
FileSystemItemType type = _fixture.Create<FileSystemItemType>();
return new FileSystemItemFixture(id, name, type);
}
#endregion
}
@@ -13,7 +13,6 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Fixtur
[ExcludeFromCodeCoverage]
public class FileSystemItemFixture : FileSystemItem
{
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="FileSystemItemFixture"/> class.
/// </summary>
@@ -24,5 +23,4 @@ public class FileSystemItemFixture : FileSystemItem
: base(id, name, fileSystemItemType)
{
}
#endregion
}
@@ -30,7 +30,6 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Servic
[ExcludeFromCodeCoverage]
public class DirectoryProviderServiceTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
private readonly IFileSystem _mockFileSystem;
private readonly IFileSystemPermissionsService _mockFileSystemPermissionsService;
@@ -59,9 +58,7 @@ public class DirectoryProviderServiceTests
private readonly string _pathValid2 = s_isLinux ? "/Valid/" : @"C:\Valid\";
private readonly string _pathInvalid2 = s_isLinux ? "/Invalid/" : @"C:\Invalid\";
private readonly char _dirSeparator = s_isLinux ? '/' : '\\';
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="DirectoryProviderServiceTests"/> class.
/// </summary>
@@ -73,9 +70,7 @@ public class DirectoryProviderServiceTests
_sut = new DirectoryProviderService(_mockFileSystem, _mockFileSystemPermissionsService);
_fileSystemPathIdFixture = new();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void GetSubdirectoryPaths_WhenUserHasNoAccess_ShouldReturnUnauthorizedAccessError()
{
@@ -1008,5 +1003,4 @@ public class DirectoryProviderServiceTests
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
_mockFileSystem.DirectoryInfo.DidNotReceive().New(Arg.Any<string>());
}
#endregion
}
@@ -28,7 +28,6 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Servic
[ExcludeFromCodeCoverage]
public class DirectoryServiceTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IEnvironmentContext _mockEnvironmentContext;
private readonly IPlatformContextManager _mockPlatformContextManager;
private readonly IPlatformContext _mockPlatformContext;
@@ -40,9 +39,7 @@ public class DirectoryServiceTests
private readonly string _pathDirTestSubDir1 = s_isLinux ? "/TestDir/Sub1" : @"C:\TestDir\Sub1";
private readonly string _pathDirTestSubDir2 = s_isLinux ? "/TestDir/Sub2" : @"C:\TestDir\Sub2";
private readonly char _dirSeparator = s_isLinux ? '/' : '\\';
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="DirectoryServiceTests"/> class.
/// </summary>
@@ -56,9 +53,7 @@ public class DirectoryServiceTests
_fileSystemPathIdFixture = new FileSystemPathIdFixture();
_directoryFixture = new DirectoryFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void GetSubdirectories_WithValidPath_ShouldReturnListOfDirectories()
{
@@ -786,5 +781,4 @@ public class DirectoryServiceTests
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileManagement.DirectoryNotFound);
}
#endregion
}
@@ -22,14 +22,11 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Servic
[ExcludeFromCodeCoverage]
public class DriveServiceTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFileSystem _mockFileSystem;
private readonly IPlatformContextManager _mockPlatformContextManager;
private readonly IPlatformContext _mockPlatformContext;
private readonly DriveService _sut;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="DriveServiceTests"/> class.
/// </summary>
@@ -41,9 +38,7 @@ public class DriveServiceTests
_mockPlatformContextManager.GetCurrentContext().Returns(_mockPlatformContext);
_sut = new DriveService(_mockFileSystem, _mockPlatformContextManager);
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void GetDrives_OnUnixPlatform_ShouldReturnSingleUnixRootItem()
{
@@ -90,5 +85,4 @@ public class DriveServiceTests
mockDriveInfo.IsReady.Returns(isReady);
return mockDriveInfo;
}
#endregion
}
@@ -29,7 +29,6 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Servic
[ExcludeFromCodeCoverage]
public class FileProviderServiceTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFixture _fixture;
private readonly IFileSystem _mockFileSystem;
private readonly IFileSystemPermissionsService _mockFileSystemPermissionsService;
@@ -46,9 +45,7 @@ public class FileProviderServiceTests
private readonly string _pathSource = s_isLinux ? "/Source" : @"C:\Source";
private readonly string _pathDestination = s_isLinux ? "/Destination" : @"C:\Destination";
private readonly char _dirSeparator = s_isLinux ? '/' : '\\';
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="FileProviderServiceTests"/> class.
/// </summary>
@@ -60,9 +57,7 @@ public class FileProviderServiceTests
_sut = new FileProviderService(_mockFileSystem, _mockFileSystemPermissionsService);
_fileSystemPathIdFixture = new();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void GetFilePaths_WhenUserHasNoAccess_ShouldReturnUnauthorizedAccessError()
{
@@ -931,5 +926,4 @@ public class FileProviderServiceTests
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
_mockFileSystem.File.DidNotReceive().Delete(Arg.Any<string>());
}
#endregion
}
@@ -28,7 +28,6 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Servic
[ExcludeFromCodeCoverage]
public class FileServiceTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IEnvironmentContext _mockEnvironmentContext;
private readonly IPlatformContextManager _mockPlatformContextManager;
private readonly IPlatformContext _mockPlatformContext;
@@ -49,9 +48,7 @@ public class FileServiceTests
private readonly string _pathSourceExistingFile = s_isLinux ? "/Source/existingfile.txt" : @"C:\Source\existingfile.txt";
private readonly string _pathSourceNonExistingFile = s_isLinux ? "/Source/nonexistent.txt" : @"C:\Source\nonexistent.txt";
private readonly char _dirSeparator = s_isLinux ? '/' : '\\';
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="FileServiceTests"/> class.
/// </summary>
@@ -65,9 +62,7 @@ public class FileServiceTests
_fileSystemPathIdFixture = new FileSystemPathIdFixture();
_fileFixture = new FileFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void GetFiles_WithValidPath_ShouldReturnListOfFiles()
{
@@ -1217,5 +1212,4 @@ public class FileServiceTests
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.Permission.UnauthorizedAccess);
}
#endregion
}
@@ -27,15 +27,12 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Servic
[ExcludeFromCodeCoverage]
public class FileTypeServiceTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private MockFileSystem _mockFileSystem = null!;
private readonly IFileSystemPermissionsService _mockFileSystemPermissionsService;
private FileTypeService? sut;
private readonly FileSystemPathIdFixture _fileSystemPathIdFixture;
private readonly FileFixture _fileFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="FileTypeServiceTests"/> class.
/// </summary>
@@ -45,9 +42,7 @@ public class FileTypeServiceTests
_fileSystemPathIdFixture = new FileSystemPathIdFixture();
_fileFixture = new FileFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task GetImageTypeAsync_WithValidFile_ShouldReturnCorrectImageType()
{
@@ -233,5 +228,4 @@ public class FileTypeServiceTests
result.IsError.Should().BeFalse();
result.Value.Should().Be(expectedType, because: $"the file header matches {testName}");
}
#endregion
}
@@ -20,7 +20,6 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Servic
public class ImageTypeFixture : TheoryData<ImageType, byte[]>
{
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="ImageTypeFixture"/> class.
/// </summary>
@@ -31,9 +30,7 @@ public class ImageTypeFixture : TheoryData<ImageType, byte[]>
Add(ImageType.BMP, CreateImage(new BmpEncoder()));
Add(ImageType.GIF, CreateImage(new GifEncoder()));
}
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a byte array representing a thumbnail fixture.
/// </summary>
@@ -46,5 +43,4 @@ public class ImageTypeFixture : TheoryData<ImageType, byte[]>
image.Save(ms, encoder);
return ms.ToArray();
}
#endregion
}
@@ -21,16 +21,13 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Servic
[ExcludeFromCodeCoverage]
public class PathServiceTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IPlatformContextManager _mockPlatformContextManager;
private readonly IPlatformContext _mockPlatformContext;
private readonly IPathStrategy _mockPathStrategy;
private readonly PathService _sut;
private readonly FileSystemPathIdFixture _fileSystemPathIdFixture;
private readonly PathSegmentFixture _pathSegmentFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="PathServiceTests"/> class.
/// </summary>
@@ -45,9 +42,7 @@ public class PathServiceTests
_fileSystemPathIdFixture = new FileSystemPathIdFixture();
_pathSegmentFixture = new PathSegmentFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void IsValidPath_WithValidPath_ShouldReturnTrue()
{
@@ -528,5 +523,4 @@ public class PathServiceTests
result.FirstError.Should().Be(Errors.FileManagement.InvalidPath);
_mockPathStrategy.DidNotReceive().GetPathRoot(Arg.Any<FileSystemPathId>());
}
#endregion
}
@@ -26,13 +26,10 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Servic
[ExcludeFromCodeCoverage]
public class ThumbnailServiceTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IEnvironmentContext _mockEnvironmentContext;
private readonly ThumbnailService _sut;
private readonly FileSystemPathIdFixture _fileSystemPathIdFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="ThumbnailServiceTests"/> class.
/// </summary>
@@ -42,9 +39,7 @@ public class ThumbnailServiceTests
_sut = new ThumbnailService(_mockEnvironmentContext);
_fileSystemPathIdFixture = new FileSystemPathIdFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public async Task GetThumbnailAsync_WithValidPath_ShouldReturnThumbnail()
{
@@ -191,5 +186,4 @@ public class ThumbnailServiceTests
await Assert.ThrowsAsync<TaskCanceledException>(() =>
_sut.GetThumbnailAsync(pathId, quality, cts.Token));
}
#endregion
}
@@ -14,13 +14,10 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Strate
[ExcludeFromCodeCoverage]
public class EnvironmentContextTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IDirectoryProviderService _mockDirectoryProviderService;
private readonly IFileProviderService _mockFileProviderService;
private readonly IFileTypeService _mockFileTypeService;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="EnvironmentContextTests"/> class.
/// </summary>
@@ -30,9 +27,7 @@ public class EnvironmentContextTests
_mockFileProviderService = Substitute.For<IFileProviderService>();
_mockFileTypeService = Substitute.For<IFileTypeService>();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Constructor_WhenCalledWithValidParameters_ShouldInitializeAllProperties()
{
@@ -95,5 +90,4 @@ public class EnvironmentContextTests
// Assert
result.Should().Be(_mockDirectoryProviderService);
}
#endregion
}
@@ -20,14 +20,11 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Strate
[ExcludeFromCodeCoverage]
public class UnixPathStrategyTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFileSystem _mockFileSystem;
private readonly UnixPathStrategy _sut;
private readonly FileSystemPathIdFixture _fileSystemPathIdFixture;
private readonly PathSegmentFixture _pathSegmentFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="UnixPathStrategyTests"/> class.
/// </summary>
@@ -38,9 +35,7 @@ public class UnixPathStrategyTests
_fileSystemPathIdFixture = new FileSystemPathIdFixture();
_pathSegmentFixture = new PathSegmentFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Theory]
[InlineData("/home/user")]
[InlineData("/var/log/")]
@@ -556,5 +551,4 @@ public class UnixPathStrategyTests
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileManagement.InvalidPath);
}
#endregion
}
@@ -20,14 +20,11 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Strate
[ExcludeFromCodeCoverage]
public class WindowsPathStrategyTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFileSystem _mockFileSystem;
private readonly WindowsPathStrategy _sut;
private readonly FileSystemPathIdFixture _fileSystemPathIdFixture;
private readonly PathSegmentFixture _pathSegmentFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="WindowsPathStrategyTests"/> class.
/// </summary>
@@ -38,9 +35,7 @@ public class WindowsPathStrategyTests
_fileSystemPathIdFixture = new FileSystemPathIdFixture();
_pathSegmentFixture = new PathSegmentFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Theory]
[InlineData(@"C:\Users\User")]
[InlineData(@"D:\Program Files\")]
@@ -772,5 +767,4 @@ public class WindowsPathStrategyTests
result.IsError.Should().BeTrue();
result.FirstError.Should().Be(Errors.FileManagement.InvalidPath);
}
#endregion
}
@@ -17,12 +17,9 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Strate
[ExcludeFromCodeCoverage]
public class PlatformContextFactoryTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IServiceProvider _serviceProvider;
private readonly PlatformContextFactory _sut;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="PlatformContextFactoryTests"/> class.
/// </summary>
@@ -37,9 +34,7 @@ public class PlatformContextFactoryTests
_serviceProvider = services.BuildServiceProvider();
_sut = new PlatformContextFactory(_serviceProvider);
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void CreateStrategy_WhenWindowsServiceExists_ShouldReturnWindowsService()
{
@@ -68,5 +63,4 @@ public class PlatformContextFactoryTests
// Act & Assert
Assert.Throws<InvalidOperationException>(() => _sut.CreateStrategy<INonExistentPlatformContextFixture>());
}
#endregion
}
@@ -16,12 +16,9 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Strate
[ExcludeFromCodeCoverage]
public class PlatformContextManagerTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IPlatformContextFactory _mockPlatformContextFactory;
private PlatformContextManager? sut;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="PlatformContextManagerTests"/> class.
/// </summary>
@@ -29,9 +26,7 @@ public class PlatformContextManagerTests
{
_mockPlatformContextFactory = Substitute.For<IPlatformContextFactory>();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void GetCurrentContext_WhenNoContextSet_ShouldSetDefaultContext()
{
@@ -155,5 +150,4 @@ public class PlatformContextManagerTests
result.Should().Be(mockWindowsContext);
_mockPlatformContextFactory.Received(1).CreateStrategy<IWindowsPlatformContext>();
}
#endregion
}
@@ -15,7 +15,6 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.Strate
[ExcludeFromCodeCoverage]
public class PlatformContextTests
{
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void WindowsPlatformContext_Constructor_ShouldSetPropertiesCorrectly()
{
@@ -117,5 +116,4 @@ public class PlatformContextTests
unixPlatformContext.GetType().GetProperty(nameof(UnixPlatformContext.Platform))!
.SetMethod.Should().BeNull();
}
#endregion
}
@@ -15,11 +15,8 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.ValueO
[ExcludeFromCodeCoverage]
public class FileSystemPathIdTests
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly FileSystemPathIdFixture _fileSystemPathIdFixture;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="FileSystemPathIdTests"/> class.
/// </summary>
@@ -27,9 +24,7 @@ public class FileSystemPathIdTests
{
_fileSystemPathIdFixture = new FileSystemPathIdFixture();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
[Fact]
public void Create_WithValidPath_ShouldReturnFileSystemPathId()
{
@@ -146,5 +141,4 @@ public class FileSystemPathIdTests
// Assert
result.Should().BeTrue();
}
#endregion
}
@@ -14,11 +14,8 @@ namespace Lumina.Domain.UnitTests.Core.Aggregates.FileManagementAggregate.ValueO
[ExcludeFromCodeCoverage]
public class FileSystemPathIdFixture
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly Faker _faker;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="FileSystemPathIdFixture"/> class.
/// </summary>
@@ -26,9 +23,7 @@ public class FileSystemPathIdFixture
{
_faker = new Faker();
}
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a random valid <see cref="FileSystemPathId"/>.
/// </summary>
@@ -44,5 +39,4 @@ public class FileSystemPathIdFixture
throw new InvalidOperationException("Failed to create FileSystemPathId: " + string.Join(", ", fileSystemPathIdResult.Errors));
return fileSystemPathIdResult.Value;
}
#endregion
}
Loaded 100 of 370 files, more files were not shown because too many files have changed in this diff. Show more