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
+82
@@ -0,0 +1,82 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Thumbnails;
|
||||
using Lumina.Application.Core.FileSystemManagement.Thumbnails.Queries.GetThumbnail;
|
||||
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 IFixture _fixture;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetThumbnailRequestMappingTests"/> class.
|
||||
/// </summary>
|
||||
public GetThumbnailRequestMappingTests()
|
||||
{
|
||||
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingGetThumbnailRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GetThumbnailRequest request = _fixture.Create<GetThumbnailRequest>();
|
||||
|
||||
// Act
|
||||
GetThumbnailQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Path.Should().Be(request.Path);
|
||||
result.Quality.Should().Be(request.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 = new(path, quality);
|
||||
|
||||
// Act
|
||||
GetThumbnailQuery result = request.ToQuery();
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Path.Should().Be(path);
|
||||
result.Quality.Should().Be(quality);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToQuery_WhenMappingMultipleRequests_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<GetThumbnailRequest> requests = _fixture.CreateMany<GetThumbnailRequest>().ToList();
|
||||
|
||||
// Act
|
||||
List<GetThumbnailQuery> results = requests.Select(r => r.ToQuery()).ToList();
|
||||
|
||||
// Assert
|
||||
results.Should().NotBeNull();
|
||||
results.Should().HaveCount(requests.Count);
|
||||
for (int i = 0; i < requests.Count; i++)
|
||||
{
|
||||
results[i].Path.Should().Be(requests[i].Path);
|
||||
results[i].Quality.Should().Be(requests[i].Quality);
|
||||
}
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Thumbnails;
|
||||
using Lumina.Contracts.Enums.PhotoLibrary;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Thumbnails;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.ValueObjects;
|
||||
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;
|
||||
|
||||
/// <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 = _fixture.Create<Thumbnail>();
|
||||
|
||||
// Act
|
||||
ThumbnailResponse result = domainModel.ToResponse();
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Type.Should().Be(domainModel.Type);
|
||||
result.Bytes.Should().BeEquivalentTo(domainModel.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).ToArray();
|
||||
Thumbnail domainModel = new(imageType, bytes);
|
||||
|
||||
// Act
|
||||
ThumbnailResponse result = domainModel.ToResponse();
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Type.Should().Be(imageType);
|
||||
result.Bytes.Should().BeEquivalentTo(bytes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToResponse_WhenMappingThumbnailWithEmptyBytes_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
ImageType imageType = _fixture.Create<ImageType>();
|
||||
byte[] emptyBytes = [];
|
||||
Thumbnail domainModel = new(imageType, emptyBytes);
|
||||
|
||||
// Act
|
||||
ThumbnailResponse result = domainModel.ToResponse();
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Type.Should().Be(imageType);
|
||||
result.Bytes.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToResponse_WhenMappingMultipleThumbnails_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<Thumbnail> thumbnails = _fixture.CreateMany<Thumbnail>(3).ToList();
|
||||
|
||||
// Act
|
||||
List<ThumbnailResponse> results = thumbnails.Select(t => t.ToResponse()).ToList();
|
||||
|
||||
// Assert
|
||||
results.Should().NotBeNull();
|
||||
results.Should().HaveCount(thumbnails.Count);
|
||||
for (int i = 0; i < thumbnails.Count; i++)
|
||||
{
|
||||
results[i].Type.Should().Be(thumbnails[i].Type);
|
||||
results[i].Bytes.Should().BeEquivalentTo(thumbnails[i].Bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user