#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;
///
/// Contains unit tests for the class.
///
[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 = new(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 requests = _combinePathRequestFixture.CreateMany();
// Act
List 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);
}
}
}