mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 22:11:10 +00:00
Uses contributor references on the book page
This commit is contained in:
1 parent
dab6bac9a7
commit
ad072eeffc
28 files changed
+217
-199
No files matched your search
-47
@@ -1,47 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Nemera.Presentation.Web.Common.DTO.MediaContributors;
|
||||
using Nemera.Presentation.Web.Common.Enums.MediaContributors;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Nemera.Presentation.Web.Fixtures.Common.DTO.MediaContributors;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaContributorDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaContributorDtoFixture
|
||||
{
|
||||
private readonly MediaContributorNameDtoFixture _mediaContributorNameDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MediaContributorDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <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="role">Optional. The canonical role of the contributor.</param>
|
||||
/// <returns>A configured <see cref="MediaContributorDto"/> instance.</returns>
|
||||
public MediaContributorDto Create(
|
||||
string? displayName = null,
|
||||
string? legalName = null,
|
||||
MediaContributorRole? role = null)
|
||||
{
|
||||
return new MediaContributorDto
|
||||
{
|
||||
Name = _mediaContributorNameDtoFixture.Create(displayName, legalName),
|
||||
Role = role ?? MediaContributorRole.Author
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MediaContributorDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaContributorDto"/> instances.</returns>
|
||||
public List<MediaContributorDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Nemera.Presentation.Web.Common.DTO.MediaContributors;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Nemera.Presentation.Web.Fixtures.Common.DTO.MediaContributors;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaContributorNameDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaContributorNameDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MediaContributorNameDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <returns>A configured <see cref="MediaContributorNameDto"/> instance.</returns>
|
||||
public MediaContributorNameDto Create(
|
||||
string? displayName = null,
|
||||
string? legalName = null)
|
||||
{
|
||||
return new MediaContributorNameDto
|
||||
{
|
||||
DisplayName = displayName ?? _faker.Name.FullName(),
|
||||
LegalName = legalName ?? _faker.Name.FullName()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MediaContributorNameDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaContributorNameDto"/> instances.</returns>
|
||||
public List<MediaContributorNameDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -23,7 +23,7 @@ public class BookDetailsDtoFixture
|
||||
private readonly Faker _faker = new();
|
||||
private readonly WrittenContentMetadataDtoFixture _writtenContentMetadataDtoFixture = new();
|
||||
private readonly IsbnDtoFixture _isbnDtoFixture = new();
|
||||
private readonly MediaContributorDtoFixture _mediaContributorDtoFixture = new();
|
||||
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
|
||||
private readonly BookRatingDtoFixture _bookRatingDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -61,7 +61,7 @@ public class BookDetailsDtoFixture
|
||||
BarnesAndNobleId = _faker.Random.String2(10, "0123456789"),
|
||||
AppleBooksId = $"id{_faker.Random.Number(1, 999999)}",
|
||||
ISBNs = [.. _isbnDtoFixture.CreateMany(_faker.Random.Number(1, 3))],
|
||||
Contributors = [.. _mediaContributorDtoFixture.CreateMany(_faker.Random.Number(1, 3))],
|
||||
Contributors = [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Number(1, 3))],
|
||||
Ratings = [.. _bookRatingDtoFixture.CreateMany(_faker.Random.Number(1, 3))],
|
||||
MetadataStatus = _faker.Random.String2(_faker.Random.Number(1, 20)),
|
||||
LastMetadataUpdateUtc = _faker.Date.Recent(),
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ public class UpdateBookRequestFixture
|
||||
private readonly WrittenContentMetadataDtoFixture _writtenContentMetadataDtoFixture = new();
|
||||
private readonly BookSeriesDtoFixture _bookSeriesDtoFixture = new();
|
||||
private readonly IsbnDtoFixture _isbnDtoFixture = new();
|
||||
private readonly MediaContributorDtoFixture _mediaContributorDtoFixture = new();
|
||||
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
|
||||
private readonly BookRatingDtoFixture _bookRatingDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -91,7 +91,7 @@ public class UpdateBookRequestFixture
|
||||
BarnesAndNobleId: includeBarnesAndNobleId ? _faker.Random.String2(10, "0123456789") : null,
|
||||
AppleBooksId: includeAppleBooksId ? $"id{_faker.Random.Number(1, 999999)}" : null,
|
||||
ISBNs: includeIsbns ? [.. _isbnDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null,
|
||||
Contributors: includeContributors ? [.. _mediaContributorDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null,
|
||||
Contributors: includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null,
|
||||
Ratings: includeRatings ? [.. _bookRatingDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user