Adds the test suites for the library path templates and centralizes their resolution in the domain service

This commit is contained in:
BinaryAlley committed 2026-10-05 20:15:00 +03:00
1 parent ca4f308b0a
commit 7ed6f05632
52 files changed
+4724 -40

No files matched your search

@@ -16,6 +16,7 @@ namespace Lumina.Application.UnitTests.Common.Mapping.MediaLibrary.Management;
public class AddMediaLibraryRequestMappingTests
{
private readonly AddLibraryRequestFixture _addLibraryRequestFixture = new();
private readonly LibraryPathTemplatePartRequestFixture _libraryPathTemplatePartRequestFixture = new();
[Fact]
public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
@@ -144,4 +145,45 @@ public class AddMediaLibraryRequestMappingTests
Assert.NotNull(result);
Assert.Null(result.CoverImage);
}
[Fact]
public void ToCommand_WhenRequestHasPathTemplateParts_ShouldMapToDtoArray()
{
// Arrange
LibraryPathTemplatePartRequest literalPart = _libraryPathTemplatePartRequestFixture.Create(
kind: nameof(LibraryPathPartKind.Literal),
representation: "Various Artists",
isOptional: false);
LibraryPathTemplatePartRequest typedPart = _libraryPathTemplatePartRequestFixture.Create(
kind: nameof(LibraryPathPartKind.Artist),
representation: "{0}",
isOptional: true);
AddLibraryRequest request = _addLibraryRequestFixture.Create(pathTemplateParts: [literalPart, typedPart]);
// Act
AddLibraryCommand result = request.ToCommand();
// Assert
Assert.NotNull(result.PathTemplateParts);
Assert.Equal(2, result.PathTemplateParts.Length);
Assert.Equal(literalPart.Kind, result.PathTemplateParts[0].Kind);
Assert.Equal(literalPart.Representation, result.PathTemplateParts[0].Representation);
Assert.Equal(literalPart.IsOptional, result.PathTemplateParts[0].IsOptional);
Assert.Equal(typedPart.Kind, result.PathTemplateParts[1].Kind);
Assert.Equal(typedPart.Representation, result.PathTemplateParts[1].Representation);
Assert.Equal(typedPart.IsOptional, result.PathTemplateParts[1].IsOptional);
}
[Fact]
public void ToCommand_WhenPathTemplatePartsIsNull_ShouldMapToNull()
{
// Arrange
AddLibraryRequest request = _addLibraryRequestFixture.Create(pathTemplateParts: null);
// Act
AddLibraryCommand result = request.ToCommand();
// Assert
Assert.Null(result.PathTemplateParts);
}
}
@@ -0,0 +1,47 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraryPathTemplateParts;
using Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.Management;
using Lumina.Contracts.Requests.MediaLibrary.Management;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Application.UnitTests.Common.Mapping.MediaLibrary.Management;
/// <summary>
/// Contains unit tests for the <see cref="GetLibraryPathTemplatePartsRequestMapping"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetLibraryPathTemplatePartsRequestMappingTests
{
private readonly GetLibraryPathTemplatePartsRequestFixture _getLibraryPathTemplatePartsRequestFixture = new();
[Fact]
public void ToQuery_WhenMappingValidRequest_ShouldMapLibraryType()
{
// Arrange
GetLibraryPathTemplatePartsRequest request = _getLibraryPathTemplatePartsRequestFixture.Create(libraryType: "Book");
// Act
GetLibraryPathTemplatePartsQuery result = request.ToQuery();
// Assert
Assert.Equal("Book", result.LibraryType);
}
[Theory]
[InlineData("Book")] // a written content library type
[InlineData("Movie")] // a video library type
[InlineData("Music")] // an audio library type
public void ToQuery_WhenMappingDifferentLibraryTypes_ShouldMapLibraryType(string libraryType)
{
// Arrange
GetLibraryPathTemplatePartsRequest request = _getLibraryPathTemplatePartsRequestFixture.Create(libraryType: libraryType);
// Act
GetLibraryPathTemplatePartsQuery result = request.ToQuery();
// Assert
Assert.Equal(libraryType, result.LibraryType);
}
}
@@ -3,10 +3,14 @@ using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using DomainErrors = Lumina.Domain.Common.Errors.Errors;
#endregion
namespace Lumina.Application.UnitTests.Common.Mapping.MediaLibrary.Management;
@@ -18,6 +22,7 @@ namespace Lumina.Application.UnitTests.Common.Mapping.MediaLibrary.Management;
public class LibraryEntityMappingTests
{
private readonly LibraryEntityFixture _libraryEntityFixture = new();
private readonly LibraryPathTemplatePartEntityFixture _libraryPathTemplatePartEntityFixture = new();
[Fact]
public void ToResponse_WhenMappingValidLibraryEntity_ShouldMapCorrectly()
@@ -123,4 +128,126 @@ public class LibraryEntityMappingTests
Assert.NotNull(result);
Assert.Null(result.CoverImage);
}
[Fact]
public void ToResponse_WhenLibraryHasPathTemplateParts_ShouldOrderByPositionAndMapProperties()
{
// Arrange
LibraryPathTemplatePartEntity firstPart = _libraryPathTemplatePartEntityFixture.Create(
position: 2,
kind: LibraryPathPartKind.Artist,
representation: "{0}",
isOptional: true);
LibraryPathTemplatePartEntity secondPart = _libraryPathTemplatePartEntityFixture.Create(
position: 0,
kind: LibraryPathPartKind.Literal,
representation: "Various Artists");
LibraryPathTemplatePartEntity thirdPart = _libraryPathTemplatePartEntityFixture.Create(
position: 1,
kind: LibraryPathPartKind.Separator,
representation: string.Empty);
LibraryEntity entity = _libraryEntityFixture.Create(
title: "My Library",
libraryType: LibraryType.Book,
contentLocations: ["C:/Books"],
pathTemplateParts: [firstPart, secondPart, thirdPart]);
// Act
LibraryResponse result = entity.ToResponse();
// Assert
Assert.Equal(3, result.PathTemplateParts.Count);
Assert.Equal(LibraryPathPartKind.Literal.ToString(), result.PathTemplateParts[0].Kind);
Assert.Equal("Various Artists", result.PathTemplateParts[0].Representation);
Assert.False(result.PathTemplateParts[0].IsOptional);
Assert.Equal(LibraryPathPartKind.Separator.ToString(), result.PathTemplateParts[1].Kind);
Assert.Equal(string.Empty, result.PathTemplateParts[1].Representation);
Assert.False(result.PathTemplateParts[1].IsOptional);
Assert.Equal(LibraryPathPartKind.Artist.ToString(), result.PathTemplateParts[2].Kind);
Assert.Equal("{0}", result.PathTemplateParts[2].Representation);
Assert.True(result.PathTemplateParts[2].IsOptional);
}
[Fact]
public void ToDomainEntity_WhenLibraryHasPathTemplateParts_ShouldBuildTemplateFromOrderedParts()
{
// Arrange
LibraryPathTemplatePartEntity firstPart = _libraryPathTemplatePartEntityFixture.Create(
position: 1,
kind: LibraryPathPartKind.Artist,
representation: "{0}",
isOptional: true);
LibraryPathTemplatePartEntity secondPart = _libraryPathTemplatePartEntityFixture.Create(
position: 0,
kind: LibraryPathPartKind.Literal,
representation: "Various Artists");
LibraryEntity entity = _libraryEntityFixture.Create(
title: "My Library",
libraryType: LibraryType.Book,
contentLocations: ["C:/Books"],
coverImage: "D:/cover.jpg",
pathTemplateParts: [firstPart, secondPart]);
// Act
Result<Library> result = entity.ToDomainEntity();
// Assert
Assert.False(result.IsFailure);
Assert.Equal(entity.Id, result.Value.Id.Value);
Assert.Equal(entity.UserId, result.Value.UserId.Value);
Assert.Equal(entity.Title, result.Value.Title);
Assert.Equal(entity.LibraryType, result.Value.LibraryType);
Assert.Equal("D:/cover.jpg", result.Value.CoverImage.Value);
Assert.Equal(2, result.Value.PathTemplate.Parts.Count);
Assert.Equal(LibraryPathPartKind.Literal, result.Value.PathTemplate.Parts[0].Kind);
Assert.Equal("Various Artists", result.Value.PathTemplate.Parts[0].Representation);
Assert.False(result.Value.PathTemplate.Parts[0].IsOptional);
Assert.Equal(LibraryPathPartKind.Artist, result.Value.PathTemplate.Parts[1].Kind);
Assert.Equal("{0}", result.Value.PathTemplate.Parts[1].Representation);
Assert.True(result.Value.PathTemplate.Parts[1].IsOptional);
}
[Fact]
public void ToDomainEntity_WhenStoredTypedPartHasEmptyRepresentation_ShouldReturnPathTemplateLiteralCannotBeEmpty()
{
// Arrange
LibraryPathTemplatePartEntity invalidPart = _libraryPathTemplatePartEntityFixture.Create(
position: 0,
kind: LibraryPathPartKind.Artist,
representation: string.Empty);
LibraryEntity entity = _libraryEntityFixture.Create(
title: "My Library",
libraryType: LibraryType.Book,
contentLocations: ["C:/Books"],
pathTemplateParts: [invalidPart]);
// Act
Result<Library> result = entity.ToDomainEntity();
// Assert
Assert.True(result.IsFailure);
Assert.Equal(DomainErrors.Library.PathTemplateLiteralCannotBeEmpty, result.FirstError);
}
[Fact]
public void ToDomainEntity_WhenStoredTypedPartHasNoPlaceholder_ShouldReturnPathTemplateValuePartMustContainSinglePlaceholder()
{
// Arrange
LibraryPathTemplatePartEntity invalidPart = _libraryPathTemplatePartEntityFixture.Create(
position: 0,
kind: LibraryPathPartKind.TrackNumber,
representation: "Track");
LibraryEntity entity = _libraryEntityFixture.Create(
title: "My Library",
libraryType: LibraryType.Book,
contentLocations: ["C:/Books"],
pathTemplateParts: [invalidPart]);
// Act
Result<Library> result = entity.ToDomainEntity();
// Assert
Assert.True(result.IsFailure);
Assert.Equal(DomainErrors.Library.PathTemplateValuePartMustContainSinglePlaceholder, result.FirstError);
}
}
@@ -4,7 +4,9 @@ using Lumina.Application.Common.Mapping.Common.Metadata;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
@@ -21,6 +23,8 @@ namespace Lumina.Application.UnitTests.Common.Mapping.MediaLibrary.Management;
public class LibraryMappingTests
{
private readonly LibraryFixture _libraryFixture = new();
private readonly LibraryPathPartFixture _libraryPathPartFixture = new();
private readonly LibraryPathTemplateFixture _libraryPathTemplateFixture = new();
[Fact]
public void ToRepositoryEntity_WhenMappingValidLibrary_ShouldMapCorrectly()
@@ -185,4 +189,57 @@ public class LibraryMappingTests
Assert.NotNull(library.ScanIds);
Assert.NotNull(result.LibraryScans);
}
[Fact]
public void ToRepositoryEntity_WhenLibraryHasPathTemplateParts_ShouldMapPartsWithSequentialPositions()
{
// Arrange
LibraryPathPart literalPart = _libraryPathPartFixture.Create(
kind: LibraryPathPartKind.Literal,
representation: "Various Artists",
isOptional: false);
LibraryPathPart typedPart = _libraryPathPartFixture.Create(
kind: LibraryPathPartKind.Artist,
representation: "{0}",
isOptional: true);
LibraryPathTemplate pathTemplate = _libraryPathTemplateFixture.Create(parts: [literalPart, typedPart]);
Library library = _libraryFixture.Create(
title: "Test Library",
libraryType: LibraryType.Book,
contentLocations: ["C:/Books"],
pathTemplate: pathTemplate);
// Act
LibraryEntity result = library.ToRepositoryEntity();
// Assert
List<LibraryPathTemplatePartEntity> parts = [.. result.PathTemplateParts.OrderBy(part => part.Position)];
Assert.Equal(2, parts.Count);
Assert.Equal(0, parts[0].Position);
Assert.Equal(LibraryPathPartKind.Literal, parts[0].Kind);
Assert.Equal("Various Artists", parts[0].Representation);
Assert.False(parts[0].IsOptional);
Assert.Equal(1, parts[1].Position);
Assert.Equal(LibraryPathPartKind.Artist, parts[1].Kind);
Assert.Equal("{0}", parts[1].Representation);
Assert.True(parts[1].IsOptional);
}
[Fact]
public void ToRepositoryEntity_WhenLibraryHasNoPathTemplateParts_ShouldMapEmptyCollection()
{
// Arrange
LibraryPathTemplate pathTemplate = _libraryPathTemplateFixture.Create(includeParts: false);
Library library = _libraryFixture.Create(
title: "Test Library",
libraryType: LibraryType.Book,
contentLocations: ["C:/Books"],
pathTemplate: pathTemplate);
// Act
LibraryEntity result = library.ToRepositoryEntity();
// Assert
Assert.Empty(result.PathTemplateParts);
}
}
@@ -0,0 +1,204 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DTO.MediaLibrary.Management;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Application.Fixtures.Common.DTO.MediaLibrary.Management;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using DomainErrors = Lumina.Domain.Common.Errors.Errors;
#endregion
namespace Lumina.Application.UnitTests.Common.Mapping.MediaLibrary.Management;
/// <summary>
/// Contains unit tests for the <see cref="LibraryPathTemplatePartDtoMapping"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryPathTemplatePartDtoMappingTests
{
private readonly LibraryPathTemplatePartDtoFixture _libraryPathTemplatePartDtoFixture = new();
[Fact]
public void ToDomainParts_WhenPartsIsNull_ShouldReturnEmptyList()
{
// Act
Result<IReadOnlyList<LibraryPathPart>> result = LibraryPathTemplatePartDtoMapping.ToDomainParts(null);
// Assert
Assert.False(result.IsFailure);
Assert.Empty(result.Value);
}
[Fact]
public void ToDomainParts_WhenPartsIsEmpty_ShouldReturnEmptyList()
{
// Arrange
List<LibraryPathTemplatePartDto> parts = [];
// Act
Result<IReadOnlyList<LibraryPathPart>> result = parts.ToDomainParts();
// Assert
Assert.False(result.IsFailure);
Assert.Empty(result.Value);
}
[Fact]
public void ToDomainParts_WhenPartsAreValid_ShouldMapKindRepresentationAndIsOptional()
{
// Arrange
LibraryPathTemplatePartDto literalPart = _libraryPathTemplatePartDtoFixture.Create(
kind: nameof(LibraryPathPartKind.Literal),
representation: "Various Artists",
isOptional: false);
LibraryPathTemplatePartDto typedPart = _libraryPathTemplatePartDtoFixture.Create(
kind: nameof(LibraryPathPartKind.Artist),
representation: "{0}",
isOptional: true);
LibraryPathTemplatePartDto[] parts = [literalPart, typedPart];
// Act
Result<IReadOnlyList<LibraryPathPart>> result = parts.ToDomainParts();
// Assert
Assert.False(result.IsFailure);
Assert.Equal(2, result.Value.Count);
Assert.Equal(LibraryPathPartKind.Literal, result.Value[0].Kind);
Assert.Equal("Various Artists", result.Value[0].Representation);
Assert.False(result.Value[0].IsOptional);
Assert.Equal(LibraryPathPartKind.Artist, result.Value[1].Kind);
Assert.Equal("{0}", result.Value[1].Representation);
Assert.True(result.Value[1].IsOptional);
}
[Fact]
public void ToDomainParts_WhenPartIsSeparator_ShouldMapWithEmptyRepresentation()
{
// Arrange
LibraryPathTemplatePartDto separatorPart = _libraryPathTemplatePartDtoFixture.Create(
kind: nameof(LibraryPathPartKind.Separator),
representation: @"\",
isOptional: false);
LibraryPathTemplatePartDto[] parts = [separatorPart];
// Act
Result<IReadOnlyList<LibraryPathPart>> result = parts.ToDomainParts();
// Assert
Assert.False(result.IsFailure);
Assert.Single(result.Value);
Assert.Equal(LibraryPathPartKind.Separator, result.Value[0].Kind);
Assert.Equal(string.Empty, result.Value[0].Representation);
Assert.False(result.Value[0].IsOptional);
}
[Fact]
public void ToDomainParts_WhenKindIsUnknown_ShouldReturnPathTemplatePartKindNotSupportedForLibraryType()
{
// Arrange
LibraryPathTemplatePartDto part = _libraryPathTemplatePartDtoFixture.Create(kind: "NotARealLibraryPathPartKind");
LibraryPathTemplatePartDto[] parts = [part];
// Act
Result<IReadOnlyList<LibraryPathPart>> result = parts.ToDomainParts();
// Assert
Assert.True(result.IsFailure);
Assert.Equal(DomainErrors.Library.PathTemplatePartKindNotSupportedForLibraryType, result.FirstError);
}
[Fact]
public void ToDomainParts_WhenKindIsNull_ShouldReturnPathTemplatePartKindNotSupportedForLibraryType()
{
// Arrange
LibraryPathTemplatePartDto part = _libraryPathTemplatePartDtoFixture.Create() with { Kind = null };
LibraryPathTemplatePartDto[] parts = [part];
// Act
Result<IReadOnlyList<LibraryPathPart>> result = parts.ToDomainParts();
// Assert
Assert.True(result.IsFailure);
Assert.Equal(DomainErrors.Library.PathTemplatePartKindNotSupportedForLibraryType, result.FirstError);
}
[Fact]
public void ToDomainParts_WhenKindUsesDifferentCasing_ShouldMapKind()
{
// Arrange
LibraryPathTemplatePartDto part = _libraryPathTemplatePartDtoFixture.Create(
kind: "artist",
representation: "{0}",
isOptional: false);
LibraryPathTemplatePartDto[] parts = [part];
// Act
Result<IReadOnlyList<LibraryPathPart>> result = parts.ToDomainParts();
// Assert
Assert.False(result.IsFailure);
Assert.Single(result.Value);
Assert.Equal(LibraryPathPartKind.Artist, result.Value[0].Kind);
Assert.Equal("{0}", result.Value[0].Representation);
Assert.False(result.Value[0].IsOptional);
}
[Fact]
public void ToDomainParts_WhenTypedPartRepresentationIsEmpty_ShouldReturnPathTemplateLiteralCannotBeEmpty()
{
// Arrange
LibraryPathTemplatePartDto part = _libraryPathTemplatePartDtoFixture.Create(
kind: nameof(LibraryPathPartKind.Artist),
representation: string.Empty);
LibraryPathTemplatePartDto[] parts = [part];
// Act
Result<IReadOnlyList<LibraryPathPart>> result = parts.ToDomainParts();
// Assert
Assert.True(result.IsFailure);
Assert.Equal(DomainErrors.Library.PathTemplateLiteralCannotBeEmpty, result.FirstError);
}
[Fact]
public void ToDomainParts_WhenTypedPartRepresentationHasNoPlaceholder_ShouldReturnPathTemplateValuePartMustContainSinglePlaceholder()
{
// Arrange
LibraryPathTemplatePartDto part = _libraryPathTemplatePartDtoFixture.Create(
kind: nameof(LibraryPathPartKind.Artist),
representation: "Artist Name");
LibraryPathTemplatePartDto[] parts = [part];
// Act
Result<IReadOnlyList<LibraryPathPart>> result = parts.ToDomainParts();
// Assert
Assert.True(result.IsFailure);
Assert.Equal(DomainErrors.Library.PathTemplateValuePartMustContainSinglePlaceholder, result.FirstError);
}
[Fact]
public void ToDomainParts_WhenTypedPartRepresentationHasDuplicatePlaceholder_ShouldReturnPathTemplateValuePartMustContainSinglePlaceholder()
{
// Arrange
LibraryPathTemplatePartDto part = _libraryPathTemplatePartDtoFixture.Create(
kind: nameof(LibraryPathPartKind.Artist),
representation: "{0} - {0}");
LibraryPathTemplatePartDto[] parts = [part];
// Act
Result<IReadOnlyList<LibraryPathPart>> result = parts.ToDomainParts();
// Assert
Assert.True(result.IsFailure);
Assert.Equal(DomainErrors.Library.PathTemplateValuePartMustContainSinglePlaceholder, result.FirstError);
}
}
@@ -3,6 +3,7 @@ using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary;
using Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.Management;
using Lumina.Contracts.Requests.MediaLibrary.Management;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -15,6 +16,7 @@ namespace Lumina.Application.UnitTests.Common.Mapping.MediaLibrary.Management;
public class UpdateLibraryRequestMappingTests
{
private readonly UpdateLibraryRequestFixture _updateLibraryRequestFixture = new();
private readonly LibraryPathTemplatePartRequestFixture _libraryPathTemplatePartRequestFixture = new();
[Fact]
public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
@@ -46,4 +48,45 @@ public class UpdateLibraryRequestMappingTests
Assert.Equal(request.ShouldSaveMetadataInMediaDirectories, result.ShouldSaveMetadataInMediaDirectories);
Assert.Equal(request.ShouldSkipUnchangedDirectoriesDuringScan, result.ShouldSkipUnchangedDirectoriesDuringScan);
}
[Fact]
public void ToCommand_WhenRequestHasPathTemplateParts_ShouldMapToDtoArray()
{
// Arrange
LibraryPathTemplatePartRequest literalPart = _libraryPathTemplatePartRequestFixture.Create(
kind: nameof(LibraryPathPartKind.Literal),
representation: "Various Artists",
isOptional: false);
LibraryPathTemplatePartRequest typedPart = _libraryPathTemplatePartRequestFixture.Create(
kind: nameof(LibraryPathPartKind.Artist),
representation: "{0}",
isOptional: true);
UpdateLibraryRequest request = _updateLibraryRequestFixture.Create(pathTemplateParts: [literalPart, typedPart]);
// Act
UpdateLibraryCommand result = request.ToCommand();
// Assert
Assert.NotNull(result.PathTemplateParts);
Assert.Equal(2, result.PathTemplateParts.Length);
Assert.Equal(literalPart.Kind, result.PathTemplateParts[0].Kind);
Assert.Equal(literalPart.Representation, result.PathTemplateParts[0].Representation);
Assert.Equal(literalPart.IsOptional, result.PathTemplateParts[0].IsOptional);
Assert.Equal(typedPart.Kind, result.PathTemplateParts[1].Kind);
Assert.Equal(typedPart.Representation, result.PathTemplateParts[1].Representation);
Assert.Equal(typedPart.IsOptional, result.PathTemplateParts[1].IsOptional);
}
[Fact]
public void ToCommand_WhenPathTemplatePartsIsNull_ShouldMapToNull()
{
// Arrange
UpdateLibraryRequest request = _updateLibraryRequestFixture.Create(pathTemplateParts: null);
// Act
UpdateLibraryCommand result = request.ToCommand();
// Assert
Assert.Null(result.PathTemplateParts);
}
}