mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 12:11:10 +00:00
Adds independent metadata and artwork enrichment
Splits the single combined enrichment phase of the media library scan into independent, modular jobs, so that the metadata and the artwork of a book are enriched separately and only when their respective triggers fire. - Adds the MediaContributorRoleCategory enum (Other first, then Author, Translator, Illustrator, Publisher and Narrator) and makes the role category canonical, so that roles describing the same kind of contribution are never treated as distinct. - Realizes the media contributor bounded context: a MediaContributor is a person, unique by display name, without a role. The role moves to the per-work participation (BookContributors), so that a single contributor can play multiple roles. Contributors are created and linked by the metadata enrichment job, and exposed to subsequent jobs. - Makes the Book aggregate pure: the enrichment tracking state (metadata status, providers, timestamps and covers) no longer lives on the domain aggregate, but stays in the Books table, managed directly by the jobs. - Models artwork generically as a BookArtwork child table (type, ordinal, content hash, status and provider), so that each piece of artwork is tracked independently and a change of one does not require the others to be re-fetched. - Splits the scan DAG into ResultsSave, ProviderConfigurationInvalidation, MetadataEnrichment and ArtworkEnrichment jobs. The invalidation job fingerprints the provider configuration of a library and resets the enrichment state of the affected channel when it changed. The artwork job resolves the missing artwork, hashing it to detect identical covers and skip re-copying. Content-changed books are reset by the results save job. - Deletes the book and its stored artwork when the file disappears from the library. - Adds the migration creating the new tables, backfilling the existing covers into the artwork table, and adding the configuration fingerprints. - Localizes the new scan job stages, and fixes the invalidation job wiping the library content locations by persisting the fingerprints through the change tracker instead of the repository update action.
This commit is contained in:
1 parent
4ee2976806
commit
565fe68239
98 files changed
+5845
-630
No files matched your search
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaContributors;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaContributors;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookContributorEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookContributorEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookContributorEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the participation.</param>
|
||||
/// <param name="bookId">Optional. The Id of the book the contributor participated in.</param>
|
||||
/// <param name="mediaContributorId">Optional. The Id of the media contributor.</param>
|
||||
/// <param name="roleName">Optional. The display name of the role the contributor played in the book.</param>
|
||||
/// <param name="roleCategory">Optional. The canonical category of the role the contributor played in the book.</param>
|
||||
/// <returns>The created <see cref="BookContributorEntity"/>.</returns>
|
||||
public BookContributorEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? bookId = null,
|
||||
Guid? mediaContributorId = null,
|
||||
string? roleName = null,
|
||||
MediaContributorRoleCategory? roleCategory = null)
|
||||
{
|
||||
return new BookContributorEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
BookId = bookId ?? Guid.NewGuid(),
|
||||
MediaContributorId = mediaContributorId ?? Guid.NewGuid(),
|
||||
RoleName = roleName ?? _faker.Lorem.Word(),
|
||||
RoleCategory = roleCategory ?? _faker.PickRandom<MediaContributorRoleCategory>(),
|
||||
CreatedOnUtc = _faker.Date.Past(),
|
||||
CreatedBy = Guid.NewGuid(),
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="BookContributorEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookContributorEntity"/> instances.</returns>
|
||||
public List<BookContributorEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaContributors;
|
||||
using Lumina.Application.Fixtures.Common.Setup;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaContributors;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaContributorEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaContributorEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaContributorEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the media contributor.</param>
|
||||
/// <param name="displayName">Optional. The name by which the contributor is popularly known.</param>
|
||||
/// <param name="legalName">Optional. The legal name of the contributor.</param>
|
||||
/// <param name="biography">Optional. The biography of the contributor.</param>
|
||||
/// <param name="dateOfBirth">Optional. The date of birth of the contributor.</param>
|
||||
/// <param name="dateOfDeath">Optional. The date of death of the contributor.</param>
|
||||
/// <returns>The created <see cref="MediaContributorEntity"/>.</returns>
|
||||
public MediaContributorEntity Create(
|
||||
Guid? id = null,
|
||||
string? displayName = null,
|
||||
string? legalName = null,
|
||||
string? biography = null,
|
||||
DateOnly? dateOfBirth = null,
|
||||
DateOnly? dateOfDeath = null)
|
||||
{
|
||||
return new MediaContributorEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
DisplayName = displayName ?? _faker.Person.FullName,
|
||||
LegalName = legalName ?? _faker.Person.FullName,
|
||||
Biography = biography ?? _faker.Lorem.Sentence(),
|
||||
DateOfBirth = dateOfBirth ?? _faker.DateOnlyBetween(new DateOnly(1900, 1, 1), new DateOnly(2000, 12, 31)),
|
||||
DateOfDeath = dateOfDeath,
|
||||
CreatedOnUtc = _faker.Date.Past(),
|
||||
CreatedBy = Guid.NewGuid(),
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaContributorEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaContributorEntity"/> instances.</returns>
|
||||
public List<MediaContributorEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -30,6 +30,8 @@ public class LibraryEntityFixture
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether the metadata should be saved in the media directories or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during a scan or not.</param>
|
||||
/// <param name="metadataProvidersConfigurationFingerprint">Optional. The fingerprint of the metadata provider configuration of the media library.</param>
|
||||
/// <param name="artworkProvidersConfigurationFingerprint">Optional. The fingerprint of the artwork provider configuration of the media library.</param>
|
||||
/// <returns>The created media library entity.</returns>
|
||||
public LibraryEntity Create(
|
||||
Guid? id = null,
|
||||
@@ -42,7 +44,9 @@ public class LibraryEntityFixture
|
||||
bool isLocked = false,
|
||||
bool canDownloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = true,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false)
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false,
|
||||
string? metadataProvidersConfigurationFingerprint = null,
|
||||
string? artworkProvidersConfigurationFingerprint = null)
|
||||
{
|
||||
return new Faker<LibraryEntity>()
|
||||
.CustomInstantiator(f => new LibraryEntity
|
||||
@@ -59,6 +63,8 @@ public class LibraryEntityFixture
|
||||
CanDownloadMetadataFromWeb = canDownloadMetadataFromWeb,
|
||||
ShouldSaveMetadataInMediaDirectories = shouldSaveMetadataInMediaDirectories,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan = shouldSkipUnchangedDirectoriesDuringScan,
|
||||
MetadataProvidersConfigurationFingerprint = metadataProvidersConfigurationFingerprint,
|
||||
ArtworkProvidersConfigurationFingerprint = artworkProvidersConfigurationFingerprint,
|
||||
CreatedOnUtc = default,
|
||||
CreatedBy = default,
|
||||
UpdatedOnUtc = null,
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookArtworkEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookArtworkEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookArtworkEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the artwork.</param>
|
||||
/// <param name="bookId">Optional. The Id of the book the artwork belongs to.</param>
|
||||
/// <param name="artworkType">Optional. The type of the artwork.</param>
|
||||
/// <param name="ordinal">Optional. The ordinal of the artwork within its type.</param>
|
||||
/// <param name="fileName">Optional. The relative file name of the stored artwork.</param>
|
||||
/// <param name="contentHash">Optional. The content hash of the stored artwork.</param>
|
||||
/// <param name="status">Optional. The status of the artwork enrichment.</param>
|
||||
/// <param name="provider">Optional. The name of the plugin that resolved the artwork.</param>
|
||||
/// <param name="lastUpdateUtc">Optional. The date and time when the artwork was last resolved.</param>
|
||||
/// <returns>The created <see cref="BookArtworkEntity"/>.</returns>
|
||||
public BookArtworkEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? bookId = null,
|
||||
ArtworkType? artworkType = null,
|
||||
int? ordinal = null,
|
||||
string? fileName = null,
|
||||
ulong? contentHash = null,
|
||||
ArtworkStatus? status = null,
|
||||
string? provider = null,
|
||||
DateTime? lastUpdateUtc = null)
|
||||
{
|
||||
return new BookArtworkEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
BookId = bookId ?? Guid.NewGuid(),
|
||||
ArtworkType = artworkType ?? ArtworkType.Cover,
|
||||
Ordinal = ordinal ?? 0,
|
||||
FileName = fileName ?? _faker.System.FilePath(),
|
||||
ContentHash = contentHash ?? (ulong)_faker.Random.ULong(),
|
||||
Status = status ?? _faker.PickRandom<ArtworkStatus>(),
|
||||
Provider = provider ?? _faker.Company.CompanyName(),
|
||||
LastUpdateUtc = lastUpdateUtc ?? _faker.Date.Recent(),
|
||||
CreatedOnUtc = _faker.Date.Past(),
|
||||
CreatedBy = Guid.NewGuid(),
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="BookArtworkEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookArtworkEntity"/> instances.</returns>
|
||||
public List<BookArtworkEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -8,6 +8,7 @@ using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
@@ -78,7 +79,7 @@ public class AddBookCommandFixture
|
||||
default!
|
||||
))
|
||||
.RuleFor(e => e.Name, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(e => e.Category, f => f.Random.String2(f.Random.Number(1, 50)));
|
||||
.RuleFor(e => e.Category, f => f.PickRandom<MediaContributorRoleCategory>());
|
||||
|
||||
Faker<MediaContributorNameDto> mediaContributorName = new Faker<MediaContributorNameDto>()
|
||||
.CustomInstantiator(f => new MediaContributorNameDto(
|
||||
|
||||
+5
-4
@@ -1,6 +1,7 @@
|
||||
#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;
|
||||
@@ -24,13 +25,13 @@ public class MediaContributorDtoFixture
|
||||
/// <param name="roleCategory">Optional. The category of the role.</param>
|
||||
/// <returns>The created <see cref="MediaContributorDto"/>.</returns>
|
||||
public MediaContributorDto Create(
|
||||
string? displayName = null,
|
||||
string? roleName = null,
|
||||
string? roleCategory = null)
|
||||
string? displayName = null,
|
||||
string? roleName = null,
|
||||
MediaContributorRoleCategory? roleCategory = null)
|
||||
{
|
||||
return new MediaContributorDto(
|
||||
Name: new MediaContributorNameDto(DisplayName: displayName ?? _faker.Name.FullName(), LegalName: null),
|
||||
Role: new MediaContributorRoleDto(Name: roleName ?? _faker.Commerce.Department(), Category: roleCategory ?? "Writing"));
|
||||
Role: new MediaContributorRoleDto(Name: roleName ?? _faker.Commerce.Department(), Category: roleCategory ?? _faker.PickRandom<MediaContributorRoleCategory>()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+4
-3
@@ -1,6 +1,7 @@
|
||||
#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;
|
||||
@@ -23,12 +24,12 @@ public class MediaContributorRoleDtoFixture
|
||||
/// <param name="category">Optional. The category of the role.</param>
|
||||
/// <returns>The created <see cref="MediaContributorRoleDto"/>.</returns>
|
||||
public MediaContributorRoleDto Create(
|
||||
string? name = null,
|
||||
string? category = null)
|
||||
string? name = null,
|
||||
MediaContributorRoleCategory? category = null)
|
||||
{
|
||||
return new MediaContributorRoleDto(
|
||||
name ?? _faker.Commerce.Department(),
|
||||
category ?? _faker.Commerce.Department());
|
||||
category ?? _faker.PickRandom<MediaContributorRoleCategory>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Fixtures.Common.Setup;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -119,7 +120,7 @@ public class AddBookRequestFixture
|
||||
default!
|
||||
))
|
||||
.RuleFor(e => e.Name, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(e => e.Category, f => f.Random.String2(f.Random.Number(1, 50)));
|
||||
.RuleFor(e => e.Category, f => f.PickRandom<MediaContributorRoleCategory>());
|
||||
|
||||
Faker<MediaContributorNameDto> mediaContributorName = new Faker<MediaContributorNameDto>()
|
||||
.CustomInstantiator(f => new MediaContributorNameDto(
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@ using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -65,7 +66,7 @@ public class BookResponseFixture
|
||||
[new IsbnDto(_faker.Random.Replace("###-#-##-#####-#"), IsbnFormat.Isbn13)],
|
||||
[new MediaContributorDto(
|
||||
new MediaContributorNameDto(_faker.Name.FullName(), _faker.Name.FullName()),
|
||||
new MediaContributorRoleDto(_faker.Commerce.ProductAdjective(), _faker.Commerce.Department()))],
|
||||
new MediaContributorRoleDto(_faker.Commerce.ProductAdjective(), _faker.PickRandom<MediaContributorRoleCategory>()))],
|
||||
[new BookRatingDto(_faker.Random.Decimal(1m, 5m), 5m, BookRatingSource.Goodreads, _faker.Random.Int(1, 1000))],
|
||||
metadataStatus ?? _faker.PickRandom<MetadataStatus>(),
|
||||
_faker.Date.Recent().ToUniversalTime(),
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaContributor"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaContributorFixture
|
||||
{
|
||||
private readonly MediaContributorIdFixture _mediaContributorIdFixture = new();
|
||||
private readonly MediaContributorNameFixture _mediaContributorNameFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaContributor"/> domain aggregate.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the contributor.</param>
|
||||
/// <param name="name">Optional. The name of the contributor.</param>
|
||||
/// <param name="biography">Optional. The biography of the contributor.</param>
|
||||
/// <param name="dateOfBirth">Optional. The date of birth of the contributor.</param>
|
||||
/// <param name="dateOfDeath">Optional. The date of death of the contributor.</param>
|
||||
/// <returns>The created <see cref="MediaContributor"/> domain aggregate.</returns>
|
||||
public MediaContributor Create(
|
||||
MediaContributorId? id = null,
|
||||
MediaContributorName? name = null,
|
||||
Optional<string>? biography = null,
|
||||
Optional<DateOnly>? dateOfBirth = null,
|
||||
Optional<DateOnly>? dateOfDeath = null)
|
||||
{
|
||||
Result<MediaContributor> result = MediaContributor.Create(
|
||||
id ?? _mediaContributorIdFixture.Create(),
|
||||
name ?? _mediaContributorNameFixture.Create(),
|
||||
biography ?? Optional<string>.None(),
|
||||
dateOfBirth ?? Optional<DateOnly>.None(),
|
||||
dateOfDeath ?? Optional<DateOnly>.None());
|
||||
|
||||
if (result.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create MediaContributor: " + string.Join(", ", result.Errors));
|
||||
return result.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MediaContributor"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaContributor"/> instances.</returns>
|
||||
public List<MediaContributor> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
@@ -22,11 +23,11 @@ public class MediaContributorRoleFixture
|
||||
/// <param name="name">Optional. The name of the role. If not provided, a random name is generated.</param>
|
||||
/// <param name="category">Optional. The category of the role. If not provided, a random category is generated.</param>
|
||||
/// <returns>The created <see cref="MediaContributorRole"/>.</returns>
|
||||
public MediaContributorRole Create(string? name = null, string? category = null)
|
||||
public MediaContributorRole Create(string? name = null, MediaContributorRoleCategory? category = null)
|
||||
{
|
||||
return MediaContributorRole.Create(
|
||||
name ?? _faker.Lorem.Word(),
|
||||
category ?? _faker.Commerce.Department());
|
||||
category ?? _faker.PickRandom<MediaContributorRoleCategory>()).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user