Aligns the book metadata contract and consolidates metadata conversion and merging

This commit is contained in:
BinaryAlley committed 2026-12-01 18:52:30 +02:00
1 parent 590e49c9de
commit e2d8e62908
43 files changed
+1076 -849

No files matched your search

@@ -1,12 +1,10 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Nemera.Contracts.DTO.Common;
using Nemera.Contracts.DTO.MediaContributors;
using Nemera.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
using Nemera.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Nemera.Contracts.Fixtures.Core.DTO.Common;
using Nemera.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary;
using Nemera.Domain.SharedKernel.Common.Enums.BookLibrary;
using Nemera.Domain.SharedKernel.Common.Enums.Common;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -21,24 +19,12 @@ namespace Nemera.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.
public class BookMetadataDtoFixture
{
private readonly Faker _faker = new();
private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new();
private readonly GenreDtoFixture _genreDtoFixture = new();
private readonly TagDtoFixture _tagDtoFixture = new();
private readonly LanguageInfoDtoFixture _languageInfoDtoFixture = new();
private readonly WrittenContentMetadataDtoFixture _writtenContentMetadataDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="BookMetadataDto"/>.
/// </summary>
/// <param name="title">Optional. The title of the book.</param>
/// <param name="originalTitle">Optional. The original title of the book.</param>
/// <param name="description">Optional. A brief description or summary of the book.</param>
/// <param name="releaseInfo">Optional. The release information of the book.</param>
/// <param name="genres">Optional. The genres of the book.</param>
/// <param name="tags">Optional. The tags of the book.</param>
/// <param name="language">Optional. The language of the book.</param>
/// <param name="originalLanguage">Optional. The original language of the book.</param>
/// <param name="publisher">Optional. The name of the publisher of the book.</param>
/// <param name="pageCount">Optional. The number of pages in the book.</param>
/// <param name="metadata">Optional. The written content metadata of the book.</param>
/// <param name="format">Optional. The format of the book.</param>
/// <param name="edition">Optional. The edition of the book.</param>
/// <param name="volumeNumber">Optional. The volume or book number in the series.</param>
@@ -56,25 +42,12 @@ public class BookMetadataDtoFixture
/// <param name="contributors">Optional. The contributors of the book.</param>
/// <param name="ratings">Optional. The ratings of the book.</param>
/// <param name="coverImagePath">Optional. The path of the cover image of the book.</param>
/// <param name="includeTitle">Whether the title should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeReleaseInfo">Whether the release info should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGenres">Whether the genres should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTags">Whether the tags should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLanguage">Whether the language should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMetadata">Whether the written content metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFormat">Whether the format should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeVolumeNumber">Whether the volume number should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="BookMetadataDto"/>.</returns>
public BookMetadataDto Create(
string? title = null,
string? originalTitle = null,
string? description = null,
ReleaseInfoDto? releaseInfo = null,
List<GenreDto>? genres = null,
List<TagDto>? tags = null,
LanguageInfoDto? language = null,
LanguageInfoDto? originalLanguage = null,
string? publisher = null,
int? pageCount = null,
WrittenContentMetadataDto? metadata = null,
BookFormat? format = null,
string? edition = null,
float? volumeNumber = null,
@@ -92,29 +65,12 @@ public class BookMetadataDtoFixture
List<MediaContributorDto>? contributors = null,
List<BookRatingDto>? ratings = null,
string? coverImagePath = null,
bool includeTitle = true,
bool includeReleaseInfo = true,
bool includeGenres = true,
bool includeTags = true,
bool includeLanguage = true,
bool includeMetadata = true,
bool includeFormat = true,
bool includeVolumeNumber = true)
{
int releaseYear = _faker.Random.Int(1900, 2024);
return new BookMetadataDto(
includeTitle ? title ?? _faker.Lorem.Sentence(3) : null,
originalTitle,
description,
includeReleaseInfo ? (releaseInfo ?? _releaseInfoDtoFixture.Create(
originalReleaseDate: new DateOnly(releaseYear, 1, 1),
originalReleaseYear: releaseYear,
releaseCountry: _faker.PickRandom<ReleaseCountry>())) : null,
includeGenres ? (genres ?? [_genreDtoFixture.Create()]) : null,
includeTags ? (tags ?? [_tagDtoFixture.Create()]) : null,
includeLanguage ? (language ?? _languageInfoDtoFixture.Create()) : null,
originalLanguage,
publisher,
pageCount,
includeMetadata ? (metadata ?? _writtenContentMetadataDtoFixture.Create()) : null,
includeFormat ? (format ?? _faker.PickRandom<BookFormat>()) : null,
edition,
includeVolumeNumber ? (volumeNumber ?? _faker.Random.Int(1, 10)) : null,