#region ========================================================================= USING ===================================================================================== using Lumina.Application.Common.Mapping.FileSystemManagement.Paths; using Lumina.Contracts.Responses.FileSystemManagement.Path; using Lumina.Domain.Common.Primitives; using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects; 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 PathSegmentMappingTests { [Fact] public void ToResponse_WhenMappingPathSegment_ShouldMapCorrectly() { // Arrange Result createResult = PathSegment.Create("TestSegment", true, false); Assert.False(createResult.IsFailure); PathSegment pathSegment = createResult.Value; // Act PathSegmentResponse result = pathSegment.ToResponse(); // Assert Assert.NotNull(result); Assert.Equal(pathSegment.Name, result.Path); } [Theory] [InlineData("Folder", true, false)] [InlineData("File.txt", false, false)] [InlineData("C:", false, true)] public void ToResponse_WhenMappingDifferentPathSegmentTypes_ShouldMapCorrectly(string name, bool isDirectory, bool isDrive) { // Arrange Result createResult = PathSegment.Create(name, isDirectory, isDrive); Assert.False(createResult.IsFailure); PathSegment pathSegment = createResult.Value; // Act PathSegmentResponse result = pathSegment.ToResponse(); // Assert Assert.NotNull(result); Assert.Equal(pathSegment.Name, result.Path); } [Fact] public void ToResponses_WhenMappingMultiplePathSegments_ShouldMapAllCorrectly() { // Arrange List pathSegments = [ PathSegment.Create("C:", false, true).Value, PathSegment.Create("Users", true, false).Value, PathSegment.Create("Documents", true, false).Value, PathSegment.Create("file.txt", false, false).Value ]; // Act IEnumerable results = pathSegments.ToResponses(); // Assert Assert.NotNull(results); Assert.Equal(pathSegments.Count, results.Count()); List resultList = [.. results]; for (int i = 0; i < pathSegments.Count; i++) Assert.Equal(pathSegments[i].Name, resultList[i].Path); } }