mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 03:11:10 +00:00
Renames project paths from Lumina to Nemera
This commit is contained in:
1 parent
ce6fddb4c9
commit
0f659a4877
6450 files changed
No files matched your search
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Common;
|
||||
using Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="FileSystemTreeNodeResponseMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FileSystemTreeNodeResponseMappingTests
|
||||
{
|
||||
private readonly FileSystemTreeNodeResponseFixture _fileSystemTreeNodeResponseFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToWindowsRootItem_WhenMappingFileSystemTreeNodeResponse_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemTreeNodeResponse response = _fileSystemTreeNodeResponseFixture.Create();
|
||||
|
||||
// Act
|
||||
Result<WindowsRootItem> result = response.ToWindowsRootItem();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(response.Path, result.Value.Id.Path);
|
||||
Assert.Equal(response.Name, result.Value.Name);
|
||||
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToUnixRootItem_WhenMappingFileSystemTreeNodeResponse_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemTreeNodeResponse response = _fileSystemTreeNodeResponseFixture.Create();
|
||||
|
||||
// Act
|
||||
Result<UnixRootItem> result = response.ToUnixRootItem();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(FileSystemItemStatus.Accessible, result.Value.Status);
|
||||
}
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Directories;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.Directories;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="DirectoryMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DirectoryMappingTests
|
||||
{
|
||||
private readonly DirectoryFixture _directoryFixture = new();
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)] // Hidden directory.
|
||||
[InlineData(false)] // Visible directory.
|
||||
public void ToFileSystemTreeNodeResponse_WhenMappingDirectory_ShouldMapCorrectly(bool isHidden)
|
||||
{
|
||||
// Arrange
|
||||
Directory directory = _directoryFixture.Create(isHidden: isHidden);
|
||||
List<FileSystemItem> childItems =
|
||||
[
|
||||
_directoryFixture.Create(isHidden: true),
|
||||
_directoryFixture.Create(isHidden: false)
|
||||
];
|
||||
foreach (FileSystemItem item in childItems)
|
||||
directory.AddItem(item);
|
||||
|
||||
// Act
|
||||
FileSystemTreeNodeResponse result = directory.ToFileSystemTreeNodeResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(directory.Name, result.Name);
|
||||
Assert.Equal(directory.Id.Path, result.Path);
|
||||
Assert.Equal(directory.Type, result.ItemType);
|
||||
Assert.Equal(directory.IsHidden, result.IsHidden);
|
||||
Assert.False(result.IsExpanded);
|
||||
Assert.False(result.ChildrenLoaded);
|
||||
Assert.NotNull(result.Children);
|
||||
Assert.Equal(childItems.Count, result.Children.Count);
|
||||
|
||||
for (int i = 0; i < childItems.Count; i++)
|
||||
{
|
||||
Assert.Equal(childItems[i].Name, result.Children[i].Name);
|
||||
Assert.Equal(childItems[i].Id.Path, result.Children[i].Path);
|
||||
Assert.Equal(childItems[i].Type, result.Children[i].ItemType);
|
||||
Assert.Equal(childItems[i].IsHidden, result.Children[i].IsHidden);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToFileSystemTreeNodeResponses_WhenMappingMultipleDirectories_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<Directory> directories =
|
||||
[
|
||||
_directoryFixture.Create(isHidden: true),
|
||||
_directoryFixture.Create(isHidden: false)
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<FileSystemTreeNodeResponse> result = directories.ToFileSystemTreeNodeResponses();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(directories.Count, result.Count());
|
||||
|
||||
List<FileSystemTreeNodeResponse> resultList = result.ToList();
|
||||
for (int i = 0; i < directories.Count; i++)
|
||||
{
|
||||
Assert.Equal(directories[i].Name, resultList[i].Name);
|
||||
Assert.Equal(directories[i].Id.Path, resultList[i].Path);
|
||||
Assert.Equal(directories[i].Type, resultList[i].ItemType);
|
||||
Assert.Equal(directories[i].IsHidden, resultList[i].IsHidden);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)] // Hidden directory.
|
||||
[InlineData(false)] // Visible directory.
|
||||
public void ToResponse_WhenMappingDirectory_ShouldMapCorrectly(bool isHidden)
|
||||
{
|
||||
// Arrange
|
||||
Directory directory = _directoryFixture.Create(isHidden: isHidden);
|
||||
List<FileSystemItem> childItems =
|
||||
[
|
||||
_directoryFixture.Create(isHidden: true),
|
||||
_directoryFixture.Create(isHidden: false)
|
||||
];
|
||||
foreach (FileSystemItem item in childItems)
|
||||
directory.AddItem(item);
|
||||
|
||||
// Act
|
||||
DirectoryResponse result = directory.ToResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(directory.Id.Path, result.Path);
|
||||
Assert.Equal(directory.Name, result.Name);
|
||||
Assert.Equal(directory.DateCreated.Value, result.DateCreated);
|
||||
Assert.Equal(directory.DateModified.Value, result.DateModified);
|
||||
Assert.Equal(directory.IsHidden, result.IsHidden);
|
||||
Assert.NotNull(result.Items);
|
||||
Assert.Equal(childItems.Count, result.Items.Count);
|
||||
|
||||
for (int i = 0; i < childItems.Count; i++)
|
||||
{
|
||||
Assert.Equal(childItems[i].Name, result.Items[i].Name);
|
||||
Assert.Equal(childItems[i].Id.Path, result.Items[i].Path);
|
||||
Assert.Equal(childItems[i].IsHidden, result.Items[i].IsHidden);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToResponses_WhenMappingMultipleDirectories_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<Directory> directories =
|
||||
[
|
||||
_directoryFixture.Create(isHidden: true),
|
||||
_directoryFixture.Create(isHidden: false)
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<DirectoryResponse> result = directories.ToResponses();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(directories.Count, result.Count());
|
||||
|
||||
List<DirectoryResponse> resultList = result.ToList();
|
||||
for (int i = 0; i < directories.Count; i++)
|
||||
{
|
||||
Assert.Equal(directories[i].Id.Path, resultList[i].Path);
|
||||
Assert.Equal(directories[i].Name, resultList[i].Name);
|
||||
Assert.Equal(directories[i].DateCreated.Value, resultList[i].DateCreated);
|
||||
Assert.Equal(directories[i].DateModified.Value, resultList[i].DateModified);
|
||||
Assert.Equal(directories[i].IsHidden, resultList[i].IsHidden);
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
|
||||
using Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectories;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Directories;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.Directories;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GetDirectoriesRequestMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetDirectoriesRequestMappingTests
|
||||
{
|
||||
private readonly GetDirectoriesRequestFixture _getDirectoriesRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingGetDirectoriesRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetDirectoriesRequest request = _getDirectoriesRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
GetDirectoriesQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(request.Path, result.Path);
|
||||
Assert.Equal(request.ShouldIncludeHiddenElements, result.ShouldIncludeHiddenElements);
|
||||
}
|
||||
}
|
||||
+231
@@ -0,0 +1,231 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
using Lumina.Contracts.DTO.FileSystemManagement;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="FileSystemItemMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FileSystemItemMappingTests
|
||||
{
|
||||
private readonly FileSystemPathIdFixture _fileSystemPathIdFixture = new();
|
||||
private readonly DirectoryFixture _directoryFixture = new();
|
||||
private readonly FileFixture _fileFixture = new();
|
||||
private readonly WindowsRootItemFixture _windowsRootItemFixture = new();
|
||||
private readonly UnixRootItemFixture _unixRootItemFixture = new();
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)] // Hidden file system item.
|
||||
[InlineData(false)] // Visible file system item.
|
||||
public void ToFileSystemItemModel_WhenMappingFileSystemItem_ShouldMapCorrectly(bool isHidden)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId id = _fileSystemPathIdFixture.Create();
|
||||
string name = "TestItem";
|
||||
FileSystemItemType type = FileSystemItemType.File;
|
||||
FileSystemItemFixture domainModel = new(id, name, type);
|
||||
domainModel.SetHiddenState(isHidden);
|
||||
|
||||
// Act
|
||||
FileSystemItemDto result = domainModel.ToFileSystemItemDto();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(domainModel.Id.Path, result.Path);
|
||||
Assert.Equal(domainModel.Name, result.Name);
|
||||
Assert.Equal(domainModel.IsHidden, result.IsHidden);
|
||||
Assert.True((DateTime.Now - result.DateCreated) < TimeSpan.FromSeconds(1));
|
||||
Assert.True((DateTime.Now - result.DateModified) < TimeSpan.FromSeconds(1));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)] // Hidden directory.
|
||||
[InlineData(false)] // Visible directory.
|
||||
public void ToTreeNodeResponse_WhenMappingDirectory_ShouldMapCorrectly(bool isHidden)
|
||||
{
|
||||
// Arrange
|
||||
Directory directory = _directoryFixture.Create(isHidden: isHidden);
|
||||
|
||||
// Act
|
||||
FileSystemTreeNodeResponse result = directory.ToTreeNodeResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(directory.Name, result.Name);
|
||||
Assert.Equal(directory.Id.Path, result.Path);
|
||||
Assert.Equal(directory.Type, result.ItemType);
|
||||
Assert.Equal(directory.IsHidden, result.IsHidden);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)] // Hidden file.
|
||||
[InlineData(false)] // Visible file.
|
||||
public void ToTreeNodeResponse_WhenMappingFile_ShouldMapCorrectly(bool isHidden)
|
||||
{
|
||||
// Arrange
|
||||
File file = _fileFixture.Create(isHidden: isHidden);
|
||||
|
||||
// Act
|
||||
FileSystemTreeNodeResponse result = file.ToTreeNodeResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(file.Name, result.Name);
|
||||
Assert.Equal(file.Id.Path, result.Path);
|
||||
Assert.Equal(file.Type, result.ItemType);
|
||||
Assert.Equal(file.IsHidden, result.IsHidden);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToTreeNodeResponse_WhenMappingWindowsRootItem_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
WindowsRootItem windowsRootItem = _windowsRootItemFixture.Create();
|
||||
|
||||
// Act
|
||||
FileSystemTreeNodeResponse result = windowsRootItem.ToTreeNodeResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(windowsRootItem.Name, result.Name);
|
||||
Assert.Equal(windowsRootItem.Id.Path, result.Path);
|
||||
Assert.Equal(windowsRootItem.Type, result.ItemType);
|
||||
Assert.False(result.IsHidden);
|
||||
Assert.False(result.IsExpanded);
|
||||
Assert.False(result.ChildrenLoaded);
|
||||
Assert.Empty(result.Children);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToTreeNodeResponse_WhenMappingUnixRootItem_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
UnixRootItem unixRootItem = _unixRootItemFixture.Create();
|
||||
|
||||
// Act
|
||||
FileSystemTreeNodeResponse result = unixRootItem.ToTreeNodeResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(unixRootItem.Name, result.Name);
|
||||
Assert.Equal(unixRootItem.Id.Path, result.Path);
|
||||
Assert.Equal(unixRootItem.Type, result.ItemType);
|
||||
Assert.False(result.IsHidden);
|
||||
Assert.False(result.IsExpanded);
|
||||
Assert.False(result.ChildrenLoaded);
|
||||
Assert.Empty(result.Children);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("TestFile.txt", FileSystemItemType.File, true)] // Hidden file.
|
||||
[InlineData("TestFolder", FileSystemItemType.Directory, false)] // Visible directory.
|
||||
public void ToFileSystemItemModel_WhenMappingDifferentFileSystemItems_ShouldMapCorrectly(string name, FileSystemItemType type, bool isHidden)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId id = _fileSystemPathIdFixture.Create();
|
||||
FileSystemItemFixture domainModel = new(id, name, type);
|
||||
domainModel.SetHiddenState(isHidden);
|
||||
|
||||
// Act
|
||||
FileSystemItemDto result = domainModel.ToFileSystemItemDto();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(domainModel.Id.Path, result.Path);
|
||||
Assert.Equal(domainModel.Name, result.Name);
|
||||
Assert.Equal(domainModel.IsHidden, result.IsHidden);
|
||||
Assert.True((DateTime.Now - result.DateCreated) < TimeSpan.FromSeconds(1));
|
||||
Assert.True((DateTime.Now - result.DateModified) < TimeSpan.FromSeconds(1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToTreeNodeResponses_WhenMappingMixedFileSystemItems_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<FileSystemItem> domainModels =
|
||||
[
|
||||
_directoryFixture.Create(isHidden: true),
|
||||
_fileFixture.Create(isHidden: false),
|
||||
_windowsRootItemFixture.Create(),
|
||||
_unixRootItemFixture.Create()
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<FileSystemTreeNodeResponse> result = domainModels.ToTreeNodeResponses();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(domainModels.Count, result.Count());
|
||||
|
||||
List<FileSystemTreeNodeResponse> resultList = [.. result];
|
||||
for (int i = 0; i < resultList.Count; i++)
|
||||
{
|
||||
Assert.Equal(domainModels[i].Name, resultList[i].Name);
|
||||
Assert.Equal(domainModels[i].Id.Path, resultList[i].Path);
|
||||
Assert.Equal(domainModels[i].Type, resultList[i].ItemType);
|
||||
Assert.Equal(domainModels[i].IsHidden, resultList[i].IsHidden);
|
||||
Assert.False(resultList[i].IsExpanded);
|
||||
Assert.False(resultList[i].ChildrenLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToTreeNodeResponse_WhenMappingInvalidFileSystemItem_ShouldThrowArgumentException()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId id = _fileSystemPathIdFixture.Create();
|
||||
string name = "TestItem";
|
||||
FileSystemItemType type = FileSystemItemType.File;
|
||||
FileSystemItemFixture invalidItem = new(id, name, type);
|
||||
|
||||
// Act & Assert
|
||||
ArgumentException exception = Assert.Throws<ArgumentException>(() => invalidItem.ToTreeNodeResponse());
|
||||
Assert.Equal("Invalid FileSystemItem", exception.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToTreeNodeResponses_WhenMappingMultipleFileSystemItems_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
IEnumerable<FileSystemItem> domainModels =
|
||||
[
|
||||
_directoryFixture.Create(isHidden: true),
|
||||
_directoryFixture.Create(isHidden: false)
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<FileSystemTreeNodeResponse> result = domainModels.ToTreeNodeResponses();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(domainModels.Count(), result.Count());
|
||||
|
||||
List<FileSystemTreeNodeResponse> resultList = [.. result];
|
||||
List<FileSystemItem> domainModelsList = [.. domainModels];
|
||||
for (int i = 0; i < resultList.Count; i++)
|
||||
{
|
||||
Assert.Equal(domainModelsList[i].Name, resultList[i].Name);
|
||||
Assert.Equal(domainModelsList[i].Id.Path, resultList[i].Path);
|
||||
Assert.Equal(domainModelsList[i].Type, resultList[i].ItemType);
|
||||
Assert.Equal(domainModelsList[i].IsHidden, resultList[i].IsHidden);
|
||||
Assert.False(resultList[i].IsExpanded);
|
||||
Assert.False(resultList[i].ChildrenLoaded);
|
||||
Assert.Empty(resultList[i].Children);
|
||||
}
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="UnixRootItemMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UnixRootItemMappingTests
|
||||
{
|
||||
private readonly UnixRootItemFixture _unixRootItemFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToTreeNodeResponse_WhenMappingUnixRootItem_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
UnixRootItem domainModel = _unixRootItemFixture.Create();
|
||||
|
||||
// Act
|
||||
FileSystemTreeNodeResponse result = domainModel.ToTreeNodeResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(domainModel.Id.Path, result.Path);
|
||||
Assert.Equal(domainModel.Name, result.Name);
|
||||
Assert.Equal(FileSystemItemType.Root, result.ItemType);
|
||||
Assert.False(result.IsExpanded);
|
||||
Assert.False(result.ChildrenLoaded);
|
||||
Assert.NotNull(result.Children);
|
||||
Assert.Empty(result.Children);
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="WindowsRootItemMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class WindowsRootItemMappingTests
|
||||
{
|
||||
private readonly WindowsRootItemFixture _windowsRootItemFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToTreeNodeResponse_WhenMappingWindowsRootItem_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
WindowsRootItem domainModel = _windowsRootItemFixture.Create(path: "C:\\", name: "C:");
|
||||
|
||||
// Act
|
||||
FileSystemTreeNodeResponse result = domainModel.ToTreeNodeResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(domainModel.Id.Path, result.Path);
|
||||
Assert.Equal(domainModel.Name, result.Name);
|
||||
Assert.Equal(FileSystemItemType.Root, result.ItemType);
|
||||
Assert.False(result.IsExpanded);
|
||||
Assert.False(result.ChildrenLoaded);
|
||||
Assert.Empty(result.Children);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToTreeNodeResponse_WhenMappingWindowsRootItemWithCustomStatus_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
WindowsRootItem domainModel = _windowsRootItemFixture.Create(path: "D:\\", name: "D:", status: FileSystemItemStatus.Inaccessible);
|
||||
|
||||
// Act
|
||||
FileSystemTreeNodeResponse result = domainModel.ToTreeNodeResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(domainModel.Id.Path, result.Path);
|
||||
Assert.Equal(domainModel.Name, result.Name);
|
||||
Assert.Equal(FileSystemItemType.Root, result.ItemType);
|
||||
Assert.False(result.IsExpanded);
|
||||
Assert.False(result.ChildrenLoaded);
|
||||
Assert.Empty(result.Children);
|
||||
}
|
||||
}
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Files;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.Files;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="FileMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FileMappingTests
|
||||
{
|
||||
private readonly FileFixture _fileFixture = new();
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)] // Hidden file.
|
||||
[InlineData(false)] // Visible file.
|
||||
public void ToFileSystemTreeNodeResponse_WhenMappingFile_ShouldMapCorrectly(bool isHidden)
|
||||
{
|
||||
// Arrange
|
||||
File domainModel = _fileFixture.Create(isHidden: isHidden);
|
||||
|
||||
// Act
|
||||
FileSystemTreeNodeResponse result = domainModel.ToFileSystemTreeNodeResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(domainModel.Name, result.Name);
|
||||
Assert.Equal(domainModel.Id.Path, result.Path);
|
||||
Assert.Equal(domainModel.Type, result.ItemType);
|
||||
Assert.Equal(domainModel.IsHidden, result.IsHidden);
|
||||
Assert.False(result.IsExpanded);
|
||||
Assert.False(result.ChildrenLoaded);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToFileSystemTreeNodeResponses_WhenMappingMultipleFiles_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
IEnumerable<File> domainModels =
|
||||
[
|
||||
_fileFixture.Create(isHidden: true),
|
||||
_fileFixture.Create(isHidden: false)
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<FileSystemTreeNodeResponse> result = domainModels.ToFileSystemTreeNodeResponses();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(domainModels.Count(), result.Count());
|
||||
|
||||
List<FileSystemTreeNodeResponse> resultList = [.. result];
|
||||
List<File> domainModelsList = [.. domainModels];
|
||||
for (int i = 0; i < resultList.Count; i++)
|
||||
{
|
||||
Assert.Equal(domainModelsList[i].Name, resultList[i].Name);
|
||||
Assert.Equal(domainModelsList[i].Id.Path, resultList[i].Path);
|
||||
Assert.Equal(domainModelsList[i].Type, resultList[i].ItemType);
|
||||
Assert.Equal(domainModelsList[i].IsHidden, resultList[i].IsHidden);
|
||||
Assert.False(resultList[i].IsExpanded);
|
||||
Assert.False(resultList[i].ChildrenLoaded);
|
||||
Assert.Empty(resultList[i].Children);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)] // Hidden file.
|
||||
[InlineData(false)] // Visible file.
|
||||
public void ToResponse_WhenMappingFile_ShouldMapCorrectly(bool isHidden)
|
||||
{
|
||||
// Arrange
|
||||
File domainModel = _fileFixture.Create(isHidden: isHidden);
|
||||
|
||||
// Act
|
||||
FileResponse result = domainModel.ToResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(domainModel.Id.Path, result.Path);
|
||||
Assert.Equal(domainModel.Name, result.Name);
|
||||
Assert.Equal(domainModel.DateCreated.Value, result.DateCreated);
|
||||
Assert.Equal(domainModel.DateModified.Value, result.DateModified);
|
||||
Assert.Equal(domainModel.Size, result.Size);
|
||||
Assert.Equal(domainModel.IsHidden, result.IsHidden);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToResponses_WhenMappingMultipleFiles_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
IEnumerable<File> domainModels =
|
||||
[
|
||||
_fileFixture.Create(isHidden: true),
|
||||
_fileFixture.Create(isHidden: false)
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<FileResponse> result = domainModels.ToResponses();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(domainModels.Count(), result.Count());
|
||||
|
||||
List<FileResponse> resultList = [.. result];
|
||||
List<File> domainModelsList = [.. domainModels];
|
||||
for (int i = 0; i < resultList.Count; i++)
|
||||
{
|
||||
Assert.Equal(domainModelsList[i].Name, resultList[i].Name);
|
||||
Assert.Equal(domainModelsList[i].Id.Path, resultList[i].Path);
|
||||
Assert.Equal(domainModelsList[i].Size, resultList[i].Size);
|
||||
Assert.Equal(domainModelsList[i].DateCreated.Value, resultList[i].DateCreated);
|
||||
Assert.Equal(domainModelsList[i].DateModified.Value, resultList[i].DateModified);
|
||||
Assert.Equal(domainModelsList[i].IsHidden, resultList[i].IsHidden);
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetFiles;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Files;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Files;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.Files;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GetFilesRequestMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetFilesRequestMappingTests
|
||||
{
|
||||
private readonly GetFilesRequestFixture _getFilesRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingGetFilesRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetFilesRequest request = _getFilesRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
GetFilesQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(request.Path, result.Path);
|
||||
Assert.Equal(request.ShouldIncludeHiddenElements, result.ShouldIncludeHiddenElements);
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Files;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Files;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.Files;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GetTreeFilesRequestMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetTreeFilesRequestMappingTests
|
||||
{
|
||||
private readonly GetTreeFilesRequestFixture _getTreeFilesRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingGetTreeFilesRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetTreeFilesRequest request = _getTreeFilesRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
GetTreeFilesQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(request.Path, result.Path);
|
||||
Assert.Equal(request.ShouldIncludeHiddenElements, result.ShouldIncludeHiddenElements);
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathExists;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.Paths;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="CheckPathExistsRequestMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class CheckPathExistsRequestMappingTests
|
||||
{
|
||||
private readonly CheckPathExistsRequestFixture _checkPathExistsRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingCheckPathExistsRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
CheckPathExistsRequest request = _checkPathExistsRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
CheckPathExistsQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(request.Path, result.Path);
|
||||
Assert.Equal(request.ShouldIncludeHiddenElements, result.ShouldIncludeHiddenElements);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/home/user/documents", true)]
|
||||
[InlineData("C:\\Users\\Documents", false)]
|
||||
[InlineData("/var/www/html", true)]
|
||||
public void ToQuery_WhenMappingWithDifferentPathsAndHiddenElementsFlag_ShouldMapCorrectly(string path, bool shouldIncludeHiddenElements)
|
||||
{
|
||||
// Arrange
|
||||
CheckPathExistsRequest request = _checkPathExistsRequestFixture.Create(path, shouldIncludeHiddenElements);
|
||||
|
||||
// Act
|
||||
CheckPathExistsQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(path, result.Path);
|
||||
Assert.Equal(shouldIncludeHiddenElements, result.ShouldIncludeHiddenElements);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingMultipleRequests_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<CheckPathExistsRequest> requests = _checkPathExistsRequestFixture.CreateMany();
|
||||
|
||||
// Act
|
||||
List<CheckPathExistsQuery> results = requests.Select(r => r.ToQuery()).ToList();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(requests.Count, results.Count);
|
||||
for (int i = 0; i < requests.Count; i++)
|
||||
{
|
||||
Assert.Equal(requests[i].Path, results[i].Path);
|
||||
Assert.Equal(requests[i].ShouldIncludeHiddenElements, results[i].ShouldIncludeHiddenElements);
|
||||
}
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Commands.CombinePath;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.Paths;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="CombinePathRequestMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class CombinePathRequestMappingTests
|
||||
{
|
||||
private readonly CombinePathRequestFixture _combinePathRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToCommand_WhenMappingCombinePathRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
CombinePathRequest request = _combinePathRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
CombinePathCommand result = request.ToCommand();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(request.OriginalPath, result.OriginalPath);
|
||||
Assert.Equal(request.NewPath, result.NewPath);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/home/user", "documents")]
|
||||
[InlineData("C:\\Users", "Documents")]
|
||||
[InlineData("/var/www", "html")]
|
||||
public void ToCommand_WhenMappingWithDifferentPaths_ShouldMapCorrectly(string originalPath, string newPath)
|
||||
{
|
||||
// Arrange
|
||||
CombinePathRequest request = _combinePathRequestFixture.Create(originalPath, newPath);
|
||||
|
||||
// Act
|
||||
CombinePathCommand result = request.ToCommand();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(originalPath, result.OriginalPath);
|
||||
Assert.Equal(newPath, result.NewPath);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToCommand_WhenMappingMultipleRequests_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<CombinePathRequest> requests = _combinePathRequestFixture.CreateMany();
|
||||
|
||||
// Act
|
||||
List<CombinePathCommand> results = [.. requests.Select(r => r.ToCommand())];
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(requests.Count, results.Count);
|
||||
for (int i = 0; i < requests.Count; i++)
|
||||
{
|
||||
Assert.Equal(requests[i].OriginalPath, results[i].OriginalPath);
|
||||
Assert.Equal(requests[i].NewPath, results[i].NewPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathParent;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.Paths;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GetPathParentRequestMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetPathParentRequestMappingTests
|
||||
{
|
||||
private readonly GetPathParentRequestFixture _getPathParentRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingGetPathParentRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetPathParentRequest request = _getPathParentRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
GetPathParentQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(request.Path, result.Path);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/home/user/documents")]
|
||||
[InlineData("C:\\Users\\Documents")]
|
||||
[InlineData("/var/www/html")]
|
||||
public void ToQuery_WhenMappingWithDifferentPaths_ShouldMapCorrectly(string path)
|
||||
{
|
||||
// Arrange
|
||||
GetPathParentRequest request = _getPathParentRequestFixture.Create(path);
|
||||
|
||||
// Act
|
||||
GetPathParentQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(path, result.Path);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingMultipleRequests_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<GetPathParentRequest> requests = _getPathParentRequestFixture.CreateMany();
|
||||
|
||||
// Act
|
||||
List<GetPathParentQuery> results = [.. requests.Select(r => r.ToQuery())];
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(requests.Count, results.Count);
|
||||
for (int i = 0; i < requests.Count; i++)
|
||||
{
|
||||
Assert.Equal(requests[i].Path, results[i].Path);
|
||||
}
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathRoot;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.Paths;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GetPathRootRequestMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetPathRootRequestMappingTests
|
||||
{
|
||||
private readonly GetPathRootRequestFixture _getPathRootRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingGetPathRootRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetPathRootRequest request = _getPathRootRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
GetPathRootQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(request.Path, result.Path);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/home/user/documents")]
|
||||
[InlineData("C:\\Users\\Documents")]
|
||||
[InlineData("/var/www/html")]
|
||||
[InlineData("D:\\Projects\\MyProject")]
|
||||
public void ToQuery_WhenMappingWithDifferentPaths_ShouldMapCorrectly(string path)
|
||||
{
|
||||
// Arrange
|
||||
GetPathRootRequest request = _getPathRootRequestFixture.Create(path);
|
||||
|
||||
// Act
|
||||
GetPathRootQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(path, result.Path);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingMultipleRequests_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<GetPathRootRequest> requests = _getPathRootRequestFixture.CreateMany();
|
||||
|
||||
// Act
|
||||
List<GetPathRootQuery> results = [.. requests.Select(r => r.ToQuery())];
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(requests.Count, results.Count);
|
||||
for (int i = 0; i < requests.Count; i++)
|
||||
{
|
||||
Assert.Equal(requests[i].Path, results[i].Path);
|
||||
}
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.Paths;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="PathSegmentMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PathSegmentMappingTests
|
||||
{
|
||||
private readonly PathSegmentFixture _pathSegmentFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToResponse_WhenMappingPathSegment_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
PathSegment pathSegment = _pathSegmentFixture.Create(name: "TestSegment", isDirectory: true, isDrive: false);
|
||||
|
||||
// Act
|
||||
PathSegmentResponse result = pathSegment.ToResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(pathSegment.Name, result.Path);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Folder", true, false)]
|
||||
[InlineData("File.txt", false, false)]
|
||||
[InlineData("C:", false, true)]
|
||||
public void ToResponse_WhenMappingDifferentPathSegmentTypes_ShouldMapCorrectly(string name, bool isDirectory, bool isDrive)
|
||||
{
|
||||
// Arrange
|
||||
PathSegment pathSegment = _pathSegmentFixture.Create(name: name, isDirectory: isDirectory, isDrive: isDrive);
|
||||
|
||||
// Act
|
||||
PathSegmentResponse result = pathSegment.ToResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(pathSegment.Name, result.Path);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToResponses_WhenMappingMultiplePathSegments_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<PathSegment> pathSegments =
|
||||
[
|
||||
_pathSegmentFixture.Create(name: "C:", isDirectory: false, isDrive: true),
|
||||
_pathSegmentFixture.Create(name: "Users", isDirectory: true, isDrive: false),
|
||||
_pathSegmentFixture.Create(name: "Documents", isDirectory: true, isDrive: false),
|
||||
_pathSegmentFixture.Create(name: "file.txt", isDirectory: false, isDrive: false)
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<PathSegmentResponse> results = pathSegments.ToResponses();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(pathSegments.Count, results.Count());
|
||||
List<PathSegmentResponse> resultList = [.. results];
|
||||
for (int i = 0; i < pathSegments.Count; i++)
|
||||
Assert.Equal(pathSegments[i].Name, resultList[i].Path);
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Commands.SplitPath;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.Paths;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="SplitPathRequestMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SplitPathRequestMappingTests
|
||||
{
|
||||
private readonly SplitPathRequestFixture _splitPathRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToCommand_WhenMappingSplitPathRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
SplitPathRequest request = _splitPathRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
SplitPathCommand result = request.ToCommand();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(request.Path, result.Path);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/home/user/documents")]
|
||||
[InlineData("C:\\Users\\Documents")]
|
||||
[InlineData("/var/www/html")]
|
||||
[InlineData("D:\\Projects\\MyProject\\file.txt")]
|
||||
public void ToCommand_WhenMappingWithDifferentPaths_ShouldMapCorrectly(string path)
|
||||
{
|
||||
// Arrange
|
||||
SplitPathRequest request = _splitPathRequestFixture.Create(path);
|
||||
|
||||
// Act
|
||||
SplitPathCommand result = request.ToCommand();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(path, result.Path);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToCommand_WhenMappingMultipleRequests_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<SplitPathRequest> requests = _splitPathRequestFixture.CreateMany();
|
||||
|
||||
// Act
|
||||
List<SplitPathCommand> results = [.. requests.Select(r => r.ToCommand())];
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(requests.Count, results.Count);
|
||||
for (int i = 0; i < requests.Count; i++)
|
||||
Assert.Equal(requests[i].Path, results[i].Path);
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.ValidatePath;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.Paths;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ValidatePathRequestMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ValidatePathRequestMappingTests
|
||||
{
|
||||
private readonly ValidatePathRequestFixture _validatePathRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingValidatePathRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
ValidatePathRequest request = _validatePathRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
ValidatePathQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(request.Path, result.Path);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/home/user/documents")]
|
||||
[InlineData("C:\\Users\\Documents")]
|
||||
[InlineData("/var/www/html")]
|
||||
[InlineData("D:\\Projects\\MyProject\\file.txt")]
|
||||
[InlineData("\\\\NetworkShare\\Folder")]
|
||||
[InlineData("relative/path/to/file.txt")]
|
||||
public void ToQuery_WhenMappingWithDifferentPaths_ShouldMapCorrectly(string path)
|
||||
{
|
||||
// Arrange
|
||||
ValidatePathRequest request = _validatePathRequestFixture.Create(path);
|
||||
|
||||
// Act
|
||||
ValidatePathQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(path, result.Path);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingMultipleRequests_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<ValidatePathRequest> requests = _validatePathRequestFixture.CreateMany();
|
||||
|
||||
// Act
|
||||
List<ValidatePathQuery> results = [.. requests.Select(r => r.ToQuery())];
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(requests.Count, results.Count);
|
||||
for (int i = 0; i < requests.Count; i++)
|
||||
Assert.Equal(requests[i].Path, results[i].Path);
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Thumbnails;
|
||||
using Lumina.Application.Core.FileSystemManagement.Thumbnails.Queries.GetThumbnail;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.FileSystemManagement.Thumbnails;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Thumbnails;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.Thumbnails;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GetThumbnailRequestMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetThumbnailRequestMappingTests
|
||||
{
|
||||
private readonly GetThumbnailRequestFixture _getThumbnailRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingGetThumbnailRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetThumbnailRequest request = _getThumbnailRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
GetThumbnailQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(request.Path, result.Path);
|
||||
Assert.Equal(request.Quality, result.Quality);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("C:\\test\\image.jpg", 50)]
|
||||
[InlineData("/home/user/image.png", 100)]
|
||||
[InlineData("D:\\photos\\vacation\\pic.gif", 75)]
|
||||
public void ToQuery_WhenMappingWithDifferentPathsAndQualities_ShouldMapCorrectly(string path, int quality)
|
||||
{
|
||||
// Arrange
|
||||
GetThumbnailRequest request = _getThumbnailRequestFixture.Create(path, quality);
|
||||
|
||||
// Act
|
||||
GetThumbnailQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(path, result.Path);
|
||||
Assert.Equal(quality, result.Quality);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingMultipleRequests_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<GetThumbnailRequest> requests = _getThumbnailRequestFixture.CreateMany();
|
||||
|
||||
// Act
|
||||
List<GetThumbnailQuery> results = [.. requests.Select(r => r.ToQuery())];
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(requests.Count, results.Count);
|
||||
for (int i = 0; i < requests.Count; i++)
|
||||
{
|
||||
Assert.Equal(requests[i].Path, results[i].Path);
|
||||
Assert.Equal(requests[i].Quality, results[i].Quality);
|
||||
}
|
||||
}
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Thumbnails;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Thumbnails;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.FileSystemManagement.Thumbnails;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ThumbnailMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ThumbnailMappingTests
|
||||
{
|
||||
private readonly IFixture _fixture;
|
||||
private readonly ThumbnailFixture _thumbnailFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ThumbnailMappingTests"/> class.
|
||||
/// </summary>
|
||||
public ThumbnailMappingTests()
|
||||
{
|
||||
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToResponse_WhenMappingThumbnail_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
Thumbnail domainModel = _thumbnailFixture.Create();
|
||||
|
||||
// Act
|
||||
ThumbnailResponse result = domainModel.ToResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(domainModel.Type, result.Type);
|
||||
Assert.Equal(domainModel.Bytes, result.Bytes);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(ImageType.JPEG)]
|
||||
[InlineData(ImageType.PNG)]
|
||||
[InlineData(ImageType.GIF)]
|
||||
public void ToResponse_WhenMappingDifferentImageTypes_ShouldMapCorrectly(ImageType imageType)
|
||||
{
|
||||
// Arrange
|
||||
byte[] bytes = [.. _fixture.CreateMany<byte>(100)];
|
||||
Thumbnail domainModel = _thumbnailFixture.Create(imageType, bytes);
|
||||
|
||||
// Act
|
||||
ThumbnailResponse result = domainModel.ToResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(imageType, result.Type);
|
||||
Assert.Equal(bytes, result.Bytes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToResponse_WhenMappingThumbnailWithEmptyBytes_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
ImageType imageType = _fixture.Create<ImageType>();
|
||||
byte[] emptyBytes = [];
|
||||
Thumbnail domainModel = _thumbnailFixture.Create(imageType, emptyBytes);
|
||||
|
||||
// Act
|
||||
ThumbnailResponse result = domainModel.ToResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(imageType, result.Type);
|
||||
Assert.Empty(result.Bytes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToResponse_WhenMappingMultipleThumbnails_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<Thumbnail> thumbnails = _thumbnailFixture.CreateMany(3);
|
||||
|
||||
// Act
|
||||
List<ThumbnailResponse> results = [.. thumbnails.Select(t => t.ToResponse())];
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(thumbnails.Count, results.Count);
|
||||
for (int i = 0; i < thumbnails.Count; i++)
|
||||
{
|
||||
Assert.Equal(thumbnails[i].Type, results[i].Type);
|
||||
Assert.Equal(thumbnails[i].Bytes, results[i].Bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user