Files

73 lines
2.5 KiB
C#

#region ========================================================================= USING =====================================================================================
using Nemera.Application.Common.Mapping.FileSystemManagement.Paths;
using Nemera.Application.Core.FileSystemManagement.Paths.Commands.CombinePath;
using Nemera.Contracts.Fixtures.Core.Requests.FileSystemManagement.Path;
using Nemera.Contracts.Requests.FileSystemManagement.Path;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Nemera.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);
}
}
}