Renames project paths from Lumina to Nemera

This commit is contained in:
BinaryAlley committed 2026-11-27 15:34:43 +02:00
1 parent ce6fddb4c9
commit 0f659a4877
6450 files changed

No files matched your search

@@ -0,0 +1,116 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
/// <summary>
/// Fixture class for the <see cref="AddAlbumRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddAlbumRequestFixture
{
private readonly Faker _faker = new();
private readonly MusicAlbumMetadataDtoFixture _musicAlbumMetadataDtoFixture = new();
private readonly AddTrackRequestFixture _addTrackRequestFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
/// <summary>
/// Creates a random valid request to add an album.
/// </summary>
/// <param name="metadata">Optional. The album metadata of the album.</param>
/// <param name="mediaFormat">Optional. The physical or digital medium of the album.</param>
/// <param name="packaging">Optional. The outermost physical packaging of the album.</param>
/// <param name="barcode">Optional. The barcode of the album.</param>
/// <param name="catalogNumber">Optional. The catalog number of the album.</param>
/// <param name="label">Optional. The name of the label that issued the album.</param>
/// <param name="asin">Optional. The ASIN of the album.</param>
/// <param name="musicBrainzReleaseId">Optional. The MusicBrainz identifier of the release.</param>
/// <param name="musicBrainzReleaseGroupId">Optional. The MusicBrainz identifier of the release group.</param>
/// <param name="musicBrainzReleaseArtistId">Optional. The MusicBrainz identifier of the release artist.</param>
/// <param name="contributors">Optional. The media contributors that performed on the album.</param>
/// <param name="ratings">Optional. The ratings of the album.</param>
/// <param name="tracks">Optional. The tracks of the album.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTracks">Whether the tracks list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaFormat">Whether the media format should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePackaging">Whether the packaging should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBarcode">Whether the barcode should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeCatalogNumbers">Whether the catalog number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLabel">Whether the label should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseId">Whether the MusicBrainz release Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseGroupId">Whether the MusicBrainz release group Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseArtistId">Whether the MusicBrainz release artist Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created request to add an album.</returns>
public AddAlbumRequest Create(
MusicAlbumMetadataDto? metadata = null,
MusicMediaFormat? mediaFormat = null,
MusicReleasePackaging? packaging = null,
string? barcode = null,
List<string>? catalogNumbers = null,
string? label = null,
string? asin = null,
Guid? musicBrainzReleaseId = null,
Guid? musicBrainzReleaseGroupId = null,
Guid? musicBrainzReleaseArtistId = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
List<AddTrackRequest>? tracks = null,
bool includeMetadata = true,
bool includeContributors = true,
bool includeRatings = true,
bool includeTracks = true,
bool includeMediaFormat = true,
bool includePackaging = true,
bool includeBarcode = true,
bool includeCatalogNumbers = true,
bool includeLabel = true,
bool includeAsin = true,
bool includeMusicBrainzReleaseId = true,
bool includeMusicBrainzReleaseGroupId = true,
bool includeMusicBrainzReleaseArtistId = true)
{
return new AddAlbumRequest(
includeMetadata ? (metadata ?? _musicAlbumMetadataDtoFixture.Create()) : null,
includeMediaFormat ? (mediaFormat ?? _faker.PickRandom<MusicMediaFormat>()) : null,
includePackaging ? (packaging ?? _faker.PickRandom<MusicReleasePackaging>()) : null,
includeBarcode ? (barcode ?? _faker.Random.String2(13, "0123456789")) : null,
includeCatalogNumbers ? (catalogNumbers ?? [_faker.Random.AlphaNumeric(10)]) : null,
includeLabel ? (label ?? _faker.Company.CompanyName()) : null,
includeAsin ? (asin ?? _faker.Random.AlphaNumeric(10)) : null,
includeMusicBrainzReleaseId ? (musicBrainzReleaseId ?? _faker.Random.Guid()) : null,
includeMusicBrainzReleaseGroupId ? (musicBrainzReleaseGroupId ?? _faker.Random.Guid()) : null,
includeMusicBrainzReleaseArtistId ? (musicBrainzReleaseArtistId ?? _faker.Random.Guid()) : null,
includeContributors ? (contributors ?? _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeRatings ? (ratings ?? _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeTracks ? (tracks ?? _addTrackRequestFixture.CreateMany(_faker.Random.Int(1, 3))) : null);
}
/// <summary>
/// Creates a list of <see cref="AddAlbumRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<AddAlbumRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,47 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
/// <summary>
/// Fixture class for the <see cref="GetAlbumTracksLiteRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetAlbumTracksLiteRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a <see cref="GetAlbumTracksLiteRequest"/> with default or random values.
/// </summary>
/// <param name="currentPage">Optional. The page of results to retrieve.</param>
/// <param name="perPage">Optional. The maximum number of tracks to retrieve per page.</param>
/// <param name="includeCurrentPage">Whether the current page should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePerPage">Whether the per page count should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetAlbumTracksLiteRequest"/>.</returns>
public GetAlbumTracksLiteRequest Create(
int? currentPage = null,
int? perPage = null,
bool includeCurrentPage = true,
bool includePerPage = true)
{
return new GetAlbumTracksLiteRequest(
CurrentPage: includeCurrentPage ? (currentPage ?? _faker.Random.Number(1, 100)) : null,
PerPage: includePerPage ? (perPage ?? _faker.Random.Number(1, 200)) : null);
}
/// <summary>
/// Creates a list of <see cref="GetAlbumTracksLiteRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetAlbumTracksLiteRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,108 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
/// <summary>
/// Fixture class for the <see cref="UpdateAlbumRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateAlbumRequestFixture
{
private readonly Faker _faker = new();
private readonly MusicAlbumMetadataDtoFixture _musicAlbumMetadataDtoFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
/// <summary>
/// Creates a random valid request to update an album.
/// </summary>
/// <param name="metadata">Optional. The album metadata of the album.</param>
/// <param name="mediaFormat">Optional. The physical or digital medium of the album.</param>
/// <param name="packaging">Optional. The outermost physical packaging of the album.</param>
/// <param name="barcode">Optional. The barcode of the album.</param>
/// <param name="catalogNumber">Optional. The catalog number of the album.</param>
/// <param name="label">Optional. The name of the label that issued the album.</param>
/// <param name="asin">Optional. The ASIN of the album.</param>
/// <param name="musicBrainzReleaseId">Optional. The MusicBrainz identifier of the release.</param>
/// <param name="musicBrainzReleaseGroupId">Optional. The MusicBrainz identifier of the release group.</param>
/// <param name="musicBrainzReleaseArtistId">Optional. The MusicBrainz identifier of the release artist.</param>
/// <param name="contributors">Optional. The media contributors that performed on the album.</param>
/// <param name="ratings">Optional. The ratings of the album.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaFormat">Whether the media format should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePackaging">Whether the packaging should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBarcode">Whether the barcode should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeCatalogNumbers">Whether the catalog number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLabel">Whether the label should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseId">Whether the MusicBrainz release Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseGroupId">Whether the MusicBrainz release group Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseArtistId">Whether the MusicBrainz release artist Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created request to update an album.</returns>
public UpdateAlbumRequest Create(
MusicAlbumMetadataDto? metadata = null,
MusicMediaFormat? mediaFormat = null,
MusicReleasePackaging? packaging = null,
string? barcode = null,
List<string>? catalogNumbers = null,
string? label = null,
string? asin = null,
Guid? musicBrainzReleaseId = null,
Guid? musicBrainzReleaseGroupId = null,
Guid? musicBrainzReleaseArtistId = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
bool includeMetadata = true,
bool includeContributors = true,
bool includeRatings = true,
bool includeMediaFormat = true,
bool includePackaging = true,
bool includeBarcode = true,
bool includeCatalogNumbers = true,
bool includeLabel = true,
bool includeAsin = true,
bool includeMusicBrainzReleaseId = true,
bool includeMusicBrainzReleaseGroupId = true,
bool includeMusicBrainzReleaseArtistId = true)
{
return new UpdateAlbumRequest(
includeMetadata ? (metadata ?? _musicAlbumMetadataDtoFixture.Create()) : null,
includeMediaFormat ? (mediaFormat ?? _faker.PickRandom<MusicMediaFormat>()) : null,
includePackaging ? (packaging ?? _faker.PickRandom<MusicReleasePackaging>()) : null,
includeBarcode ? (barcode ?? _faker.Random.String2(13, "0123456789")) : null,
includeCatalogNumbers ? (catalogNumbers ?? [_faker.Random.AlphaNumeric(10)]) : null,
includeLabel ? (label ?? _faker.Company.CompanyName()) : null,
includeAsin ? (asin ?? _faker.Random.AlphaNumeric(10)) : null,
includeMusicBrainzReleaseId ? (musicBrainzReleaseId ?? _faker.Random.Guid()) : null,
includeMusicBrainzReleaseGroupId ? (musicBrainzReleaseGroupId ?? _faker.Random.Guid()) : null,
includeMusicBrainzReleaseArtistId ? (musicBrainzReleaseArtistId ?? _faker.Random.Guid()) : null,
includeContributors ? (contributors ?? _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeRatings ? (ratings ?? _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null);
}
/// <summary>
/// Creates a list of <see cref="UpdateAlbumRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateAlbumRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,90 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
/// <summary>
/// Fixture class for the <see cref="AddArtistRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddArtistRequestFixture
{
private readonly Faker _faker = new();
private readonly MusicArtistMetadataDtoFixture _musicArtistMetadataDtoFixture = new();
private readonly AddAlbumRequestFixture _addAlbumRequestFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
/// <summary>
/// Creates a random valid request to add an artist.
/// </summary>
/// <param name="metadata">Optional. The metadata of the artist.</param>
/// <param name="website">Optional. The website of the artist.</param>
/// <param name="musicBrainzArtistId">Optional. The MusicBrainz identifier of the artist.</param>
/// <param name="ipis">Optional. The IPI codes of the artist.</param>
/// <param name="isnis">Optional. The ISNI codes of the artist.</param>
/// <param name="contributors">Optional. The media contributors that make up the artist.</param>
/// <param name="ratings">Optional. The ratings of the artist.</param>
/// <param name="albums">Optional. The albums of the artist.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeWebsite">Whether the website should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzArtistId">Whether the MusicBrainz artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIpis">Whether the IPI codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsnis">Whether the ISNI codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbums">Whether the albums list should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created request to add an artist.</returns>
public AddArtistRequest Create(
MusicArtistMetadataDto? metadata = null,
string? website = null,
Guid? musicBrainzArtistId = null,
List<string>? ipis = null,
List<string>? isnis = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
List<AddAlbumRequest>? albums = null,
bool includeMetadata = true,
bool includeWebsite = true,
bool includeMusicBrainzArtistId = true,
bool includeIpis = true,
bool includeIsnis = true,
bool includeContributors = true,
bool includeRatings = true,
bool includeAlbums = true)
{
return new AddArtistRequest(
includeMetadata ? (metadata ?? _musicArtistMetadataDtoFixture.Create()) : null,
includeWebsite ? (website ?? _faker.Internet.Url()) : null,
includeMusicBrainzArtistId ? (musicBrainzArtistId ?? _faker.Random.Guid()) : null,
includeIpis ? (ipis ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.AlphaNumeric(9))]) : null,
includeIsnis ? (isnis ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.AlphaNumeric(16))]) : null,
includeContributors ? (contributors ?? _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeRatings ? (ratings ?? _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeAlbums ? (albums ?? _addAlbumRequestFixture.CreateMany(_faker.Random.Int(1, 3))) : null);
}
/// <summary>
/// Creates a list of <see cref="AddArtistRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<AddArtistRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,47 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
/// <summary>
/// Fixture class for the <see cref="GetArtistAlbumsLiteRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetArtistAlbumsLiteRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid request to get the lightweight read models of the albums of an artist.
/// </summary>
/// <param name="currentPage">Optional. The page of results to retrieve.</param>
/// <param name="perPage">Optional. The maximum number of albums to retrieve per page.</param>
/// <param name="includeCurrentPage">Whether the current page should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePerPage">Whether the per page count should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created request to get the lightweight read models of the albums of an artist.</returns>
public GetArtistAlbumsLiteRequest Create(
int? currentPage = null,
int? perPage = null,
bool includeCurrentPage = true,
bool includePerPage = true)
{
return new GetArtistAlbumsLiteRequest(
includeCurrentPage ? (currentPage ?? _faker.Random.Number(1, 100)) : null,
includePerPage ? (perPage ?? _faker.Random.Number(1, 200)) : null);
}
/// <summary>
/// Creates a list of <see cref="GetArtistAlbumsLiteRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetArtistAlbumsLiteRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,82 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
using Lumina.Domain.SharedKernel.Common.Enums.Common;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
/// <summary>
/// Fixture class for the <see cref="GetArtistsLiteRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetArtistsLiteRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid request to get the lightweight read models of the artists of a media library.
/// </summary>
/// <param name="currentPage">Optional. The page of results to retrieve.</param>
/// <param name="perPage">Optional. The maximum number of artists to retrieve per page.</param>
/// <param name="searchTerm">Optional. The search term used to filter the artists by name.</param>
/// <param name="filterAlphaKey">Optional. The alpha key used to filter the results by the first character of their name, for the alpha picker.</param>
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Optional. Whether the leading "The " prefix of a name should be ignored when computing the alpha key, or not.</param>
/// <param name="sortBy">Optional. The name of the field by which to sort the results.</param>
/// <param name="sortOrder">Optional. The direction in which to sort the results.</param>
/// <param name="includeCurrentPage">Whether the current page should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePerPage">Whether the per page count should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSearchTerm">Whether the search term should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFilterAlphaKey">Whether the filter alpha key should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSortBy">Whether the sort field should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSortOrder">Whether the sort order should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created request to get the lightweight read models of the artists of a media library.</returns>
public GetArtistsLiteRequest Create(
int? currentPage = null,
int? perPage = null,
string? searchTerm = null,
string? filterAlphaKey = null,
bool shouldIgnoreThePrefixForAlphaPicker = false,
string? sortBy = null,
SortOrder? sortOrder = null,
bool includeCurrentPage = true,
bool includePerPage = true,
bool includeSearchTerm = true,
bool includeFilterAlphaKey = true,
bool includeSortBy = true,
bool includeSortOrder = true)
{
return new GetArtistsLiteRequest(
includeCurrentPage ? (currentPage ?? _faker.Random.Number(1, 100)) : null,
includePerPage ? (perPage ?? _faker.Random.Number(1, 200)) : null,
includeSearchTerm ? (searchTerm ?? _faker.Name.FullName()) : null,
includeFilterAlphaKey ? (filterAlphaKey ?? CreateFilterAlphaKey()) : null,
shouldIgnoreThePrefixForAlphaPicker,
includeSortBy ? (sortBy ?? _faker.Lorem.Word()) : null,
includeSortOrder ? (sortOrder ?? _faker.PickRandom<SortOrder>()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetArtistsLiteRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetArtistsLiteRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Creates a random valid alpha key: a single ASCII letter, "#" for names starting with a digit, or "*" for any other first character.
/// </summary>
/// <returns>The created alpha key.</returns>
private string CreateFilterAlphaKey()
{
return _faker.Random.Bool()
? _faker.Random.Char('A', 'Z').ToString()
: _faker.Random.ListItem(new[] { "#", "*" });
}
}
@@ -0,0 +1,52 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
/// <summary>
/// Fixture class for the <see cref="GetArtistsRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetArtistsRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid request to get the artists of a media library.
/// </summary>
/// <param name="currentPage">Optional. The page of results to retrieve.</param>
/// <param name="perPage">Optional. The maximum number of artists to retrieve per page.</param>
/// <param name="searchTerm">Optional. The search term used to filter the artists by name.</param>
/// <param name="includeCurrentPage">Whether the current page should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePerPage">Whether the per page count should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSearchTerm">Whether the search term should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created request to get the artists of a media library.</returns>
public GetArtistsRequest Create(
int? currentPage = null,
int? perPage = null,
string? searchTerm = null,
bool includeCurrentPage = true,
bool includePerPage = true,
bool includeSearchTerm = true)
{
return new GetArtistsRequest(
includeCurrentPage ? (currentPage ?? _faker.Random.Number(1, 100)) : null,
includePerPage ? (perPage ?? _faker.Random.Number(1, 200)) : null,
includeSearchTerm ? (searchTerm ?? _faker.Name.FullName()) : null);
}
/// <summary>
/// Creates a list of <see cref="GetArtistsRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetArtistsRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,119 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
/// <summary>
/// Fixture class for the <see cref="UpdateArtistAlbumRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateArtistAlbumRequestFixture
{
private readonly Faker _faker = new();
private readonly MusicAlbumMetadataDtoFixture _musicAlbumMetadataDtoFixture = new();
private readonly UpdateArtistTrackRequestFixture _updateArtistTrackRequestFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
/// <summary>
/// Creates a random valid request to update an album of an artist.
/// </summary>
/// <param name="albumId">Optional. The Id of the album, when the album already exists.</param>
/// <param name="metadata">Optional. The album metadata of the album.</param>
/// <param name="mediaFormat">Optional. The physical or digital medium of the album.</param>
/// <param name="packaging">Optional. The outermost physical packaging of the album.</param>
/// <param name="barcode">Optional. The barcode of the album.</param>
/// <param name="catalogNumber">Optional. The catalog number of the album.</param>
/// <param name="label">Optional. The name of the label that issued the album.</param>
/// <param name="asin">Optional. The ASIN of the album.</param>
/// <param name="musicBrainzReleaseId">Optional. The MusicBrainz identifier of the release.</param>
/// <param name="musicBrainzReleaseGroupId">Optional. The MusicBrainz identifier of the release group.</param>
/// <param name="musicBrainzReleaseArtistId">Optional. The MusicBrainz identifier of the release artist.</param>
/// <param name="contributors">Optional. The media contributors that performed on the album.</param>
/// <param name="ratings">Optional. The ratings of the album.</param>
/// <param name="tracks">Optional. The tracks of the album.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaFormat">Whether the media format should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePackaging">Whether the packaging should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBarcode">Whether the barcode should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeCatalogNumbers">Whether the catalog number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLabel">Whether the label should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseId">Whether the MusicBrainz release Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseGroupId">Whether the MusicBrainz release group Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseArtistId">Whether the MusicBrainz release artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTracks">Whether the tracks list should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created request to update an album of an artist.</returns>
public UpdateArtistAlbumRequest Create(
Guid? albumId = null,
MusicAlbumMetadataDto? metadata = null,
MusicMediaFormat? mediaFormat = null,
MusicReleasePackaging? packaging = null,
string? barcode = null,
List<string>? catalogNumbers = null,
string? label = null,
string? asin = null,
Guid? musicBrainzReleaseId = null,
Guid? musicBrainzReleaseGroupId = null,
Guid? musicBrainzReleaseArtistId = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
List<UpdateArtistTrackRequest>? tracks = null,
bool includeAlbumId = true,
bool includeMetadata = true,
bool includeMediaFormat = true,
bool includePackaging = true,
bool includeBarcode = true,
bool includeCatalogNumbers = true,
bool includeLabel = true,
bool includeAsin = true,
bool includeMusicBrainzReleaseId = true,
bool includeMusicBrainzReleaseGroupId = true,
bool includeMusicBrainzReleaseArtistId = true,
bool includeContributors = true,
bool includeRatings = true,
bool includeTracks = true)
{
return new UpdateArtistAlbumRequest(
includeAlbumId ? (albumId ?? _faker.Random.Guid()) : null,
includeMetadata ? (metadata ?? _musicAlbumMetadataDtoFixture.Create()) : null,
includeMediaFormat ? (mediaFormat ?? _faker.PickRandom<MusicMediaFormat>()) : null,
includePackaging ? (packaging ?? _faker.PickRandom<MusicReleasePackaging>()) : null,
includeBarcode ? (barcode ?? _faker.Random.String2(13, "0123456789")) : null,
includeCatalogNumbers ? (catalogNumbers ?? [_faker.Random.String2(_faker.Random.Number(1, 50))]) : null,
includeLabel ? (label ?? _faker.Company.CompanyName()) : null,
includeAsin ? (asin ?? _faker.Random.AlphaNumeric(10)) : null,
includeMusicBrainzReleaseId ? (musicBrainzReleaseId ?? _faker.Random.Guid()) : null,
includeMusicBrainzReleaseGroupId ? (musicBrainzReleaseGroupId ?? _faker.Random.Guid()) : null,
includeMusicBrainzReleaseArtistId ? (musicBrainzReleaseArtistId ?? _faker.Random.Guid()) : null,
includeContributors ? (contributors ?? _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeRatings ? (ratings ?? _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeTracks ? (tracks ?? _updateArtistTrackRequestFixture.CreateMany(_faker.Random.Int(1, 3))) : null);
}
/// <summary>
/// Creates a list of <see cref="UpdateArtistAlbumRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateArtistAlbumRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,88 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
/// <summary>
/// Fixture class for the <see cref="UpdateArtistRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateArtistRequestFixture
{
private readonly Faker _faker = new();
private readonly MusicArtistMetadataDtoFixture _musicArtistMetadataDtoFixture = new();
private readonly UpdateArtistAlbumRequestFixture _updateArtistAlbumRequestFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
/// <summary>
/// Creates a random valid request to update an artist.
/// </summary>
/// <param name="metadata">Optional. The metadata of the artist.</param>
/// <param name="website">Optional. The website of the artist.</param>
/// <param name="musicBrainzArtistId">Optional. The MusicBrainz identifier of the artist.</param>
/// <param name="ipis">Optional. The IPI codes of the artist.</param>
/// <param name="isnis">Optional. The ISNI codes of the artist.</param>
/// <param name="contributors">Optional. The media contributors that make up the artist.</param>
/// <param name="ratings">Optional. The ratings of the artist.</param>
/// <param name="albums">Optional. The albums of the artist.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeWebsite">Whether the website should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzArtistId">Whether the MusicBrainz artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIpis">Whether the IPI codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsnis">Whether the ISNI codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbums">Whether the albums list should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created request to update an artist.</returns>
public UpdateArtistRequest Create(
MusicArtistMetadataDto? metadata = null,
string? website = null,
Guid? musicBrainzArtistId = null,
List<string>? ipis = null,
List<string>? isnis = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
List<UpdateArtistAlbumRequest>? albums = null,
bool includeMetadata = true,
bool includeWebsite = true,
bool includeMusicBrainzArtistId = true,
bool includeIpis = true,
bool includeIsnis = true,
bool includeContributors = true,
bool includeRatings = true,
bool includeAlbums = true)
{
return new UpdateArtistRequest(
includeMetadata ? (metadata ?? _musicArtistMetadataDtoFixture.Create()) : null,
includeWebsite ? (website ?? _faker.Internet.Url()) : null,
includeMusicBrainzArtistId ? (musicBrainzArtistId ?? _faker.Random.Guid()) : null,
includeIpis ? (ipis ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.AlphaNumeric(9))]) : null,
includeIsnis ? (isnis ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.AlphaNumeric(16))]) : null,
includeContributors ? (contributors ?? _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeRatings ? (ratings ?? _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeAlbums ? (albums ?? _updateArtistAlbumRequestFixture.CreateMany(_faker.Random.Int(1, 3))) : null);
}
/// <summary>
/// Creates a list of <see cref="UpdateArtistRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateArtistRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,129 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.Common;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
/// <summary>
/// Fixture class for the <see cref="UpdateArtistTrackRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateArtistTrackRequestFixture
{
private readonly Faker _faker = new();
private readonly MusicTrackMetadataDtoFixture _musicTrackMetadataDtoFixture = new();
private readonly MusicWorkDtoFixture _musicWorkDtoFixture = new();
private readonly MoodDtoFixture _moodDtoFixture = new();
private readonly IsrcDtoFixture _isrcDtoFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
/// <summary>
/// Creates a random valid request to update a track of an album of an artist.
/// </summary>
/// <param name="trackId">Optional. The Id of the track, when the track already exists.</param>
/// <param name="path">Optional. The file system path of the track.</param>
/// <param name="metadata">Optional. The audio metadata of the track.</param>
/// <param name="trackNumber">Optional. The number of the track on its disc.</param>
/// <param name="discNumber">Optional. The number of the disc the track belongs to.</param>
/// <param name="script">Optional. The script used by the language of the track.</param>
/// <param name="key">Optional. The musical key of the track.</param>
/// <param name="bpm">Optional. The tempo of the track in beats per minute.</param>
/// <param name="work">Optional. The work the track is a recording of.</param>
/// <param name="musicBrainzRecordingId">Optional. The MusicBrainz identifier of the recording.</param>
/// <param name="musicBrainzTrackId">Optional. The MusicBrainz identifier of the track.</param>
/// <param name="moods">Optional. The moods of the track.</param>
/// <param name="isrcs">Optional. The ISRC codes of the track.</param>
/// <param name="contributors">Optional. The media contributors that performed on the track.</param>
/// <param name="ratings">Optional. The ratings of the track.</param>
/// <param name="includeTrackId">Whether the track Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePath">Whether the path should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackNumber">Whether the track number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeDiscNumber">Whether the disc number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeScript">Whether the script should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeKey">Whether the musical key should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBpm">Whether the tempo should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeWork">Whether the work should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzRecordingId">Whether the MusicBrainz recording Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzTrackId">Whether the MusicBrainz track Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMoods">Whether the moods should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsrcs">Whether the ISRC codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings list should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created request to update a track of an album of an artist.</returns>
public UpdateArtistTrackRequest Create(
Guid? trackId = null,
string? path = null,
MusicTrackMetadataDto? metadata = null,
int? trackNumber = null,
int? discNumber = null,
string? script = null,
MusicKey? key = null,
int? bpm = null,
MusicWorkDto? work = null,
Guid? musicBrainzRecordingId = null,
Guid? musicBrainzTrackId = null,
List<MoodDto>? moods = null,
List<IsrcDto>? isrcs = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
bool includeTrackId = true,
bool includePath = true,
bool includeMetadata = true,
bool includeTrackNumber = true,
bool includeDiscNumber = true,
bool includeScript = true,
bool includeKey = true,
bool includeBpm = true,
bool includeWork = true,
bool includeMusicBrainzRecordingId = true,
bool includeMusicBrainzTrackId = true,
bool includeMoods = true,
bool includeIsrcs = true,
bool includeContributors = true,
bool includeRatings = true)
{
return new UpdateArtistTrackRequest(
includeTrackId ? (trackId ?? _faker.Random.Guid()) : null,
includePath ? (path ?? Path.Combine(Path.GetTempPath(), "lumina-tracks", _faker.System.FileName())) : null,
includeMetadata ? (metadata ?? _musicTrackMetadataDtoFixture.Create()) : null,
includeTrackNumber ? (trackNumber ?? _faker.Random.Int(1, 30)) : null,
includeDiscNumber ? (discNumber ?? _faker.Random.Int(1, 3)) : null,
includeScript ? (script ?? _faker.Random.AlphaNumeric(4)) : null,
includeKey ? (key ?? _faker.PickRandom<MusicKey>()) : null,
includeBpm ? (bpm ?? _faker.Random.Int(40, 220)) : null,
includeWork ? (work ?? _musicWorkDtoFixture.Create()) : null,
includeMusicBrainzRecordingId ? (musicBrainzRecordingId ?? _faker.Random.Guid()) : null,
includeMusicBrainzTrackId ? (musicBrainzTrackId ?? _faker.Random.Guid()) : null,
includeMoods ? (moods ?? [.. _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeIsrcs ? (isrcs ?? [.. _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null);
}
/// <summary>
/// Creates a list of <see cref="UpdateArtistTrackRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateArtistTrackRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,124 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.Common;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
/// <summary>
/// Fixture class for the <see cref="AddTrackRequest"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddTrackRequestFixture
{
private readonly Faker _faker = new();
private readonly MusicTrackMetadataDtoFixture _musicTrackMetadataDtoFixture = new();
private readonly MusicWorkDtoFixture _musicWorkDtoFixture = new();
private readonly MoodDtoFixture _moodDtoFixture = new();
private readonly IsrcDtoFixture _isrcDtoFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
/// <summary>
/// Creates a random valid request to add a track.
/// </summary>
/// <param name="path">Optional. The file system path of the track.</param>
/// <param name="metadata">Optional. The audio metadata of the track.</param>
/// <param name="trackNumber">Optional. The number of the track on its disc.</param>
/// <param name="discNumber">Optional. The number of the disc the track belongs to.</param>
/// <param name="script">Optional. The script used by the language of the track.</param>
/// <param name="key">Optional. The musical key of the track.</param>
/// <param name="bpm">Optional. The tempo of the track in beats per minute.</param>
/// <param name="work">Optional. The work the track is a recording of.</param>
/// <param name="musicBrainzRecordingId">Optional. The MusicBrainz identifier of the recording.</param>
/// <param name="musicBrainzTrackId">Optional. The MusicBrainz identifier of the track.</param>
/// <param name="moods">Optional. The list of moods of the track.</param>
/// <param name="isrcs">Optional. The list of ISRC of the track.</param>
/// <param name="contributors">Optional. The list of media contributors that performed on the track.</param>
/// <param name="ratings">Optional. The list of ratings for this track.</param>
/// <param name="includePath">Whether the path should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackNumber">Whether the track number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeDiscNumber">Whether the disc number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeScript">Whether the script should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeKey">Whether the musical key should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBpm">Whether the tempo should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeWork">Whether the work should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzRecordingId">Whether the MusicBrainz recording Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzTrackId">Whether the MusicBrainz track Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMoods">Whether the moods should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsrcs">Whether the ISRC codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created request to add a track.</returns>
public AddTrackRequest Create(
string? path = null,
MusicTrackMetadataDto? metadata = null,
int? trackNumber = null,
int? discNumber = null,
string? script = null,
MusicKey? key = null,
int? bpm = null,
MusicWorkDto? work = null,
Guid? musicBrainzRecordingId = null,
Guid? musicBrainzTrackId = null,
List<MoodDto>? moods = null,
List<IsrcDto>? isrcs = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
bool includePath = true,
bool includeMetadata = true,
bool includeTrackNumber = true,
bool includeDiscNumber = true,
bool includeScript = true,
bool includeKey = true,
bool includeBpm = true,
bool includeWork = true,
bool includeMusicBrainzRecordingId = true,
bool includeMusicBrainzTrackId = true,
bool includeMoods = true,
bool includeIsrcs = true,
bool includeContributors = true,
bool includeRatings = true)
{
return new AddTrackRequest(
includePath ? path ?? Path.Combine(Path.GetTempPath(), "lumina-tracks", _faker.System.FileName()) : null,
includeMetadata ? metadata ?? _musicTrackMetadataDtoFixture.Create() : null,
includeTrackNumber ? trackNumber ?? _faker.Random.Int(1, 30) : null,
includeDiscNumber ? discNumber ?? _faker.Random.Int(1, 3) : null,
includeScript ? script ?? _faker.Random.AlphaNumeric(4) : null,
includeKey ? key ?? _faker.PickRandom<MusicKey>() : null,
includeBpm ? bpm ?? _faker.Random.Int(40, 220) : null,
includeWork ? work ?? _musicWorkDtoFixture.Create() : null,
includeMusicBrainzRecordingId ? musicBrainzRecordingId ?? _faker.Random.Guid() : null,
includeMusicBrainzTrackId ? musicBrainzTrackId ?? _faker.Random.Guid() : null,
includeMoods ? moods ?? _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeIsrcs ? isrcs ?? _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeContributors ? contributors ?? _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeRatings ? ratings ?? _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null);
}
/// <summary>
/// Creates a list of <see cref="AddTrackRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<AddTrackRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
/// <summary>
/// Fixture class for the <see cref="ShuffleTracksRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ShuffleTracksRequestFixture
{
/// <summary>
/// Creates a random valid <see cref="ShuffleTracksRequest"/>.
/// </summary>
/// <param name="count">Optional. The maximum number of tracks to return.</param>
/// <param name="artistId">Optional. The Id of the artist whose tracks are sampled.</param>
/// <param name="albumId">Optional. The Id of the album whose tracks are sampled.</param>
/// <param name="excludedTrackIds">Optional. The tracks that must not be returned.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeExcludedTrackIds">Whether the excluded track Ids should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="ShuffleTracksRequest"/>.</returns>
public ShuffleTracksRequest Create(
int? count = null,
Guid? artistId = null,
Guid? albumId = null,
List<Guid>? excludedTrackIds = null,
bool includeArtistId = true,
bool includeAlbumId = true,
bool includeExcludedTrackIds = true)
{
return new ShuffleTracksRequest(
count ?? Random.Shared.Next(1, 501),
includeArtistId ? (artistId ?? Guid.NewGuid()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid()) : null,
includeExcludedTrackIds
? (excludedTrackIds ?? [.. Enumerable.Range(0, Random.Shared.Next(0, 3)).Select(_ => Guid.NewGuid())])
: null);
}
/// <summary>
/// Creates a list of <see cref="ShuffleTracksRequest"/> records with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ShuffleTracksRequest"/> records.</returns>
public List<ShuffleTracksRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,118 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.Common;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
/// <summary>
/// Fixture class for the <see cref="UpdateTrackRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateTrackRequestFixture
{
private readonly Faker _faker = new();
private readonly MusicTrackMetadataDtoFixture _musicTrackMetadataDtoFixture = new();
private readonly MusicWorkDtoFixture _musicWorkDtoFixture = new();
private readonly MoodDtoFixture _moodDtoFixture = new();
private readonly IsrcDtoFixture _isrcDtoFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
/// <summary>
/// Creates a random valid request to update a track.
/// </summary>
/// <param name="metadata">Optional. The audio metadata of the track.</param>
/// <param name="trackNumber">Optional. The number of the track on its disc.</param>
/// <param name="discNumber">Optional. The number of the disc the track belongs to.</param>
/// <param name="script">Optional. The script used by the language of the track.</param>
/// <param name="key">Optional. The musical key of the track.</param>
/// <param name="bpm">Optional. The tempo of the track in beats per minute.</param>
/// <param name="work">Optional. The work the track is a recording of.</param>
/// <param name="musicBrainzRecordingId">Optional. The MusicBrainz identifier of the recording.</param>
/// <param name="musicBrainzTrackId">Optional. The MusicBrainz identifier of the track.</param>
/// <param name="moods">Optional. The moods of the track.</param>
/// <param name="isrcs">Optional. The ISRC codes of the track.</param>
/// <param name="contributors">Optional. The media contributors that performed on the track.</param>
/// <param name="ratings">Optional. The ratings of the track.</param>
/// <param name="includeDiscNumber">Whether the disc number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeScript">Whether the script should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeKey">Whether the musical key should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBpm">Whether the tempo should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeWork">Whether the work should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzRecordingId">Whether the MusicBrainz recording Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzTrackId">Whether the MusicBrainz track Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMoods">Whether the moods should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsrcs">Whether the ISRC codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackNumber">Whether the track number should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created request to update a track.</returns>
public UpdateTrackRequest Create(
MusicTrackMetadataDto? metadata = null,
int? trackNumber = null,
int? discNumber = null,
string? script = null,
MusicKey? key = null,
int? bpm = null,
MusicWorkDto? work = null,
Guid? musicBrainzRecordingId = null,
Guid? musicBrainzTrackId = null,
List<MoodDto>? moods = null,
List<IsrcDto>? isrcs = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
bool includeDiscNumber = true,
bool includeScript = true,
bool includeKey = true,
bool includeBpm = true,
bool includeWork = true,
bool includeMusicBrainzRecordingId = true,
bool includeMusicBrainzTrackId = true,
bool includeMoods = true,
bool includeIsrcs = true,
bool includeContributors = true,
bool includeRatings = true,
bool includeMetadata = true,
bool includeTrackNumber = true)
{
return new UpdateTrackRequest(
includeMetadata ? (metadata ?? _musicTrackMetadataDtoFixture.Create()) : null,
includeTrackNumber ? (trackNumber ?? _faker.Random.Int(1, 20)) : null,
includeDiscNumber ? (discNumber ?? _faker.Random.Int(1, 3)) : null,
includeScript ? (script ?? _faker.Random.String2(_faker.Random.Number(1, 50))) : null,
includeKey ? (key ?? _faker.PickRandom<MusicKey>()) : null,
includeBpm ? (bpm ?? _faker.Random.Int(40, 240)) : null,
includeWork ? (work ?? _musicWorkDtoFixture.Create()) : null,
includeMusicBrainzRecordingId ? (musicBrainzRecordingId ?? _faker.Random.Guid()) : null,
includeMusicBrainzTrackId ? (musicBrainzTrackId ?? _faker.Random.Guid()) : null,
includeMoods ? (moods ?? [.. _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeIsrcs ? (isrcs ?? [.. _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null);
}
/// <summary>
/// Creates a list of <see cref="UpdateTrackRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateTrackRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,89 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaLibrary.Management;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="AddLibraryRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddLibraryRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="AddLibraryRequest"/>.
/// </summary>
/// <param name="title">Optional. The title of the media library.</param>
/// <param name="libraryType">Optional. The type of the media library.</param>
/// <param name="contentLocations">Optional. The file system paths of the media library content directories.</param>
/// <param name="coverImage">Optional. The path of the image file used as the cover.</param>
/// <param name="isEnabled">Optional. Whether the media library is enabled.</param>
/// <param name="isLocked">Optional. Whether the media library is locked.</param>
/// <param name="canDownloadMetadataFromWeb">Optional. Whether metadata should be downloaded from the web.</param>
/// <param name="shouldSaveMetadataInMediaDirectories">Optional. Whether metadata should be saved in the media directories.</param>
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Optional. Whether unchanged directories should be skipped during scan.</param>
/// <param name="shouldSkipHiddenFilesAndDirectoriesDuringScan">Optional. Whether hidden files and directories should be skipped during scan.</param>
/// <param name="isContentOnSsd">Optional. Whether the content of the media library is stored on a solid state drive.</param>
/// <param name="shouldTrackConsumptionProgress">Optional. Whether the consumption progress of the media library items should be tracked, or not.</param>
/// <param name="completionThresholdPercentage">Optional. The percentage of a media library item that must be consumed for its session to be considered completed.</param>
/// <param name="pathTemplateParts">Optional. The ordered parts of the path template of the media library.</param>
/// <param name="metadataProviders">Optional. The choices made for the metadata providers of the media library.</param>
/// <param name="artworkProviders">Optional. The choices made for the artwork providers of the media library.</param>
/// <param name="bookReaders">Optional. The choices made for the book readers of the media library.</param>
/// <returns>The created <see cref="AddLibraryRequest"/>.</returns>
public AddLibraryRequest Create(
string? title = null,
string? libraryType = null,
string[]? contentLocations = null,
string? coverImage = null,
bool? isEnabled = null,
bool? isLocked = null,
bool? canDownloadMetadataFromWeb = null,
bool? shouldSaveMetadataInMediaDirectories = null,
bool? shouldSkipUnchangedDirectoriesDuringScan = null,
bool? shouldSkipHiddenFilesAndDirectoriesDuringScan = null,
bool? isContentOnSsd = null,
bool? shouldTrackConsumptionProgress = null,
int? completionThresholdPercentage = null,
LibraryPathTemplatePartRequest?[]? pathTemplateParts = null,
LibraryProviderSelectionRequest?[]? metadataProviders = null,
LibraryProviderSelectionRequest?[]? artworkProviders = null,
LibraryProviderSelectionRequest?[]? bookReaders = null)
{
return new AddLibraryRequest(
title ?? _faker.Commerce.Department(),
libraryType ?? "EBook",
contentLocations ?? [_faker.System.DirectoryPath()],
coverImage ?? null,
isEnabled ?? _faker.Random.Bool(),
isLocked ?? _faker.Random.Bool(),
canDownloadMetadataFromWeb ?? _faker.Random.Bool(),
shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(),
shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool(),
shouldSkipHiddenFilesAndDirectoriesDuringScan ?? _faker.Random.Bool(),
isContentOnSsd ?? false,
shouldTrackConsumptionProgress,
completionThresholdPercentage,
pathTemplateParts,
metadataProviders,
artworkProviders,
bookReaders
);
}
/// <summary>
/// Creates a list of <see cref="AddLibraryRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<AddLibraryRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaLibrary.Management;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="CancelLibraryScanRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class CancelLibraryScanRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="CancelLibraryScanRequest"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library whose scan is cancelled.</param>
/// <param name="scanId">Optional. The Id of the scan to cancel.</param>
/// <returns>The created <see cref="CancelLibraryScanRequest"/>.</returns>
public CancelLibraryScanRequest Create(
Guid? libraryId = null,
Guid? scanId = null)
{
return new CancelLibraryScanRequest(
libraryId ?? _faker.Random.Guid(),
scanId ?? _faker.Random.Guid()
);
}
/// <summary>
/// Creates a list of <see cref="CancelLibraryScanRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<CancelLibraryScanRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,41 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaLibrary.Management;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="DeleteLibraryRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class DeleteLibraryRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="DeleteLibraryRequest"/>.
/// </summary>
/// <param name="id">Optional. The Id of the media library to delete.</param>
/// <returns>The created <see cref="DeleteLibraryRequest"/>.</returns>
public DeleteLibraryRequest Create(Guid? id = null)
{
return new DeleteLibraryRequest(
id ?? _faker.Random.Guid()
);
}
/// <summary>
/// Creates a list of <see cref="DeleteLibraryRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<DeleteLibraryRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,35 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Requests.MediaLibrary.Management;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="GetLibraryPathTemplatePartsRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetLibraryPathTemplatePartsRequestFixture
{
/// <summary>
/// Creates a random valid <see cref="GetLibraryPathTemplatePartsRequest"/>.
/// </summary>
/// <param name="libraryType">Optional. The media library type whose available path parts are retrieved.</param>
/// <returns>The created <see cref="GetLibraryPathTemplatePartsRequest"/>.</returns>
public GetLibraryPathTemplatePartsRequest Create(string? libraryType = null)
{
return new GetLibraryPathTemplatePartsRequest(libraryType ?? "Music");
}
/// <summary>
/// Creates a list of <see cref="GetLibraryPathTemplatePartsRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetLibraryPathTemplatePartsRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,41 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaLibrary.Management;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="GetLibraryRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetLibraryRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="GetLibraryRequest"/>.
/// </summary>
/// <param name="id">Optional. The Id of the media library to retrieve.</param>
/// <returns>The created <see cref="GetLibraryRequest"/>.</returns>
public GetLibraryRequest Create(Guid? id = null)
{
return new GetLibraryRequest(
id ?? _faker.Random.Guid()
);
}
/// <summary>
/// Creates a list of <see cref="GetLibraryRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetLibraryRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaLibrary.Management;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="GetLibraryScanProgressRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetLibraryScanProgressRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="GetLibraryScanProgressRequest"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library whose scan progress is requested.</param>
/// <param name="scanId">Optional. The Id of the media library scan whose progress is requested.</param>
/// <returns>The created <see cref="GetLibraryScanProgressRequest"/>.</returns>
public GetLibraryScanProgressRequest Create(
Guid? libraryId = null,
Guid? scanId = null)
{
return new GetLibraryScanProgressRequest(
libraryId ?? _faker.Random.Guid(),
scanId ?? _faker.Random.Guid()
);
}
/// <summary>
/// Creates a list of <see cref="GetLibraryScanProgressRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetLibraryScanProgressRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Requests.MediaLibrary.Management;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="LibraryPathTemplatePartRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryPathTemplatePartRequestFixture
{
/// <summary>
/// Creates a random valid <see cref="LibraryPathTemplatePartRequest"/>.
/// </summary>
/// <param name="kind">Optional. The kind of the path part.</param>
/// <param name="representation">Optional. The literal text or the value mask of the path part.</param>
/// <param name="isOptional">Whether the path part can be absent from the path.</param>
/// <returns>The created <see cref="LibraryPathTemplatePartRequest"/>.</returns>
public LibraryPathTemplatePartRequest Create(
string? kind = null,
string? representation = null,
bool isOptional = false)
{
return new LibraryPathTemplatePartRequest(
kind ?? "Artist",
representation ?? "{0}",
isOptional);
}
/// <summary>
/// Creates a list of <see cref="LibraryPathTemplatePartRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<LibraryPathTemplatePartRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Requests.MediaLibrary.Management;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="LibraryProviderSelectionRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryProviderSelectionRequestFixture
{
/// <summary>
/// Creates a random valid <see cref="LibraryProviderSelectionRequest"/>.
/// </summary>
/// <param name="pluginId">Optional. The Id of the plugin providing the provider or reader.</param>
/// <param name="isEnabled">Whether the provider or reader is enabled.</param>
/// <param name="includeIsEnabled">Whether the choice carries an enabled state. When <see langword="false"/>, the enabled state is <see langword="null"/>.</param>
/// <returns>The created <see cref="LibraryProviderSelectionRequest"/>.</returns>
public LibraryProviderSelectionRequest Create(
Guid? pluginId = null,
bool isEnabled = true,
bool includeIsEnabled = true)
{
return new LibraryProviderSelectionRequest(
pluginId ?? Guid.NewGuid(),
includeIsEnabled ? isEnabled : null);
}
/// <summary>
/// Creates a list of <see cref="LibraryProviderSelectionRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<LibraryProviderSelectionRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,41 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaLibrary.Management;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="ScanLibraryRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScanLibraryRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ScanLibraryRequest"/>.
/// </summary>
/// <param name="id">Optional. The Id of the media library to scan.</param>
/// <returns>The created <see cref="ScanLibraryRequest"/>.</returns>
public ScanLibraryRequest Create(Guid? id = null)
{
return new ScanLibraryRequest(
id ?? _faker.Random.Guid()
);
}
/// <summary>
/// Creates a list of <see cref="ScanLibraryRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ScanLibraryRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,93 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaLibrary.Management;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.Management;
/// <summary>
/// Fixture class for the <see cref="UpdateLibraryRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateLibraryRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="UpdateLibraryRequest"/>.
/// </summary>
/// <param name="id">Optional. The Id of the media library to update.</param>
/// <param name="title">Optional. The title of the media library.</param>
/// <param name="libraryType">Optional. The type of the media library.</param>
/// <param name="contentLocations">Optional. The file system paths of the media library content directories.</param>
/// <param name="coverImage">Optional. The path of the image file used as the cover.</param>
/// <param name="isEnabled">Optional. Whether the media library is enabled.</param>
/// <param name="isLocked">Optional. Whether the media library is locked.</param>
/// <param name="canDownloadMetadataFromWeb">Optional. Whether metadata should be downloaded from the web.</param>
/// <param name="shouldSaveMetadataInMediaDirectories">Optional. Whether metadata should be saved in the media directories.</param>
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Optional. Whether unchanged directories should be skipped during scan.</param>
/// <param name="shouldSkipHiddenFilesAndDirectoriesDuringScan">Optional. Whether hidden files and directories should be skipped during scan.</param>
/// <param name="isContentOnSsd">Optional. Whether the content of the media library is stored on a solid state drive.</param>
/// <param name="shouldTrackConsumptionProgress">Optional. Whether the consumption progress of the media library items should be tracked, or not.</param>
/// <param name="completionThresholdPercentage">Optional. The percentage of a media library item that must be consumed for its session to be considered completed.</param>
/// <param name="pathTemplateParts">Optional. The ordered parts of the path template of the media library.</param>
/// <param name="metadataProviders">Optional. The choices made for the metadata providers of the media library.</param>
/// <param name="artworkProviders">Optional. The choices made for the artwork providers of the media library.</param>
/// <param name="bookReaders">Optional. The choices made for the book readers of the media library.</param>
/// <returns>The created <see cref="UpdateLibraryRequest"/>.</returns>
public UpdateLibraryRequest Create(
Guid? id = null,
string? title = null,
string? libraryType = null,
string[]? contentLocations = null,
string? coverImage = null,
bool? isEnabled = null,
bool? isLocked = null,
bool? canDownloadMetadataFromWeb = null,
bool? shouldSaveMetadataInMediaDirectories = null,
bool? shouldSkipUnchangedDirectoriesDuringScan = null,
bool? shouldSkipHiddenFilesAndDirectoriesDuringScan = null,
bool? isContentOnSsd = null,
bool? shouldTrackConsumptionProgress = null,
int? completionThresholdPercentage = null,
LibraryPathTemplatePartRequest?[]? pathTemplateParts = null,
LibraryProviderSelectionRequest?[]? metadataProviders = null,
LibraryProviderSelectionRequest?[]? artworkProviders = null,
LibraryProviderSelectionRequest?[]? bookReaders = null)
{
return new UpdateLibraryRequest(
id ?? _faker.Random.Guid(),
title ?? _faker.Commerce.Department(),
libraryType ?? "EBook",
contentLocations ?? [_faker.System.DirectoryPath()],
coverImage ?? null,
isEnabled ?? _faker.Random.Bool(),
isLocked ?? _faker.Random.Bool(),
canDownloadMetadataFromWeb ?? _faker.Random.Bool(),
shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(),
shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool(),
shouldSkipHiddenFilesAndDirectoriesDuringScan ?? _faker.Random.Bool(),
isContentOnSsd ?? false,
shouldTrackConsumptionProgress,
completionThresholdPercentage,
pathTemplateParts,
metadataProviders,
artworkProviders,
bookReaders
);
}
/// <summary>
/// Creates a list of <see cref="UpdateLibraryRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateLibraryRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,210 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
/// <summary>
/// Fixture class for the <see cref="AddBookRequest"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddBookRequestFixture
{
private readonly IsbnDtoFixture _isbnDtoFixture = new();
private readonly BookRatingDtoFixture _bookRatingDtoFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly WrittenContentMetadataDtoFixture _writtenContentMetadataDtoFixture = new();
/// <summary>
/// Creates a random valid request to add a book.
/// </summary>
/// <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 contributors of the book.</param>
/// <param name="ratings">Optional. The ratings of the book.</param>
/// <param name="includeFormat">Whether the format should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeEdition">Whether the edition 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>
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoodreadsId">Whether the Goodreads Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLccn">Whether the LCCN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOclcNumber">Whether the OCLC number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOpenLibraryId">Whether the Open Library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryThingId">Whether the LibraryThing Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoogleBooksId">Whether the Google Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBarnesAndNobleId">Whether the Barnes and Noble Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAppleBooksId">Whether the Apple Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsbns">Whether the ISBNs should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created request to add a book.</returns>
public AddBookRequest Create(
string? path = null,
WrittenContentMetadataDto? metadata = null,
BookFormat? format = null,
string? edition = null,
float? volumeNumber = null,
BookSeriesDto? 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<IsbnDto>? isbns = null,
List<MediaContributorReferenceDto>? contributors = null,
List<BookRatingDto>? ratings = null,
bool includeFormat = true,
bool includeEdition = true,
bool includeVolumeNumber = true,
bool includeAsin = true,
bool includeGoodreadsId = true,
bool includeLccn = true,
bool includeOclcNumber = true,
bool includeOpenLibraryId = true,
bool includeLibraryThingId = true,
bool includeGoogleBooksId = true,
bool includeBarnesAndNobleId = true,
bool includeAppleBooksId = true,
bool includeIsbns = true,
bool includeRatings = true,
bool includeContributors = true)
{
return new Faker<AddBookRequest>()
.CustomInstantiator(f => new AddBookRequest(
default!,
default!,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default!,
default!,
default!,
default!
))
.RuleFor(x => x.Path, f => path ?? Path.Combine(Path.GetTempPath(), "lumina-books", f.System.FileName()))
.RuleFor(x => x.Metadata, metadata ?? _writtenContentMetadataDtoFixture.Create())
.RuleFor(x => x.Format, f => format ?? (includeFormat ? f.PickRandom<BookFormat>() : null))
.RuleFor(x => x.Edition, f => edition ?? (includeEdition ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeVolumeNumber ? (float?)f.Random.Number(1, 3) : null))
.RuleFor(x => x.Series, series)
.RuleFor(x => x.ASIN, f => asin ?? (includeAsin ? f.Random.String2(10) : null))
.RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeGoodreadsId ? f.Random.Number(100000, 500000).ToString() : null))
.RuleFor(x => x.LCCN, f => lccn ?? (includeLccn ? CreateLccn(f) : null))
.RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOclcNumber ? CreateOclcNumber(f) : null))
.RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOpenLibraryId ? CreateOpenLibraryId(f) : null))
.RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeLibraryThingId ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeGoogleBooksId ? CreateGoogleBooksId(f) : null))
.RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeBarnesAndNobleId ? f.Random.String2(10, "0123456789") : null))
.RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeAppleBooksId ? $"id{f.Random.Number(1, 999999)}" : null))
.RuleFor(p => p.ISBNs, f => isbns ?? (includeIsbns ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(p => p.Ratings, f => ratings ?? (includeRatings ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(x => x.Contributors, f => contributors ?? (includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null));
}
/// <summary>
/// Generates a random LCCN (Library of Congress Control Number).
/// </summary>
/// <param name="faker">The faker used to generate the value.</param>
/// <returns>The generated LCCN.</returns>
private static string CreateLccn(Faker faker)
{
string letters = new([.. Enumerable.Range(0, faker.Random.Number(0, 3)).Select(_ => faker.Random.Char('a', 'z'))]);
string digits = faker.Random.String2(faker.Random.Number(8, 10), "0123456789");
return letters + digits;
}
/// <summary>
/// Generates a random OCLC number (WorldCat identifier).
/// </summary>
/// <param name="faker">The faker used to generate the value.</param>
/// <returns>The generated OCLC number.</returns>
private static string CreateOclcNumber(Faker faker)
{
string[] prefixes = ["ocm", "ocn", "on", "(OCoLC)"];
string prefix = faker.Random.ArrayElement(prefixes);
string number;
switch (prefix)
{
case "ocm":
number = faker.Random.String2(8, "0123456789");
break;
case "ocn":
number = faker.Random.String2(faker.Random.Number(9, 11), "0123456789");
break;
case "on":
number = faker.Random.String2(10, "0123456789");
break;
case "(OCoLC)":
number = faker.Random.String2(faker.Random.Number(8, 10), "0123456789");
break;
default:
number = faker.Random.String2(faker.Random.Number(8, 10), "0123456789");
return number;
}
return prefix + number;
}
/// <summary>
/// Generates a random Open Library Id.
/// </summary>
/// <param name="faker">The faker used to generate the value.</param>
/// <returns>The generated Open Library Id.</returns>
private static string CreateOpenLibraryId(Faker faker)
{
int firstDigit = faker.Random.Number(1, 9);
string remainingDigits = faker.Random.String2(faker.Random.Number(0, 6), "0123456789");
char suffix = faker.Random.ArrayElement(['A', 'M', 'W']);
return $"OL{firstDigit}{remainingDigits}{suffix}";
}
/// <summary>
/// Generates a random Google Books Id.
/// </summary>
/// <param name="faker">The faker used to generate the value.</param>
/// <returns>The generated Google Books Id.</returns>
private static string CreateGoogleBooksId(Faker faker)
{
const string VALID_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
return new string([.. Enumerable.Repeat(VALID_CHARS, 12).Select(s => s[faker.Random.Number(VALID_CHARS.Length - 1)])]);
}
}
@@ -0,0 +1,64 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Domain.SharedKernel.Common.Enums.Common;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
/// <summary>
/// Fixture class for the <see cref="GetBooksLiteRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetBooksLiteRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a <see cref="GetBooksLiteRequest"/> with default or random values.
/// </summary>
/// <param name="currentPage">Optional. The page of results to retrieve.</param>
/// <param name="perPage">Optional. The maximum number of books to retrieve per page.</param>
/// <param name="searchTerm">Optional. The search term used to filter results.</param>
/// <param name="filterAlphaKey">Optional. The alpha key used to filter the results by the first character of their title, for the alpha picker.</param>
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Optional. Whether the leading "The " prefix of a title should be ignored when computing the alpha key, or not.</param>
/// <param name="sortBy">Optional. The name of the field by which to sort the results.</param>
/// <param name="sortOrder">Optional. The direction in which to sort the results.</param>
/// <param name="includeCurrentPage">Whether the current page should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePerPage">Whether the per page count should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetBooksLiteRequest"/>.</returns>
public GetBooksLiteRequest Create(
int? currentPage = null,
int? perPage = null,
string? searchTerm = null,
string? filterAlphaKey = null,
bool shouldIgnoreThePrefixForAlphaPicker = false,
string? sortBy = null,
SortOrder? sortOrder = null,
bool includeCurrentPage = true,
bool includePerPage = true)
{
return new GetBooksLiteRequest(
CurrentPage: includeCurrentPage ? (currentPage ?? _faker.Random.Number(1, 100)) : null,
PerPage: includePerPage ? (perPage ?? _faker.Random.Number(1, 200)) : null,
SearchTerm: searchTerm ?? _faker.Lorem.Word(),
FilterAlphaKey: filterAlphaKey,
ShouldIgnoreThePrefixForAlphaPicker: shouldIgnoreThePrefixForAlphaPicker,
SortBy: sortBy ?? _faker.Lorem.Word(),
SortOrder: sortOrder ?? _faker.PickRandom<SortOrder>()
);
}
/// <summary>
/// Creates a list of <see cref="GetBooksLiteRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetBooksLiteRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,58 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Domain.SharedKernel.Common.Enums.Common;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
/// <summary>
/// Fixture class for the <see cref="GetBooksRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetBooksRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a <see cref="GetBooksRequest"/> with default or random values.
/// </summary>
/// <param name="currentPage">Optional. The page of results to retrieve.</param>
/// <param name="perPage">Optional. The maximum number of books to retrieve per page.</param>
/// <param name="searchTerm">Optional. The search term used to filter results.</param>
/// <param name="sortBy">Optional. The name of the field by which to sort the results.</param>
/// <param name="sortOrder">Optional. The direction in which to sort the results.</param>
/// <param name="includeCurrentPage">Whether the current page should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePerPage">Whether the per page count should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GetBooksRequest"/>.</returns>
public GetBooksRequest Create(
int? currentPage = null,
int? perPage = null,
string? searchTerm = null,
string? sortBy = null,
SortOrder? sortOrder = null,
bool includeCurrentPage = true,
bool includePerPage = true)
{
return new GetBooksRequest(
CurrentPage: includeCurrentPage ? (currentPage ?? _faker.Random.Number(1, 100)) : null,
PerPage: includePerPage ? (perPage ?? _faker.Random.Number(1, 200)) : null,
SearchTerm: searchTerm ?? _faker.Lorem.Word(),
SortBy: sortBy ?? _faker.Lorem.Word(),
SortOrder: sortOrder ?? _faker.PickRandom<SortOrder>()
);
}
/// <summary>
/// Creates a list of <see cref="GetBooksRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetBooksRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,205 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
/// <summary>
/// Fixture class for the <see cref="UpdateBookRequest"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateBookRequestFixture
{
private readonly IsbnDtoFixture _isbnDtoFixture = new();
private readonly BookRatingDtoFixture _bookRatingDtoFixture = new();
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
private readonly WrittenContentMetadataDtoFixture _writtenContentMetadataDtoFixture = new();
/// <summary>
/// Creates a random valid request to update a book.
/// </summary>
/// <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 contributors of the book.</param>
/// <param name="ratings">Optional. The ratings of the book.</param>
/// <param name="includeFormat">Whether the format should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeEdition">Whether the edition 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>
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoodreadsId">Whether the Goodreads Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLccn">Whether the LCCN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOclcNumber">Whether the OCLC number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOpenLibraryId">Whether the Open Library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryThingId">Whether the LibraryThing Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoogleBooksId">Whether the Google Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBarnesAndNobleId">Whether the Barnes and Noble Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAppleBooksId">Whether the Apple Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsbns">Whether the ISBNs should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created request to update a book.</returns>
public UpdateBookRequest Create(
WrittenContentMetadataDto? metadata = null,
BookFormat? format = null,
string? edition = null,
float? volumeNumber = null,
BookSeriesDto? 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<IsbnDto>? isbns = null,
List<MediaContributorReferenceDto>? contributors = null,
List<BookRatingDto>? ratings = null,
bool includeFormat = true,
bool includeEdition = true,
bool includeVolumeNumber = true,
bool includeAsin = true,
bool includeGoodreadsId = true,
bool includeLccn = true,
bool includeOclcNumber = true,
bool includeOpenLibraryId = true,
bool includeLibraryThingId = true,
bool includeGoogleBooksId = true,
bool includeBarnesAndNobleId = true,
bool includeAppleBooksId = true,
bool includeIsbns = true,
bool includeRatings = true,
bool includeContributors = true)
{
return new Faker<UpdateBookRequest>()
.CustomInstantiator(f => new UpdateBookRequest(
default!,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default,
default!,
default!,
default!
))
.RuleFor(x => x.Metadata, metadata ?? _writtenContentMetadataDtoFixture.Create())
.RuleFor(x => x.Format, f => format ?? (includeFormat ? f.PickRandom<BookFormat>() : null))
.RuleFor(x => x.Edition, f => edition ?? (includeEdition ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeVolumeNumber ? (float?)f.Random.Number(1, 3) : null))
.RuleFor(x => x.Series, series)
.RuleFor(x => x.ASIN, f => asin ?? (includeAsin ? f.Random.String2(10) : null))
.RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeGoodreadsId ? f.Random.Number(100000, 500000).ToString() : null))
.RuleFor(x => x.LCCN, f => lccn ?? (includeLccn ? CreateLccn(f) : null))
.RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOclcNumber ? CreateOclcNumber(f) : null))
.RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOpenLibraryId ? CreateOpenLibraryId(f) : null))
.RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeLibraryThingId ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeGoogleBooksId ? CreateGoogleBooksId(f) : null))
.RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeBarnesAndNobleId ? f.Random.String2(10, "0123456789") : null))
.RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeAppleBooksId ? $"id{f.Random.Number(1, 999999)}" : null))
.RuleFor(p => p.ISBNs, f => isbns ?? (includeIsbns ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(p => p.Ratings, f => ratings ?? (includeRatings ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(x => x.Contributors, f => contributors ?? (includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null));
}
/// <summary>
/// Generates a random LCCN (Library of Congress Control Number).
/// </summary>
/// <param name="faker">The faker used to generate the value.</param>
/// <returns>The generated LCCN.</returns>
private static string CreateLccn(Faker faker)
{
string letters = new([.. Enumerable.Range(0, faker.Random.Number(0, 3)).Select(_ => faker.Random.Char('a', 'z'))]);
string digits = faker.Random.String2(faker.Random.Number(8, 10), "0123456789");
return letters + digits;
}
/// <summary>
/// Generates a random OCLC number (WorldCat identifier).
/// </summary>
/// <param name="faker">The faker used to generate the value.</param>
/// <returns>The generated OCLC number.</returns>
private static string CreateOclcNumber(Faker faker)
{
string[] prefixes = ["ocm", "ocn", "on", "(OCoLC)"];
string prefix = faker.Random.ArrayElement(prefixes);
string number;
switch (prefix)
{
case "ocm":
number = faker.Random.String2(8, "0123456789");
break;
case "ocn":
number = faker.Random.String2(faker.Random.Number(9, 11), "0123456789");
break;
case "on":
number = faker.Random.String2(10, "0123456789");
break;
case "(OCoLC)":
number = faker.Random.String2(faker.Random.Number(8, 10), "0123456789");
break;
default:
number = faker.Random.String2(faker.Random.Number(8, 10), "0123456789");
return number;
}
return prefix + number;
}
/// <summary>
/// Generates a random Open Library Id.
/// </summary>
/// <param name="faker">The faker used to generate the value.</param>
/// <returns>The generated Open Library Id.</returns>
private static string CreateOpenLibraryId(Faker faker)
{
int firstDigit = faker.Random.Number(1, 9);
string remainingDigits = faker.Random.String2(faker.Random.Number(0, 6), "0123456789");
char suffix = faker.Random.ArrayElement(['A', 'M', 'W']);
return $"OL{firstDigit}{remainingDigits}{suffix}";
}
/// <summary>
/// Generates a random Google Books Id.
/// </summary>
/// <param name="faker">The faker used to generate the value.</param>
/// <returns>The generated Google Books Id.</returns>
private static string CreateGoogleBooksId(Faker faker)
{
const string VALID_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
return new string([.. Enumerable.Repeat(VALID_CHARS, 12).Select(s => s[faker.Random.Number(VALID_CHARS.Length - 1)])]);
}
}