Files
Nemera/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/FileSystemManagement/Paths/GetPathParentRequestMappingTests.cs
T

79 lines
2.4 KiB
C#

#region ========================================================================= USING =====================================================================================
using AutoFixture;
using AutoFixture.AutoNSubstitute;
using Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathParent;
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 IFixture _fixture;
/// <summary>
/// Initializes a new instance of the <see cref="GetPathParentRequestMappingTests"/> class.
/// </summary>
public GetPathParentRequestMappingTests()
{
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
}
[Fact]
public void ToQuery_WhenMappingGetPathParentRequest_ShouldMapCorrectly()
{
// Arrange
GetPathParentRequest request = _fixture.Create<GetPathParentRequest>();
// 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 = new(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 = _fixture.CreateMany<GetPathParentRequest>().ToList();
// Act
List<GetPathParentQuery> 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);
}
}
}