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

@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.MediaLibrary.Management;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="LibraryPathPartDefinitionResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryPathPartDefinitionResponseFixture
{
/// <summary>
/// Creates a random valid <see cref="LibraryPathPartDefinitionResponse"/>.
/// </summary>
/// <param name="kind">Optional. The kind of the path part.</param>
/// <param name="valueType">Optional. The value type captured by the path part.</param>
/// <param name="defaultRepresentation">Optional. The default representation of the path part.</param>
/// <param name="isOptionalByDefault">Whether the path part is optional by default.</param>
/// <returns>The created <see cref="LibraryPathPartDefinitionResponse"/>.</returns>
public LibraryPathPartDefinitionResponse Create(
string? kind = null,
string? valueType = null,
string? defaultRepresentation = null,
bool isOptionalByDefault = false)
{
return new LibraryPathPartDefinitionResponse(
kind ?? "Artist",
valueType ?? "Text",
defaultRepresentation ?? "{0}",
isOptionalByDefault);
}
/// <summary>
/// Creates a list of <see cref="LibraryPathPartDefinitionResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<LibraryPathPartDefinitionResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,47 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.MediaLibrary.Management;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="LibraryPathTemplateCatalogResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryPathTemplateCatalogResponseFixture
{
private readonly LibraryPathPartDefinitionResponseFixture _libraryPathPartDefinitionResponseFixture = new();
private readonly LibraryPathTemplatePartResponseFixture _libraryPathTemplatePartResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="LibraryPathTemplateCatalogResponse"/>.
/// </summary>
/// <param name="parts">Optional. The path parts that can be used in the path template of the library type.</param>
/// <param name="defaultTemplateParts">Optional. The ordered parts of the default path template of the library type.</param>
/// <param name="includeParts">Whether the catalog should carry selectable path parts. When <see langword="false"/>, no parts are created.</param>
/// <param name="includeDefaultTemplateParts">Whether the catalog should carry default template parts. When <see langword="false"/>, no default template parts are created.</param>
/// <returns>The created <see cref="LibraryPathTemplateCatalogResponse"/>.</returns>
public LibraryPathTemplateCatalogResponse Create(
List<LibraryPathPartDefinitionResponse>? parts = null,
List<LibraryPathTemplatePartResponse>? defaultTemplateParts = null,
bool includeParts = true,
bool includeDefaultTemplateParts = true)
{
return new LibraryPathTemplateCatalogResponse(
includeParts ? (parts ?? _libraryPathPartDefinitionResponseFixture.CreateMany(2)) : [],
includeDefaultTemplateParts ? (defaultTemplateParts ?? _libraryPathTemplatePartResponseFixture.CreateMany(2)) : []);
}
/// <summary>
/// Creates a list of <see cref="LibraryPathTemplateCatalogResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<LibraryPathTemplateCatalogResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.MediaLibrary.Management;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="LibraryPathTemplatePartResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryPathTemplatePartResponseFixture
{
/// <summary>
/// Creates a random valid <see cref="LibraryPathTemplatePartResponse"/>.
/// </summary>
/// <param name="kind">Optional. The kind of the path part.</param>
/// <param name="representation">Optional. The literal text or the value mask of the path part.</param>
/// <param name="isOptional">Whether the path part can be absent from the path.</param>
/// <returns>The created <see cref="LibraryPathTemplatePartResponse"/>.</returns>
public LibraryPathTemplatePartResponse Create(
string? kind = null,
string? representation = null,
bool isOptional = false)
{
return new LibraryPathTemplatePartResponse(
kind ?? "Artist",
representation ?? "{0}",
isOptional);
}
/// <summary>
/// Creates a list of <see cref="LibraryPathTemplatePartResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<LibraryPathTemplatePartResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}