mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 12:11:10 +00:00
Renames project paths from Lumina to Nemera
This commit is contained in:
1 parent
ce6fddb4c9
commit
0f659a4877
6450 files changed
No files matched your search
+107
@@ -0,0 +1,107 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.MediaContributorBoundedContext.MediaContributorAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Book"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly WrittenContentMetadataFixture _writtenContentMetadataFixture = new();
|
||||
private readonly IsbnFixture _isbnFixture = new();
|
||||
private readonly BookRatingFixture _bookRatingFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="Book"/> domain aggregate.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library this book belongs to.</param>
|
||||
/// <param name="path">Optional. The file system path of 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>
|
||||
/// <param name="series">Optional. The series the book is part of.</param>
|
||||
/// <param name="asin">Optional. The ASIN of the book.</param>
|
||||
/// <param name="goodreadsId">Optional. The Goodreads Id of the book.</param>
|
||||
/// <param name="lccn">Optional. The LCCN of the book.</param>
|
||||
/// <param name="oclcNumber">Optional. The OCLC number of the book.</param>
|
||||
/// <param name="openLibraryId">Optional. The Open Library Id of the book.</param>
|
||||
/// <param name="libraryThingId">Optional. The LibraryThing Id of the book.</param>
|
||||
/// <param name="googleBooksId">Optional. The Google Books Id of the book.</param>
|
||||
/// <param name="barnesAndNobleId">Optional. The Barnes and Noble Id of the book.</param>
|
||||
/// <param name="appleBooksId">Optional. The Apple Books Id of the book.</param>
|
||||
/// <param name="isbns">Optional. The ISBNs of the book.</param>
|
||||
/// <param name="contributors">Optional. The media contributors of the book.</param>
|
||||
/// <param name="ratings">Optional. The ratings of the book.</param>
|
||||
/// <returns>The created <see cref="Book"/> domain aggregate.</returns>
|
||||
public Book Create(
|
||||
Guid? libraryId = null,
|
||||
string? path = null,
|
||||
WrittenContentMetadata? metadata = null,
|
||||
BookFormat? format = null,
|
||||
string? edition = null,
|
||||
float? volumeNumber = null,
|
||||
BookSeries? series = null,
|
||||
string? asin = null,
|
||||
string? goodreadsId = null,
|
||||
string? lccn = null,
|
||||
string? oclcNumber = null,
|
||||
string? openLibraryId = null,
|
||||
string? libraryThingId = null,
|
||||
string? googleBooksId = null,
|
||||
string? barnesAndNobleId = null,
|
||||
string? appleBooksId = null,
|
||||
List<Isbn>? isbns = null,
|
||||
List<BookMediaContributor>? contributors = null,
|
||||
List<BookRating>? ratings = null)
|
||||
{
|
||||
return Book.Create(
|
||||
libraryId is null ? LibraryId.Create(Guid.NewGuid()) : LibraryId.Create(libraryId.Value),
|
||||
path ?? _faker.System.FilePath(),
|
||||
metadata ?? _writtenContentMetadataFixture.Create(),
|
||||
format ?? _faker.PickRandom<BookFormat>(),
|
||||
edition is null ? Optional<string>.Some(_faker.Commerce.ProductName()) : Optional<string>.Some(edition),
|
||||
volumeNumber is null ? Optional<float>.None() : Optional<float>.Some(volumeNumber.Value),
|
||||
series is null ? Optional<BookSeries>.None() : Optional<BookSeries>.Some(series),
|
||||
asin is null ? Optional<string>.Some(_faker.Random.String2(10)) : Optional<string>.Some(asin),
|
||||
goodreadsId is null ? Optional<string>.Some(_faker.Random.Number(100000, 500000).ToString()) : Optional<string>.Some(goodreadsId),
|
||||
lccn is null ? Optional<string>.Some(_faker.Random.String2(_faker.Random.Number(8, 10))) : Optional<string>.Some(lccn),
|
||||
oclcNumber is null ? Optional<string>.Some($"ocm{_faker.Random.String2(8, "0123456789")}") : Optional<string>.Some(oclcNumber),
|
||||
openLibraryId is null ? Optional<string>.Some($"OL{_faker.Random.Number(100000, 999999)}{_faker.Random.ArrayElement(['A', 'M', 'W'])}") : Optional<string>.Some(openLibraryId),
|
||||
libraryThingId is null ? Optional<string>.Some(_faker.Random.String2(_faker.Random.Number(1, 50))) : Optional<string>.Some(libraryThingId),
|
||||
googleBooksId is null ? Optional<string>.Some(_faker.Random.String2(12)) : Optional<string>.Some(googleBooksId),
|
||||
barnesAndNobleId is null ? Optional<string>.Some(_faker.Random.String2(10, "0123456789")) : Optional<string>.Some(barnesAndNobleId),
|
||||
appleBooksId is null ? Optional<string>.Some($"id{_faker.Random.Number(1, 999999)}") : Optional<string>.Some(appleBooksId),
|
||||
isbns ?? [.. Enumerable.Range(0, _faker.Random.Number(1, 4)).Select(_ => _isbnFixture.Create())],
|
||||
contributors ?? [.. Enumerable.Range(0, _faker.Random.Number(1, 4)).Select(_ => BookMediaContributor.Create(MediaContributorId.CreateUnique(), MediaContributorRole.Author).Value)],
|
||||
ratings ?? [.. Enumerable.Range(0, _faker.Random.Number(1, 4)).Select(_ => _bookRatingFixture.Create())]
|
||||
).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="Book"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="Book"/> instances.</returns>
|
||||
public List<Book> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookSeries"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookSeriesFixture
|
||||
{
|
||||
private readonly BookSeriesIdFixture _bookSeriesIdFixture = new();
|
||||
private readonly WrittenContentMetadataFixture _writtenContentMetadataFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookSeries"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The unique identifier of the book series.</param>
|
||||
/// <param name="isComplete">Whether the book series is complete.</param>
|
||||
/// <returns>The created <see cref="BookSeries"/>.</returns>
|
||||
public BookSeries Create(
|
||||
Guid? id = null,
|
||||
bool isComplete = false)
|
||||
{
|
||||
return BookSeries.Create(
|
||||
id is null ? BookSeriesId.CreateUnique() : _bookSeriesIdFixture.Create(id.Value),
|
||||
_writtenContentMetadataFixture.Create(),
|
||||
isComplete,
|
||||
[]).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="BookSeries"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookSeries"/> instances.</returns>
|
||||
public List<BookSeries> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="BookId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="BookId"/>.</returns>
|
||||
public BookId Create(Guid? value = null)
|
||||
{
|
||||
return value is null ? BookId.CreateUnique() : BookId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="BookId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookId"/> instances.</returns>
|
||||
public List<BookId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using AutoFixture;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookRating"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookRatingFixture
|
||||
{
|
||||
private readonly Fixture _fixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookRating"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The rating value.</param>
|
||||
/// <param name="maxValue">Optional. The maximum possible rating value.</param>
|
||||
/// <param name="source">Optional. The rating source. If not provided, a random source is selected.</param>
|
||||
/// <param name="voteCount">Optional. The number of votes. If not provided, a random vote count is selected.</param>
|
||||
/// <returns>The created <see cref="BookRating"/>.</returns>
|
||||
public BookRating Create(
|
||||
decimal? value = null,
|
||||
decimal? maxValue = null,
|
||||
Optional<BookRatingSource>? source = null,
|
||||
Optional<int>? voteCount = null)
|
||||
{
|
||||
maxValue ??= Random.Shared.Next(5, 10);
|
||||
value ??= Random.Shared.Next(1, (int)maxValue.Value);
|
||||
source ??= Optional<BookRatingSource>.Some(_fixture.Create<BookRatingSource>());
|
||||
voteCount ??= Optional<int>.Some(Random.Shared.Next(1, 1000));
|
||||
|
||||
return BookRating.Create(value.Value, maxValue.Value, source.Value, voteCount.Value).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="BookRating"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookRating"/> instances.</returns>
|
||||
public List<BookRating> CreateMany(int count = 3)
|
||||
{
|
||||
List<BookRating> result = [];
|
||||
for (int i = 0; i < count; i++)
|
||||
result.Add(Create());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookSeriesId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookSeriesIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookSeriesId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="BookSeriesId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="BookSeriesId"/>.</returns>
|
||||
public BookSeriesId Create(Guid? value = null)
|
||||
{
|
||||
return value is null ? BookSeriesId.CreateUnique() : BookSeriesId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="BookSeriesId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookSeriesId"/> instances.</returns>
|
||||
public List<BookSeriesId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Isbn"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class IsbnFixture
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Creates a valid <see cref="Isbn"/> with a random or explicitly requested format.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The ISBN value to use. If not provided, a random valid value is generated for the requested format.</param>
|
||||
/// <param name="format">Optional. The requested <see cref="IsbnFormat"/>. If not provided, a random format is selected.</param>
|
||||
/// <returns>The created <see cref="Isbn"/>.</returns>
|
||||
public Isbn Create(string? value = null, IsbnFormat? format = null)
|
||||
{
|
||||
if (value is not null)
|
||||
{
|
||||
IsbnFormat targetFormat = format ?? IsbnFormat.Isbn10;
|
||||
Result<Isbn> result = Isbn.Create(value, targetFormat);
|
||||
if (result.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create Isbn: " + string.Join(", ", result.Errors));
|
||||
return result.Value;
|
||||
}
|
||||
|
||||
IsbnFormat requestedFormat = format ?? (Random.Shared.Next(2) == 0 ? IsbnFormat.Isbn10 : IsbnFormat.Isbn13);
|
||||
string isbn = requestedFormat == IsbnFormat.Isbn10 ? GenerateValidIsbn10() : GenerateValidIsbn13();
|
||||
return Isbn.Create(isbn, requestedFormat).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="Isbn"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="Isbn"/> instances.</returns>
|
||||
public List<Isbn> CreateMany(int count = 3)
|
||||
{
|
||||
List<Isbn> result = [];
|
||||
for (int i = 0; i < count; i++)
|
||||
result.Add(Create());
|
||||
return result;
|
||||
}
|
||||
|
||||
private string GenerateValidIsbn10()
|
||||
{
|
||||
int[] digits = new int[9];
|
||||
for (int i = 0; i < 9; i++)
|
||||
digits[i] = Random.Shared.Next(0, 10);
|
||||
|
||||
int sum = 0;
|
||||
for (int i = 0; i < 9; i++)
|
||||
sum += (10 - i) * digits[i];
|
||||
|
||||
int checkDigit = (11 - sum % 11) % 11;
|
||||
string checkChar = checkDigit == 10 ? "X" : checkDigit.ToString();
|
||||
|
||||
return $"{digits[0]}-{digits[1]}{digits[2]}-{digits[3]}{digits[4]}{digits[5]}{digits[6]}{digits[7]}{digits[8]}-{checkChar}";
|
||||
}
|
||||
|
||||
private string GenerateValidIsbn13()
|
||||
{
|
||||
string prefix = Random.Shared.Next(2) == 0 ? "978" : "979";
|
||||
string group = Random.Shared.Next(0, 99999).ToString().PadLeft(5, '0');
|
||||
string publisher = Random.Shared.Next(0, 999999).ToString().PadLeft(6, '0');
|
||||
string title = Random.Shared.Next(0, 99).ToString().PadLeft(2, '0');
|
||||
|
||||
string isbn = $"{prefix}{group[..1]}{publisher}{title}";
|
||||
int sum = 0;
|
||||
for (int i = 0; i < 12; i++)
|
||||
sum += (i % 2 == 0 ? 1 : 3) * int.Parse(isbn[i].ToString());
|
||||
|
||||
int checkDigit = (10 - sum % 10) % 10;
|
||||
|
||||
return $"{prefix}-{group[..1]}-{publisher}-{title}-{checkDigit}";
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Common.ValueObjects.Metadata;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="WrittenContentMetadata"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class WrittenContentMetadataFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly GenreFixture _genreFixture = new();
|
||||
private readonly TagFixture _tagFixture = new();
|
||||
private readonly ReleaseInfoFixture _releaseInfoFixture = new();
|
||||
private readonly LanguageInfoFixture _languageInfoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="WrittenContentMetadata"/>.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional. The title of the written content.</param>
|
||||
/// <param name="originalTitle">Optional. The original title of the written content.</param>
|
||||
/// <param name="description">Optional. The description of the written content.</param>
|
||||
/// <param name="releaseInfo">Optional. The release information of the written content.</param>
|
||||
/// <param name="genres">Optional. The genres of the written content.</param>
|
||||
/// <param name="tags">Optional. The tags associated with the written content.</param>
|
||||
/// <param name="language">Optional. The language of the written content.</param>
|
||||
/// <param name="originalLanguage">Optional. The original language of the written content.</param>
|
||||
/// <param name="publisher">Optional. The publisher of the written content.</param>
|
||||
/// <param name="pageCount">Optional. The number of pages in the written content.</param>
|
||||
/// <returns>The created <see cref="WrittenContentMetadata"/>.</returns>
|
||||
public WrittenContentMetadata Create(
|
||||
string? title = null,
|
||||
Optional<string>? originalTitle = null,
|
||||
Optional<string>? description = null,
|
||||
ReleaseInfo? releaseInfo = null,
|
||||
List<Genre>? genres = null,
|
||||
List<Tag>? tags = null,
|
||||
Optional<LanguageInfo>? language = null,
|
||||
Optional<LanguageInfo>? originalLanguage = null,
|
||||
Optional<string>? publisher = null,
|
||||
Optional<int>? pageCount = null)
|
||||
{
|
||||
return WrittenContentMetadata.Create(
|
||||
title ?? _faker.Commerce.ProductName(),
|
||||
originalTitle ?? Optional<string>.None(),
|
||||
description ?? Optional<string>.Some(_faker.Lorem.Sentence()),
|
||||
releaseInfo ?? _releaseInfoFixture.Create(),
|
||||
genres ?? [_genreFixture.Create(), _genreFixture.Create()],
|
||||
tags ?? [_tagFixture.Create(), _tagFixture.Create()],
|
||||
language ?? Optional<LanguageInfo>.Some(_languageInfoFixture.Create()),
|
||||
originalLanguage ?? Optional<LanguageInfo>.None(),
|
||||
publisher ?? Optional<string>.Some(_faker.Company.CompanyName()),
|
||||
pageCount ?? Optional<int>.Some(_faker.Random.Int(1, 1000))).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="WrittenContentMetadata"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="WrittenContentMetadata"/> instances.</returns>
|
||||
public List<WrittenContentMetadata> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the library Id.</param>
|
||||
/// <returns>The created <see cref="LibraryId"/>.</returns>
|
||||
public LibraryId Create(Guid? value = null)
|
||||
{
|
||||
return LibraryId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryId"/> instances.</returns>
|
||||
public List<LibraryId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user