Refactors the add book slice and shared media contributor model across the stack

This commit is contained in:
BinaryAlley committed 2026-09-12 12:12:22 -07:00
1 parent 3a2c80b615
commit 9a71a6d32b
61 files changed
+5223 -1384

No files matched your search

@@ -21,35 +21,27 @@ public class MediaContributorDtoFixture
/// Creates a random valid <see cref="MediaContributorDto"/>.
/// </summary>
/// <param name="displayName">Optional. The display name of the media contributor.</param>
/// <param name="roleName">Optional. The name of the role assigned to the media contributor.</param>
/// <param name="roleCategory">Optional. The category of the role.</param>
/// <param name="role">Optional. The canonical role assigned to the media contributor.</param>
/// <param name="legalName">Optional. The legal name of the media contributor.</param>
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeDisplayName">Whether the display name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLegalName">Whether the legal name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRole">Whether the role should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRoleName">Whether the role name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRoleCategory">Whether the role category should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="MediaContributorDto"/>.</returns>
public MediaContributorDto Create(
string? displayName = null,
string? roleName = null,
MediaContributorRoleCategory? roleCategory = null,
MediaContributorRole? role = null,
string? legalName = null,
bool includeName = true,
bool includeDisplayName = true,
bool includeLegalName = true,
bool includeRole = true,
bool includeRoleName = true,
bool includeRoleCategory = true)
bool includeRole = true)
{
return new MediaContributorDto(
Name: includeName ? new MediaContributorNameDto(
DisplayName: includeDisplayName ? displayName ?? _faker.Name.FullName() : null,
LegalName: includeLegalName ? legalName : null) : null,
Role: includeRole ? new MediaContributorRoleDto(
Name: includeRoleName ? roleName ?? _faker.Commerce.Department() : null,
Category: includeRoleCategory ? roleCategory ?? _faker.PickRandom<MediaContributorRoleCategory>() : null) : null);
Role: includeRole ? role ?? _faker.PickRandom<MediaContributorRole>() : null);
}
/// <summary>
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
/// <summary>
/// Fixture class for the <see cref="MediaContributorReferenceDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaContributorReferenceDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="MediaContributorReferenceDto"/>.
/// </summary>
/// <param name="contributorId">Optional. The Id of the media contributor.</param>
/// <param name="role">Optional. The role the contributor played.</param>
/// <returns>The created <see cref="MediaContributorReferenceDto"/>.</returns>
public MediaContributorReferenceDto Create(Guid? contributorId = null, MediaContributorRole? role = null)
{
return new MediaContributorReferenceDto(
ContributorId: contributorId ?? Guid.NewGuid(),
Role: role ?? _faker.PickRandom<MediaContributorRole>());
}
/// <summary>
/// Creates a list of <see cref="MediaContributorReferenceDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<MediaContributorReferenceDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -1,44 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
/// <summary>
/// Fixture class for the <see cref="MediaContributorRoleDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaContributorRoleDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="MediaContributorRoleDto"/>.
/// </summary>
/// <param name="name">Optional. The name of the role assigned to the media contributor.</param>
/// <param name="category">Optional. The category of the role.</param>
/// <returns>The created <see cref="MediaContributorRoleDto"/>.</returns>
public MediaContributorRoleDto Create(
string? name = null,
MediaContributorRoleCategory? category = null)
{
return new MediaContributorRoleDto(
name ?? _faker.Commerce.Department(),
category ?? _faker.PickRandom<MediaContributorRoleCategory>());
}
/// <summary>
/// Creates a list of <see cref="MediaContributorRoleDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<MediaContributorRoleDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}