mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 06:11:10 +00:00
Replaces MVC with FastEndpoints in Lumina.Presentation.Api
This commit is contained in:
1 parent
b1a20716df
commit
c7b8bc2f1c
519 files changed
+15329
-8539
No files matched your search
+119
@@ -0,0 +1,119 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
using Lumina.Application.UnitTests.Core.FileSystemManagement.Files.Fixtures;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Files;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.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;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileMappingTests"/> class.
|
||||
/// </summary>
|
||||
public FileMappingTests()
|
||||
{
|
||||
_fileFixture = new();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToFileSystemTreeNodeResponse_WhenMappingFile_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
File domainModel = _fileFixture.CreateFile();
|
||||
|
||||
// Act
|
||||
FileSystemTreeNodeResponse result = domainModel.ToFileSystemTreeNodeResponse();
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Name.Should().Be(domainModel.Name);
|
||||
result.Path.Should().Be(domainModel.Id.Path);
|
||||
result.ItemType.Should().Be(domainModel.Type);
|
||||
result.IsExpanded.Should().BeFalse();
|
||||
result.ChildrenLoaded.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToFileSystemTreeNodeResponses_WhenMappingMultipleFiles_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
IEnumerable<File> domainModels = _fileFixture.CreateMany();
|
||||
|
||||
// Act
|
||||
IEnumerable<FileSystemTreeNodeResponse> result = domainModels.ToFileSystemTreeNodeResponses();
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Should().HaveCount(domainModels.Count());
|
||||
|
||||
List<FileSystemTreeNodeResponse> resultList = result.ToList();
|
||||
List<File> domainModelsList = domainModels.ToList();
|
||||
for (int i = 0; i < resultList.Count; i++)
|
||||
{
|
||||
resultList[i].Name.Should().Be(domainModelsList[i].Name);
|
||||
resultList[i].Path.Should().Be(domainModelsList[i].Id.Path);
|
||||
resultList[i].ItemType.Should().Be(domainModelsList[i].Type);
|
||||
resultList[i].IsExpanded.Should().BeFalse();
|
||||
resultList[i].ChildrenLoaded.Should().BeFalse();
|
||||
resultList[i].Children.Should().BeEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToResponse_WhenMappingFile_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
File domainModel = _fileFixture.CreateFile();
|
||||
|
||||
// Act
|
||||
FileResponse result = domainModel.ToResponse();
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Path.Should().Be(domainModel.Id.Path);
|
||||
result.Name.Should().Be(domainModel.Name);
|
||||
result.DateCreated.Should().Be(domainModel.DateCreated.Value);
|
||||
result.DateModified.Should().Be(domainModel.DateModified.Value);
|
||||
result.Size.Should().Be(domainModel.Size);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToResponses_WhenMappingMultipleFiles_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
IEnumerable<File> domainModels = _fileFixture.CreateMany();
|
||||
|
||||
// Act
|
||||
IEnumerable<FileResponse> result = domainModels.ToResponses();
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Should().HaveCount(domainModels.Count());
|
||||
|
||||
List<FileResponse> resultList = result.ToList();
|
||||
List<File> domainModelsList = domainModels.ToList();
|
||||
for (int i = 0; i < resultList.Count; i++)
|
||||
{
|
||||
resultList[i].Name.Should().Be(domainModelsList[i].Name);
|
||||
resultList[i].Path.Should().Be(domainModelsList[i].Id.Path);
|
||||
resultList[i].Size.Should().Be(domainModelsList[i].Size);
|
||||
resultList[i].DateCreated.Should().Be(domainModelsList[i].DateCreated.Value);
|
||||
resultList[i].DateModified.Should().Be(domainModelsList[i].DateModified.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetFiles;
|
||||
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 IFixture _fixture;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetFilesRequestMappingTests"/> class.
|
||||
/// </summary>
|
||||
public GetFilesRequestMappingTests()
|
||||
{
|
||||
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingGetFilesRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetFilesRequest request = _fixture.Create<GetFilesRequest>();
|
||||
|
||||
// Act
|
||||
GetFilesQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Path.Should().Be(request.Path);
|
||||
result.IncludeHiddenElements.Should().Be(request.IncludeHiddenElements);
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
|
||||
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 IFixture _fixture;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetTreeFilesRequestMappingTests"/> class.
|
||||
/// </summary>
|
||||
public GetTreeFilesRequestMappingTests()
|
||||
{
|
||||
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingGetTreeFilesRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetTreeFilesRequest request = _fixture.Create<GetTreeFilesRequest>();
|
||||
|
||||
// Act
|
||||
GetTreeFilesQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Path.Should().Be(request.Path);
|
||||
result.IncludeHiddenElements.Should().Be(request.IncludeHiddenElements);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user