mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 17:11:10 +00:00
Adds the music library album test suite
This commit is contained in:
1 parent
ffe79221fe
commit
5d3e430dd1
57 files changed
+16761
-24
No files matched your search
+165
@@ -0,0 +1,165 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AlbumMetadataDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AlbumMetadataDtoFixture
|
||||
{
|
||||
private const int MINIMUM_RELEASE_YEAR = 1900;
|
||||
private const int MAXIMUM_RELEASE_YEAR = 2026;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
private readonly GenreDtoFixture _genreDtoFixture = new();
|
||||
private readonly TagDtoFixture _tagDtoFixture = new();
|
||||
private readonly LanguageInfoDtoFixture _languageInfoDtoFixture = new();
|
||||
private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AlbumMetadataDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional. The title of the album.</param>
|
||||
/// <param name="originalTitle">Optional. The original title of the album.</param>
|
||||
/// <param name="description">Optional. A brief description or summary of the album.</param>
|
||||
/// <param name="releaseInfo">Optional. The release information of the album.</param>
|
||||
/// <param name="language">Optional. The language of the album.</param>
|
||||
/// <param name="originalLanguage">Optional. The original language of the album.</param>
|
||||
/// <param name="tags">Optional. The tags that describe or categorize the album.</param>
|
||||
/// <param name="genres">Optional. The genres associated with the album.</param>
|
||||
/// <param name="releaseType">Optional. The type of the release.</param>
|
||||
/// <param name="releaseStatus">Optional. The status of the release.</param>
|
||||
/// <param name="totalDiscs">Optional. The number of discs of the release.</param>
|
||||
/// <param name="totalTracks">Optional. The number of tracks of the release.</param>
|
||||
/// <param name="includeTitle">Whether the title should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeOriginalTitle">Whether the original title should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReleaseInfo">Whether the release information should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLanguage">Whether the language should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeOriginalLanguage">Whether the original language should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeTags">Whether the tags should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeGenres">Whether the genres should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReleaseType">Whether the release type should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeReleaseStatus">Whether the release status should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeTotalDiscs">Whether the total number of discs should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeTotalTracks">Whether the total number of tracks should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="AlbumMetadataDto"/>.</returns>
|
||||
public AlbumMetadataDto Create(
|
||||
string? title = null,
|
||||
string? originalTitle = null,
|
||||
string? description = null,
|
||||
ReleaseInfoDto? releaseInfo = null,
|
||||
LanguageInfoDto? language = null,
|
||||
LanguageInfoDto? originalLanguage = null,
|
||||
List<TagDto>? tags = null,
|
||||
List<GenreDto>? genres = null,
|
||||
MusicReleaseType? releaseType = null,
|
||||
MusicReleaseStatus? releaseStatus = null,
|
||||
int? totalDiscs = null,
|
||||
int? totalTracks = null,
|
||||
bool includeTitle = true,
|
||||
bool includeOriginalTitle = true,
|
||||
bool includeDescription = true,
|
||||
bool includeReleaseInfo = true,
|
||||
bool includeLanguage = true,
|
||||
bool includeOriginalLanguage = true,
|
||||
bool includeTags = true,
|
||||
bool includeGenres = true,
|
||||
bool includeReleaseType = true,
|
||||
bool includeReleaseStatus = true,
|
||||
bool includeTotalDiscs = true,
|
||||
bool includeTotalTracks = true)
|
||||
{
|
||||
return new AlbumMetadataDto(
|
||||
includeTitle ? (title ?? _faker.Music.Genre()) : null,
|
||||
includeOriginalTitle ? (originalTitle ?? _faker.Music.Genre()) : null,
|
||||
includeDescription ? (description ?? _faker.Lorem.Paragraph()) : null,
|
||||
includeReleaseInfo ? (releaseInfo ?? GenerateReleaseInfo()) : null,
|
||||
includeLanguage ? (language ?? _languageInfoDtoFixture.Create()) : null,
|
||||
includeOriginalLanguage ? (originalLanguage ?? _languageInfoDtoFixture.Create()) : null,
|
||||
includeTags ? (tags ?? GenerateDistinctTags()) : null,
|
||||
includeGenres ? (genres ?? GenerateDistinctGenres()) : null,
|
||||
includeReleaseType ? (releaseType ?? _faker.PickRandom<MusicReleaseType>()) : null,
|
||||
includeReleaseStatus ? (releaseStatus ?? _faker.PickRandom<MusicReleaseStatus>()) : null,
|
||||
includeTotalDiscs ? (totalDiscs ?? _faker.Random.Int(1, 3)) : null,
|
||||
includeTotalTracks ? (totalTracks ?? _faker.Random.Int(1, 30)) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AlbumMetadataDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<AlbumMetadataDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ReleaseInfoDto"/> with consistent dates and years.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="ReleaseInfoDto"/>.</returns>
|
||||
private ReleaseInfoDto GenerateReleaseInfo()
|
||||
{
|
||||
int originalReleaseYear = Random.Shared.Next(MINIMUM_RELEASE_YEAR, MAXIMUM_RELEASE_YEAR);
|
||||
int reReleaseYear = Random.Shared.Next(originalReleaseYear, MAXIMUM_RELEASE_YEAR);
|
||||
return _releaseInfoDtoFixture.Create(
|
||||
originalReleaseDate: new DateOnly(originalReleaseYear, 1, 1),
|
||||
originalReleaseYear: originalReleaseYear,
|
||||
reReleaseDate: new DateOnly(reReleaseYear, 1, 1),
|
||||
reReleaseYear: reReleaseYear,
|
||||
releaseCountry: _faker.PickRandom<ReleaseCountry>(),
|
||||
releaseVersion: _faker.Random.String2(_faker.Random.Number(1, 50)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates two genres with distinct names, so that the storage deduplication never collapses them into one.
|
||||
/// </summary>
|
||||
/// <returns>The created genres.</returns>
|
||||
private List<GenreDto> GenerateDistinctGenres()
|
||||
{
|
||||
return
|
||||
[
|
||||
_genreDtoFixture.Create(name: CreateUniqueName()),
|
||||
_genreDtoFixture.Create(name: CreateUniqueName())
|
||||
];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates two tags with distinct names, so that the storage deduplication never collapses them into one.
|
||||
/// </summary>
|
||||
/// <returns>The created tags.</returns>
|
||||
private List<TagDto> GenerateDistinctTags()
|
||||
{
|
||||
return
|
||||
[
|
||||
_tagDtoFixture.Create(name: CreateUniqueName()),
|
||||
_tagDtoFixture.Create(name: CreateUniqueName())
|
||||
];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a unique name, so that the generated genres and tags never collapse into one after storage deduplication.
|
||||
/// </summary>
|
||||
/// <returns>A unique name of at most 50 characters.</returns>
|
||||
private string CreateUniqueName()
|
||||
{
|
||||
string uniqueSuffix = Guid.NewGuid().ToString("N")[..12];
|
||||
int maximumWordLength = 50 - uniqueSuffix.Length - 1;
|
||||
string word = _faker.Lorem.Word();
|
||||
string truncatedWord = word.Length > maximumWordLength ? word[..maximumWordLength] : word;
|
||||
return $"{truncatedWord}-{uniqueSuffix}";
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
#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 AlbumMetadataDtoFixture _albumMetadataDtoFixture = 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="barcode">Optional. The barcode of the album.</param>
|
||||
/// <param name="catalogNumber">Optional. The catalog number 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="includeBarcode">Whether the barcode should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeCatalogNumber">Whether the catalog number 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(
|
||||
AlbumMetadataDto? metadata = null,
|
||||
MusicMediaFormat? mediaFormat = null,
|
||||
string? barcode = null,
|
||||
string? catalogNumber = 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 includeBarcode = true,
|
||||
bool includeCatalogNumber = true,
|
||||
bool includeMusicBrainzReleaseId = true,
|
||||
bool includeMusicBrainzReleaseGroupId = true,
|
||||
bool includeMusicBrainzReleaseArtistId = true)
|
||||
{
|
||||
return new AddAlbumRequest(
|
||||
includeMetadata ? (metadata ?? _albumMetadataDtoFixture.Create()) : null,
|
||||
includeMediaFormat ? (mediaFormat ?? _faker.PickRandom<MusicMediaFormat>()) : null,
|
||||
includeBarcode ? (barcode ?? _faker.Random.String2(13, "0123456789")) : null,
|
||||
includeCatalogNumber ? (catalogNumber ?? _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())];
|
||||
}
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
#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 AlbumMetadataDtoFixture _albumMetadataDtoFixture = 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="barcode">Optional. The barcode of the album.</param>
|
||||
/// <param name="catalogNumber">Optional. The catalog number 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="includeBarcode">Whether the barcode should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeCatalogNumber">Whether the catalog number 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(
|
||||
AlbumMetadataDto? metadata = null,
|
||||
MusicMediaFormat? mediaFormat = null,
|
||||
string? barcode = null,
|
||||
string? catalogNumber = 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 includeBarcode = true,
|
||||
bool includeCatalogNumber = true,
|
||||
bool includeMusicBrainzReleaseId = true,
|
||||
bool includeMusicBrainzReleaseGroupId = true,
|
||||
bool includeMusicBrainzReleaseArtistId = true)
|
||||
{
|
||||
return new UpdateAlbumRequest(
|
||||
includeMetadata ? (metadata ?? _albumMetadataDtoFixture.Create()) : null,
|
||||
includeMediaFormat ? (mediaFormat ?? _faker.PickRandom<MusicMediaFormat>()) : null,
|
||||
includeBarcode ? (barcode ?? _faker.Random.String2(13, "0123456789")) : null,
|
||||
includeCatalogNumber ? (catalogNumber ?? _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())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AlbumLiteResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AlbumLiteResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AlbumLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the album.</param>
|
||||
/// <param name="title">Optional. The title of the album.</param>
|
||||
/// <param name="totalTracks">Optional. The number of tracks of the release.</param>
|
||||
/// <returns>The created <see cref="AlbumLiteResponse"/>.</returns>
|
||||
public AlbumLiteResponse Create(
|
||||
Guid? id = null,
|
||||
string? title = null,
|
||||
int? totalTracks = null)
|
||||
{
|
||||
return new AlbumLiteResponse(
|
||||
id ?? Guid.NewGuid(),
|
||||
title ?? _faker.Commerce.ProductName(),
|
||||
totalTracks ?? _faker.Random.Int(1, 30));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AlbumLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<AlbumLiteResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+116
@@ -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.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Contracts.Responses.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.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AlbumResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AlbumResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly AlbumMetadataDtoFixture _albumMetadataDtoFixture = new();
|
||||
private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new();
|
||||
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
|
||||
private readonly TrackResponseFixture _trackResponseFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AlbumResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the album.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist the album belongs to.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the album belongs to.</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="barcode">Optional. The barcode of the album.</param>
|
||||
/// <param name="catalogNumber">Optional. The catalog number 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="createdOnUtc">Optional. The date and time when the album was created.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the album was updated.</param>
|
||||
/// <param name="contributors">Optional. The list of contributor references of the album.</param>
|
||||
/// <param name="ratings">Optional. The list of ratings of the album.</param>
|
||||
/// <param name="tracks">Optional. The list of tracks of the album.</param>
|
||||
/// <param name="includeMediaFormat">Whether the media format 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="includeCatalogNumber">Whether the catalog number 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="includeUpdatedOnUtc">Whether the update date 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>
|
||||
/// <param name="includeTracks">Whether the tracks should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="AlbumResponse"/>.</returns>
|
||||
public AlbumResponse Create(
|
||||
Guid? id = null,
|
||||
Guid? artistId = null,
|
||||
Guid? libraryId = null,
|
||||
AlbumMetadataDto? metadata = null,
|
||||
MusicMediaFormat? mediaFormat = null,
|
||||
string? barcode = null,
|
||||
string? catalogNumber = null,
|
||||
Guid? musicBrainzReleaseId = null,
|
||||
Guid? musicBrainzReleaseGroupId = null,
|
||||
Guid? musicBrainzReleaseArtistId = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
List<MediaContributorReferenceDto>? contributors = null,
|
||||
List<AudioRatingDto>? ratings = null,
|
||||
List<TrackResponse>? tracks = null,
|
||||
bool includeMediaFormat = true,
|
||||
bool includeBarcode = true,
|
||||
bool includeCatalogNumber = true,
|
||||
bool includeMusicBrainzReleaseId = true,
|
||||
bool includeMusicBrainzReleaseGroupId = true,
|
||||
bool includeMusicBrainzReleaseArtistId = true,
|
||||
bool includeUpdatedOnUtc = true,
|
||||
bool includeContributors = true,
|
||||
bool includeRatings = true,
|
||||
bool includeTracks = true)
|
||||
{
|
||||
return new AlbumResponse(
|
||||
id ?? Guid.NewGuid(),
|
||||
artistId ?? Guid.NewGuid(),
|
||||
libraryId ?? Guid.NewGuid(),
|
||||
metadata ?? _albumMetadataDtoFixture.Create(),
|
||||
includeMediaFormat ? (mediaFormat ?? _faker.PickRandom<MusicMediaFormat>()) : null,
|
||||
includeBarcode ? (barcode ?? _faker.Random.String2(13, "0123456789")) : null,
|
||||
includeCatalogNumber ? (catalogNumber ?? _faker.Random.AlphaNumeric(10)) : null,
|
||||
includeMusicBrainzReleaseId ? (musicBrainzReleaseId ?? Guid.NewGuid()) : null,
|
||||
includeMusicBrainzReleaseGroupId ? (musicBrainzReleaseGroupId ?? Guid.NewGuid()) : null,
|
||||
includeMusicBrainzReleaseArtistId ? (musicBrainzReleaseArtistId ?? Guid.NewGuid()) : null,
|
||||
createdOnUtc ?? _faker.Date.Past().ToUniversalTime(),
|
||||
includeUpdatedOnUtc ? (updatedOnUtc ?? _faker.Date.Recent().ToUniversalTime()) : null,
|
||||
includeContributors ? (contributors ?? _mediaContributorReferenceDtoFixture.CreateMany(1)) : null,
|
||||
includeRatings ? (ratings ?? _audioRatingDtoFixture.CreateMany(1)) : null,
|
||||
includeTracks ? (tracks ?? _trackResponseFixture.CreateMany(1)) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AlbumResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<AlbumResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user