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,46 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Authentication;
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.Authentication;
/// <summary>
/// Fixture class for the <see cref="PermissionDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PermissionDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PermissionDto"/>.
/// </summary>
/// <param name="id">Optional. The Id of the permission.</param>
/// <param name="permissionName">Optional. The name of the permission.</param>
/// <returns>The created <see cref="PermissionDto"/>.</returns>
public PermissionDto Create(
Guid? id = null,
AuthorizationPermission? permissionName = null)
{
return new PermissionDto(
id ?? Guid.NewGuid(),
permissionName ?? _faker.PickRandom<AuthorizationPermission>()
);
}
/// <summary>
/// Creates a list of <see cref="PermissionDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<PermissionDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,44 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Authentication;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.Authentication;
/// <summary>
/// Fixture class for the <see cref="RoleDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RoleDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="RoleDto"/>.
/// </summary>
/// <param name="id">Optional. The unique identifier of the role.</param>
/// <param name="roleName">Optional. The name of the role.</param>
/// <returns>The created <see cref="RoleDto"/>.</returns>
public RoleDto Create(
Guid? id = null,
string? roleName = null)
{
return new RoleDto(
id ?? Guid.NewGuid(),
roleName ?? _faker.Lorem.Word());
}
/// <summary>
/// Creates a list of <see cref="RoleDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<RoleDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.Common;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.Common;
/// <summary>
/// Fixture class for the <see cref="ArtworkDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ArtworkDtoFixture
{
/// <summary>
/// Creates an <see cref="ArtworkDto"/>.
/// </summary>
/// <param name="localPath">Optional. The local file system path of the artwork.</param>
/// <param name="remoteUrl">Optional. The remote URL of the artwork.</param>
/// <param name="type">Optional. The type of the artwork.</param>
/// <param name="ordinal">Optional. The ordinal of the artwork within its type.</param>
/// <returns>The created <see cref="ArtworkDto"/>.</returns>
public ArtworkDto Create(
string? localPath = null,
string? remoteUrl = null,
ArtworkType type = ArtworkType.Cover,
int ordinal = 0)
{
return new ArtworkDto(type, ordinal, localPath, remoteUrl);
}
/// <summary>
/// Creates a list of <see cref="ArtworkDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ArtworkDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,41 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Common;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.Common;
/// <summary>
/// Fixture class for the <see cref="GenreDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class GenreDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="GenreDto"/>.
/// </summary>
/// <param name="name">Optional. The name of the genre.</param>
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="GenreDto"/>.</returns>
public GenreDto Create(
string? name = null,
bool includeName = true)
{
return new GenreDto(includeName ? name ?? _faker.Lorem.Word() : null);
}
/// <summary>
/// Creates a list of <see cref="GenreDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GenreDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,52 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Common;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.Common;
/// <summary>
/// Fixture class for the <see cref="LanguageInfoDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LanguageInfoDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="LanguageInfoDto"/>.
/// </summary>
/// <param name="languageCode">Optional. The ISO code of the language.</param>
/// <param name="languageName">Optional. The name of the language in English.</param>
/// <param name="nativeName">Optional. The native name of the language.</param>
/// <param name="includeLanguageCode">Whether the language code should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLanguageName">Whether the language name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeNativeName">Whether the native name should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="LanguageInfoDto"/>.</returns>
public LanguageInfoDto Create(
string? languageCode = null,
string? languageName = null,
string? nativeName = null,
bool includeLanguageCode = true,
bool includeLanguageName = true,
bool includeNativeName = true)
{
return new LanguageInfoDto(
includeLanguageCode ? (languageCode ?? _faker.Random.String2(2)) : null,
includeLanguageName ? (languageName ?? _faker.Lorem.Word()) : null,
includeNativeName ? (nativeName ?? _faker.Lorem.Word()) : null);
}
/// <summary>
/// Creates a list of <see cref="LanguageInfoDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<LanguageInfoDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,47 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Common;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.Common;
/// <summary>
/// Fixture class for the <see cref="MediaArtworkDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaArtworkDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="MediaArtworkDto"/>.
/// </summary>
/// <param name="type">Optional. The type of the artwork.</param>
/// <param name="ordinal">Optional. The ordinal of the artwork within its type.</param>
/// <param name="path">Optional. The relative path of the stored artwork file.</param>
/// <returns>The created <see cref="MediaArtworkDto"/>.</returns>
public MediaArtworkDto Create(
ArtworkType? type = null,
int? ordinal = null,
string? path = null)
{
return new MediaArtworkDto(
type ?? _faker.PickRandom<ArtworkType>(),
ordinal ?? _faker.Random.Int(0, 5),
path ?? _faker.System.FilePath());
}
/// <summary>
/// Creates a list of <see cref="MediaArtworkDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<MediaArtworkDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,41 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Common;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.Common;
/// <summary>
/// Fixture class for the <see cref="MoodDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MoodDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="MoodDto"/>.
/// </summary>
/// <param name="name">Optional. The name of the mood.</param>
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="MoodDto"/>.</returns>
public MoodDto Create(
string? name = null,
bool includeName = true)
{
return new MoodDto(includeName ? name ?? _faker.Lorem.Word() : null);
}
/// <summary>
/// Creates a list of <see cref="MoodDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<MoodDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,12 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.Common;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.Common;
/// <summary>
/// Test double deriving from <see cref="MetadataLookupDto"/> for a runtime type other than <see cref="BookMetadataLookupDto"/>.
/// </summary>
[ExcludeFromCodeCoverage]
public sealed record OtherMetadataLookupDto : MetadataLookupDto;
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.Common;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.Common;
/// <summary>
/// Fixture class for the <see cref="OtherMetadataLookupDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class OtherMetadataLookupDtoFixture
{
/// <summary>
/// Creates a <see cref="OtherMetadataLookupDto"/>.
/// </summary>
/// <returns>The created <see cref="OtherMetadataLookupDto"/>.</returns>
public OtherMetadataLookupDto Create()
{
return new OtherMetadataLookupDto();
}
/// <summary>
/// Creates a list of <see cref="OtherMetadataLookupDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<OtherMetadataLookupDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,50 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Common.Pagination;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.Common.Pagination;
/// <summary>
/// Fixture class for the <see cref="PaginationDataDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PaginationDataDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PaginationDataDto"/>.
/// </summary>
/// <param name="currentPage">Optional. The current page number in a paginated collection.</param>
/// <param name="perPage">Optional. The number of items to include per page in paginated results.</param>
/// <param name="includeCurrentPage">Whether the current page should be included, or left at its default value.</param>
/// <param name="includePerPage">Whether the per page count should be included, or left at its default value.</param>
/// <returns>The created <see cref="PaginationDataDto"/>.</returns>
public PaginationDataDto Create(
int? currentPage = null,
int? perPage = null,
bool includeCurrentPage = true,
bool includePerPage = true)
{
PaginationDataDto dto = new();
if (includeCurrentPage)
dto.CurrentPage = currentPage ?? _faker.Random.Int(1, 100);
if (includePerPage)
dto.PerPage = perPage ?? _faker.Random.Int(1, 200);
return dto;
}
/// <summary>
/// Creates a list of <see cref="PaginationDataDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PaginationDataDto"/> instances.</returns>
public List<PaginationDataDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,66 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.Common;
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.Common;
/// <summary>
/// Fixture class for the <see cref="ReleaseInfoDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReleaseInfoDtoFixture
{
/// <summary>
/// Creates a <see cref="ReleaseInfoDto"/>, preserving the values that are not provided as <see langword="null"/>.
/// </summary>
/// <param name="originalReleaseDate">Optional. The original release date of the content.</param>
/// <param name="originalReleaseYear">Optional. The original release year of the content.</param>
/// <param name="reReleaseDate">Optional. The re-release date of the content.</param>
/// <param name="reReleaseYear">Optional. The re-release year of the content.</param>
/// <param name="releaseCountry">Optional. The country where the content was released.</param>
/// <param name="releaseVersion">Optional. The version or edition of the content's release.</param>
/// <param name="includeOriginalReleaseDate">Whether the original release date should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOriginalReleaseYear">Whether the original release year should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeReReleaseDate">Whether the re-release date should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeReReleaseYear">Whether the re-release year should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeReleaseCountry">Whether the release country should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeReleaseVersion">Whether the release version should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="ReleaseInfoDto"/>.</returns>
public ReleaseInfoDto Create(
DateOnly? originalReleaseDate = null,
int? originalReleaseYear = null,
DateOnly? reReleaseDate = null,
int? reReleaseYear = null,
ReleaseCountry? releaseCountry = null,
string? releaseVersion = null,
bool includeOriginalReleaseDate = true,
bool includeOriginalReleaseYear = true,
bool includeReReleaseDate = true,
bool includeReReleaseYear = true,
bool includeReleaseCountry = true,
bool includeReleaseVersion = true)
{
return new ReleaseInfoDto(
includeOriginalReleaseDate ? originalReleaseDate : null,
includeOriginalReleaseYear ? originalReleaseYear : null,
includeReReleaseDate ? reReleaseDate : null,
includeReReleaseYear ? reReleaseYear : null,
includeReleaseCountry ? releaseCountry : null,
includeReleaseVersion ? releaseVersion : null);
}
/// <summary>
/// Creates a list of <see cref="ReleaseInfoDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ReleaseInfoDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,41 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Common;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.Common;
/// <summary>
/// Fixture class for the <see cref="TagDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class TagDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="TagDto"/>.
/// </summary>
/// <param name="name">Optional. The name of the tag.</param>
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="TagDto"/>.</returns>
public TagDto Create(
string? name = null,
bool includeName = true)
{
return new TagDto(includeName ? name ?? _faker.Lorem.Word() : null);
}
/// <summary>
/// Creates a list of <see cref="TagDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<TagDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,44 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.FileSystemManagement;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.FileSystemManagement;
/// <summary>
/// Fixture class for the <see cref="FileSystemItemDto"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class FileSystemItemDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="FileSystemItemDto"/>.
/// </summary>
/// <param name="isHidden">Optional. Whether the file system item is hidden. If not provided, a random value is generated.</param>
/// <returns>The created <see cref="FileSystemItemDto"/>.</returns>
public FileSystemItemDto Create(bool? isHidden = null)
{
return new FileSystemItemDto(
_faker.System.FilePath(),
_faker.System.FileName(),
_faker.Date.Past(),
_faker.Date.Recent(),
isHidden ?? _faker.Random.Bool()
);
}
/// <summary>
/// Creates a list of <see cref="FileSystemItemDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<FileSystemItemDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,60 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
/// <summary>
/// Fixture class for the <see cref="MediaContributorDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaContributorDtoFixture
{
private readonly Faker _faker = new();
private readonly MediaContributorNameDtoFixture _mediaContributorNameDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="MediaContributorDto"/>.
/// </summary>
/// <param name="displayName">Optional. The display name of the media contributor.</param>
/// <param name="role">Optional. The canonical role assigned to the media contributor.</param>
/// <param name="legalName">Optional. The legal name of the media contributor.</param>
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeDisplayName">Whether the display name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLegalName">Whether the legal name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRole">Whether the role should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="MediaContributorDto"/>.</returns>
public MediaContributorDto Create(
string? displayName = null,
MediaContributorRole? role = null,
string? legalName = null,
bool includeName = true,
bool includeDisplayName = true,
bool includeLegalName = true,
bool includeRole = true)
{
return new MediaContributorDto(
Name: includeName ? _mediaContributorNameDtoFixture.Create(
displayName: displayName,
legalName: legalName,
includeDisplayName: includeDisplayName,
// This fixture historically left the legal name null unless one was explicitly supplied, so the name fixture is only asked for one when a value is passed.
includeLegalName: includeLegalName && legalName is not null) : null,
Role: includeRole ? role ?? _faker.PickRandom<MediaContributorRole>() : null);
}
/// <summary>
/// Creates a list of <see cref="MediaContributorDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<MediaContributorDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,47 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaContributors;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
/// <summary>
/// Fixture class for the <see cref="MediaContributorNameDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaContributorNameDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="MediaContributorNameDto"/>.
/// </summary>
/// <param name="displayName">Optional. The display name of the media contributor.</param>
/// <param name="legalName">Optional. The legal name of the media contributor.</param>
/// <param name="includeDisplayName">Whether the display name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLegalName">Whether the legal name should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="MediaContributorNameDto"/>.</returns>
public MediaContributorNameDto Create(
string? displayName = null,
string? legalName = null,
bool includeDisplayName = true,
bool includeLegalName = true)
{
return new MediaContributorNameDto(
includeDisplayName ? displayName ?? _faker.Name.FullName() : null,
includeLegalName ? legalName ?? _faker.Name.FullName() : null);
}
/// <summary>
/// Creates a list of <see cref="MediaContributorNameDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<MediaContributorNameDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
/// <summary>
/// Fixture class for the <see cref="MediaContributorReferenceDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaContributorReferenceDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="MediaContributorReferenceDto"/>.
/// </summary>
/// <param name="contributorId">Optional. The Id of the media contributor.</param>
/// <param name="role">Optional. The role the contributor played.</param>
/// <returns>The created <see cref="MediaContributorReferenceDto"/>.</returns>
public MediaContributorReferenceDto Create(Guid? contributorId = null, MediaContributorRole? role = null)
{
return new MediaContributorReferenceDto(
ContributorId: contributorId ?? Guid.NewGuid(),
Role: role ?? _faker.PickRandom<MediaContributorRole>());
}
/// <summary>
/// Creates a list of <see cref="MediaContributorReferenceDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<MediaContributorReferenceDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,60 @@
#region ========================================================================= USING =====================================================================================
using AutoFixture;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
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.DTO.MediaLibrary.AudioLibrary;
/// <summary>
/// Fixture class for the <see cref="AudioRatingDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AudioRatingDtoFixture
{
private readonly Fixture _fixture = new();
/// <summary>
/// Creates a random valid <see cref="AudioRatingDto"/>.
/// </summary>
/// <param name="value">Optional. The rating value.</param>
/// <param name="maxValue">Optional. The maximum possible rating value.</param>
/// <param name="source">Optional. The rating source.</param>
/// <param name="voteCount">Optional. The number of votes.</param>
/// <param name="includeValue">Whether the rating value should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMaxValue">Whether the maximum possible rating value should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSource">Whether the rating source should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeVoteCount">Whether the number of votes should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="AudioRatingDto"/>.</returns>
public AudioRatingDto Create(
decimal? value = null,
decimal? maxValue = null,
AudioRatingSource? source = null,
int? voteCount = null,
bool includeValue = true,
bool includeMaxValue = true,
bool includeSource = true,
bool includeVoteCount = true)
{
return new AudioRatingDto(
includeValue ? (value ?? Random.Shared.Next(1, 5)) : null,
includeMaxValue ? (maxValue ?? 5) : null,
includeSource ? (source ?? _fixture.Create<AudioRatingSource>()) : null,
includeVoteCount ? (voteCount ?? Random.Shared.Next(1, 1000)) : null
);
}
/// <summary>
/// Creates a list of <see cref="AudioRatingDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<AudioRatingDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,240 @@
#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.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();
private readonly MediaContributorDtoFixture _mediaContributorDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = 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="releaseTitle">Optional. The title of the specific release (edition) of the album.</param>
/// <param name="description">Optional. A brief description or summary of the album.</param>
/// <param name="disambiguation">Optional. The disambiguation comment 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="script">Optional. The script used by the language of the release of the album.</param>
/// <param name="releaseTypes">Optional. The types of the release.</param>
/// <param name="releaseStatus">Optional. The status of the release.</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="totalDiscs">Optional. The number of discs of the release.</param>
/// <param name="totalTracks">Optional. The number of tracks of the release.</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="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="includeDisambiguation">Whether the disambiguation 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="includeScript">Whether the script should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeReleaseTypes">Whether the release types 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="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="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>
/// <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 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 <see cref="AlbumMetadataDto"/>.</returns>
public AlbumMetadataDto Create(
string? title = null,
string? originalTitle = null,
string? releaseTitle = null,
string? description = null,
string? disambiguation = null,
ReleaseInfoDto? releaseInfo = null,
LanguageInfoDto? language = null,
LanguageInfoDto? originalLanguage = null,
List<TagDto>? tags = null,
List<GenreDto>? genres = null,
string? script = null,
List<MusicReleaseType>? releaseTypes = null,
MusicReleaseStatus? releaseStatus = null,
MusicMediaFormat? mediaFormat = null,
MusicReleasePackaging? packaging = null,
int? totalDiscs = null,
int? totalTracks = null,
string? barcode = null,
List<string>? catalogNumbers = null,
string? label = null,
string? asin = null,
Guid? musicBrainzReleaseId = null,
Guid? musicBrainzReleaseGroupId = null,
Guid? musicBrainzReleaseArtistId = null,
List<MediaContributorDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
bool includeTitle = true,
bool includeOriginalTitle = true,
bool includeDescription = true,
bool includeDisambiguation = true,
bool includeReleaseInfo = true,
bool includeLanguage = true,
bool includeOriginalLanguage = true,
bool includeTags = true,
bool includeGenres = true,
bool includeScript = true,
bool includeReleaseTypes = true,
bool includeReleaseStatus = true,
bool includeMediaFormat = true,
bool includePackaging = true,
bool includeTotalDiscs = true,
bool includeTotalTracks = 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 includeReleaseTitle = true)
{
return new AlbumMetadataDto(
includeTitle ? (title ?? _faker.Music.Genre()) : null,
includeOriginalTitle ? (originalTitle ?? _faker.Music.Genre()) : null,
includeDescription ? (description ?? _faker.Lorem.Paragraph()) : null,
includeDisambiguation ? (disambiguation ?? _faker.Lorem.Sentence()) : null,
includeReleaseInfo ? (releaseInfo ?? GenerateReleaseInfo()) : null,
includeLanguage ? (language ?? _languageInfoDtoFixture.Create()) : null,
includeOriginalLanguage ? (originalLanguage ?? _languageInfoDtoFixture.Create()) : null,
includeTags ? (tags ?? GenerateDistinctTags()) : null,
includeGenres ? (genres ?? GenerateDistinctGenres()) : null,
includeScript ? (script ?? _faker.Random.String2(4)) : null,
includeReleaseTypes ? (releaseTypes ?? [_faker.PickRandom<MusicReleaseType>()]) : null,
includeReleaseStatus ? (releaseStatus ?? _faker.PickRandom<MusicReleaseStatus>()) : null,
includeMediaFormat ? (mediaFormat ?? _faker.PickRandom<MusicMediaFormat>()) : null,
includePackaging ? (packaging ?? _faker.PickRandom<MusicReleasePackaging>()) : null,
includeTotalDiscs ? (totalDiscs ?? _faker.Random.Int(1, 3)) : null,
includeTotalTracks ? (totalTracks ?? _faker.Random.Int(1, 30)) : 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 ?? _mediaContributorDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeRatings ? (ratings ?? _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeReleaseTitle ? (releaseTitle ?? _faker.Commerce.ProductName()) : 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}";
}
}
@@ -0,0 +1,62 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
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="AlbumMetadataLookupDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AlbumMetadataLookupDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="AlbumMetadataLookupDto"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the album belongs to.</param>
/// <param name="path">Optional. The file system path of a track of the album.</param>
/// <param name="musicBrainzReleaseGroupId">Optional. The MusicBrainz identifier of the release group of the album.</param>
/// <param name="musicBrainzReleaseId">Optional. The MusicBrainz identifier of the release of the album.</param>
/// <param name="title">Optional. The title of the album.</param>
/// <param name="artistName">Optional. The name of the artist of the album.</param>
/// <param name="releaseYear">Optional. The year the album was released.</param>
/// <param name="trackCount">Optional. The number of tracks the local album has.</param>
/// <returns>The created <see cref="AlbumMetadataLookupDto"/>.</returns>
public AlbumMetadataLookupDto Create(
Guid? libraryId = null,
string? path = null,
Guid? musicBrainzReleaseGroupId = null,
Guid? musicBrainzReleaseId = null,
string? title = null,
string? artistName = null,
int? releaseYear = null,
int? trackCount = null)
{
return new AlbumMetadataLookupDto(
libraryId ?? Guid.NewGuid(),
path ?? _faker.System.FilePath(),
musicBrainzReleaseGroupId,
musicBrainzReleaseId,
title,
artistName,
releaseYear,
trackCount);
}
/// <summary>
/// Creates a list of <see cref="AlbumMetadataLookupDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<AlbumMetadataLookupDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,159 @@
#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.Domain.SharedKernel.Common.Enums.AudioLibrary;
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="ArtistMetadataDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ArtistMetadataDtoFixture
{
private const int MINIMUM_LIFESPAN_YEAR = 1900;
private const int MAXIMUM_LIFESPAN_YEAR = 2026;
private readonly Faker _faker = new();
private readonly GenreDtoFixture _genreDtoFixture = new();
private readonly TagDtoFixture _tagDtoFixture = new();
private readonly MusicAreaDtoFixture _musicAreaDtoFixture = new();
private readonly MusicArtistAliasDtoFixture _musicArtistAliasDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
private readonly MediaContributorDtoFixture _mediaContributorDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="ArtistMetadataDto"/>.
/// </summary>
/// <param name="name">Optional. The name of the artist.</param>
/// <param name="sortName">Optional. The sort name of the artist.</param>
/// <param name="disambiguation">Optional. The disambiguation comment of the artist.</param>
/// <param name="type">Optional. The type of the artist.</param>
/// <param name="gender">Optional. The gender of the artist.</param>
/// <param name="country">Optional. The ISO 3166-1 alpha-2 code of the country of the artist.</param>
/// <param name="area">Optional. The area the artist is primarily identified with.</param>
/// <param name="beginArea">Optional. The area the artist began in.</param>
/// <param name="endArea">Optional. The area the artist ended in.</param>
/// <param name="lifeSpanBegin">Optional. The date the artist started existing.</param>
/// <param name="lifeSpanEnd">Optional. The date the artist stopped existing.</param>
/// <param name="isEnded">Optional. Whether the artist no longer exists.</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="aliases">Optional. The alternative names of the artist.</param>
/// <param name="genres">Optional. The genres associated with the artist.</param>
/// <param name="tags">Optional. The tags that describe or categorize the artist.</param>
/// <param name="ratings">Optional. The ratings of the artist.</param>
/// <param name="contributors">Optional. The media contributors that make up the artist.</param>
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSortName">Whether the sort name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeDisambiguation">Whether the disambiguation should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeType">Whether the type should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGender">Whether the gender should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeCountry">Whether the country should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArea">Whether the area should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBeginArea">Whether the begin area should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeEndArea">Whether the end area should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLifeSpanBegin">Whether the lifespan begin should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLifeSpanEnd">Whether the lifespan end 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="includeGenres">Whether the genres 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="includeAliases">Whether the aliases 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 <see cref="ArtistMetadataDto"/>.</returns>
public ArtistMetadataDto Create(
string? name = null,
string? sortName = null,
string? disambiguation = null,
MusicArtistType? type = null,
MusicArtistGender? gender = null,
string? country = null,
MusicAreaDto? area = null,
MusicAreaDto? beginArea = null,
MusicAreaDto? endArea = null,
DateOnly? lifeSpanBegin = null,
DateOnly? lifeSpanEnd = null,
bool? isEnded = null,
string? website = null,
Guid? musicBrainzArtistId = null,
List<string>? ipis = null,
List<string>? isnis = null,
List<MusicArtistAliasDto>? aliases = null,
List<GenreDto>? genres = null,
List<TagDto>? tags = null,
List<AudioRatingDto>? ratings = null,
List<MediaContributorDto>? contributors = null,
bool includeName = true,
bool includeSortName = true,
bool includeDisambiguation = true,
bool includeType = true,
bool includeGender = true,
bool includeCountry = true,
bool includeArea = true,
bool includeBeginArea = true,
bool includeEndArea = true,
bool includeLifeSpanBegin = true,
bool includeLifeSpanEnd = true,
bool includeWebsite = true,
bool includeMusicBrainzArtistId = true,
bool includeIpis = true,
bool includeIsnis = true,
bool includeGenres = true,
bool includeTags = true,
bool includeAliases = true,
bool includeRatings = true,
bool includeContributors = true)
{
int lifeSpanBeginYear = Random.Shared.Next(MINIMUM_LIFESPAN_YEAR, MAXIMUM_LIFESPAN_YEAR);
int lifeSpanEndYear = Random.Shared.Next(lifeSpanBeginYear, Math.Max(lifeSpanBeginYear + 1, MAXIMUM_LIFESPAN_YEAR));
return new ArtistMetadataDto(
includeName ? (name ?? _faker.Name.FullName()) : null,
includeSortName ? (sortName ?? _faker.Name.FullName()) : null,
includeDisambiguation ? (disambiguation ?? _faker.Lorem.Sentence()) : null,
includeType ? (type ?? _faker.PickRandom<MusicArtistType>()) : null,
includeGender ? (gender ?? _faker.PickRandom<MusicArtistGender>()) : null,
includeCountry ? (country ?? _faker.Address.CountryCode()) : null,
includeArea ? (area ?? _musicAreaDtoFixture.Create()) : null,
includeBeginArea ? (beginArea ?? _musicAreaDtoFixture.Create()) : null,
includeEndArea ? (endArea ?? _musicAreaDtoFixture.Create()) : null,
includeLifeSpanBegin ? (lifeSpanBegin ?? new DateOnly(lifeSpanBeginYear, 1, 1)) : null,
includeLifeSpanEnd ? (lifeSpanEnd ?? new DateOnly(lifeSpanEndYear, 1, 1)) : null,
isEnded ?? _faker.Random.Bool(),
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,
includeAliases ? (aliases ?? _musicArtistAliasDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeGenres ? (genres ?? _genreDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeTags ? (tags ?? _tagDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeRatings ? (ratings ?? _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeContributors ? (contributors ?? _mediaContributorDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null);
}
/// <summary>
/// Creates a list of <see cref="ArtistMetadataDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ArtistMetadataDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,50 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
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="ArtistMetadataLookupDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ArtistMetadataLookupDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ArtistMetadataLookupDto"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the artist belongs to.</param>
/// <param name="path">Optional. The file system path of a track of the artist.</param>
/// <param name="musicBrainzArtistId">Optional. The MusicBrainz identifier of the artist.</param>
/// <param name="name">Optional. The name of the artist.</param>
/// <returns>The created <see cref="ArtistMetadataLookupDto"/>.</returns>
public ArtistMetadataLookupDto Create(
Guid? libraryId = null,
string? path = null,
Guid? musicBrainzArtistId = null,
string? name = null)
{
return new ArtistMetadataLookupDto(
libraryId ?? Guid.NewGuid(),
path ?? _faker.System.FilePath(),
musicBrainzArtistId,
name);
}
/// <summary>
/// Creates a list of <see cref="ArtistMetadataLookupDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ArtistMetadataLookupDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,247 @@
#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.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="AudioMetadataDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class AudioMetadataDtoFixture
{
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();
private readonly MusicWorkDtoFixture _musicWorkDtoFixture = new();
private readonly IsrcDtoFixture _isrcDtoFixture = new();
private readonly MoodDtoFixture _moodDtoFixture = new();
private readonly MediaContributorDtoFixture _mediaContributorDtoFixture = new();
private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="AudioMetadataDto"/>.
/// </summary>
/// <param name="title">Optional. The title of the audio.</param>
/// <param name="originalTitle">Optional. The original title of the audio.</param>
/// <param name="description">Optional. A brief description or summary of the audio.</param>
/// <param name="disambiguation">Optional. The disambiguation comment of the audio.</param>
/// <param name="releaseInfo">Optional. The release information of the audio.</param>
/// <param name="language">Optional. The language of the audio.</param>
/// <param name="originalLanguage">Optional. The original language of the audio.</param>
/// <param name="tags">Optional. The tags that describe or categorize the audio.</param>
/// <param name="genres">Optional. The genres associated with the audio.</param>
/// <param name="script">Optional. The script used by the language of the audio.</param>
/// <param name="key">Optional. The musical key of the audio.</param>
/// <param name="bpm">Optional. The tempo of the audio, in beats per minute.</param>
/// <param name="isVideo">Optional. Whether the recording of the audio is a video recording.</param>
/// <param name="work">Optional. The work the audio is a recording of.</param>
/// <param name="isrcs">Optional. The ISRC codes of the audio.</param>
/// <param name="moods">Optional. The moods of the audio.</param>
/// <param name="durationInSeconds">Optional. The duration of the audio, in seconds.</param>
/// <param name="sampleRate">Optional. The sample rate of the audio, in Hz.</param>
/// <param name="channels">Optional. The number of audio channels.</param>
/// <param name="bitDepth">Optional. The bit depth of the audio.</param>
/// <param name="audioCodec">Optional. The audio codec used.</param>
/// <param name="container">Optional. The container of the audio file.</param>
/// <param name="bitrate">Optional. The bitrate of the audio, in kbps.</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="contributors">Optional. The media contributors that performed on the audio.</param>
/// <param name="ratings">Optional. The ratings of the audio.</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="includeDisambiguation">Whether the disambiguation 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="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="includeIsrcs">Whether the ISRC codes 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="includeDurationInSeconds">Whether the duration should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSampleRate">Whether the sample rate should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeChannels">Whether the channels should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBitDepth">Whether the bit depth should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAudioCodec">Whether the audio codec should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContainer">Whether the container should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBitrate">Whether the bitrate 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="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 <see cref="AudioMetadataDto"/>.</returns>
public AudioMetadataDto Create(
string? title = null,
string? originalTitle = null,
string? description = null,
string? disambiguation = null,
ReleaseInfoDto? releaseInfo = null,
LanguageInfoDto? language = null,
LanguageInfoDto? originalLanguage = null,
List<TagDto>? tags = null,
List<GenreDto>? genres = null,
string? script = null,
MusicKey? key = null,
int? bpm = null,
bool? isVideo = null,
MusicWorkDto? work = null,
List<IsrcDto>? isrcs = null,
List<MoodDto>? moods = null,
int? durationInSeconds = null,
int? sampleRate = null,
int? channels = null,
int? bitDepth = null,
string? audioCodec = null,
string? container = null,
int? bitrate = null,
Guid? musicBrainzRecordingId = null,
Guid? musicBrainzTrackId = null,
List<MediaContributorDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
bool includeTitle = true,
bool includeOriginalTitle = true,
bool includeDescription = true,
bool includeDisambiguation = true,
bool includeReleaseInfo = true,
bool includeLanguage = true,
bool includeOriginalLanguage = true,
bool includeTags = true,
bool includeGenres = true,
bool includeScript = true,
bool includeKey = true,
bool includeBpm = true,
bool includeWork = true,
bool includeIsrcs = true,
bool includeMoods = true,
bool includeDurationInSeconds = true,
bool includeSampleRate = true,
bool includeChannels = true,
bool includeBitDepth = true,
bool includeAudioCodec = true,
bool includeContainer = true,
bool includeBitrate = true,
bool includeMusicBrainzRecordingId = true,
bool includeMusicBrainzTrackId = true,
bool includeContributors = true,
bool includeRatings = true)
{
return new AudioMetadataDto(
includeTitle ? (title ?? _faker.Music.Genre()) : null,
includeOriginalTitle ? (originalTitle ?? _faker.Music.Genre()) : null,
includeDescription ? (description ?? _faker.Lorem.Paragraph()) : null,
includeDisambiguation ? (disambiguation ?? _faker.Lorem.Sentence()) : null,
includeReleaseInfo ? (releaseInfo ?? GenerateReleaseInfo()) : null,
includeLanguage ? (language ?? _languageInfoDtoFixture.Create()) : null,
includeOriginalLanguage ? (originalLanguage ?? _languageInfoDtoFixture.Create()) : null,
includeTags ? (tags ?? GenerateDistinctTags()) : null,
includeGenres ? (genres ?? GenerateDistinctGenres()) : null,
includeScript ? (script ?? _faker.Random.String2(4)) : null,
includeKey ? (key ?? _faker.PickRandom<MusicKey>()) : null,
includeBpm ? (bpm ?? _faker.Random.Int(40, 220)) : null,
isVideo ?? _faker.Random.Bool(),
includeWork ? (work ?? _musicWorkDtoFixture.Create()) : null,
includeIsrcs ? (isrcs ?? _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeMoods ? (moods ?? _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeDurationInSeconds ? (durationInSeconds ?? _faker.Random.Int(60, 7200)) : null,
includeSampleRate ? (sampleRate ?? _faker.Random.Int(8000, 192000)) : null,
includeChannels ? (channels ?? _faker.Random.Int(1, 8)) : null,
includeBitDepth ? (bitDepth ?? _faker.Random.Int(8, 32)) : null,
includeAudioCodec ? (audioCodec ?? _faker.Random.ArrayElement(["FLAC", "MP3", "AAC", "ALAC"])) : null,
includeContainer ? (container ?? _faker.Random.ArrayElement(["MP3", "FLAC", "OGG", "MP4", "AAC", "WAV"])) : null,
includeBitrate ? (bitrate ?? _faker.Random.Int(96, 1411)) : null,
includeMusicBrainzRecordingId ? (musicBrainzRecordingId ?? _faker.Random.Guid()) : null,
includeMusicBrainzTrackId ? (musicBrainzTrackId ?? _faker.Random.Guid()) : null,
includeContributors ? (contributors ?? _mediaContributorDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeRatings ? (ratings ?? _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null);
}
/// <summary>
/// Creates a list of <see cref="AudioMetadataDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<AudioMetadataDto> 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}";
}
}
@@ -0,0 +1,56 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
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="IsrcDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class IsrcDtoFixture
{
private const string LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private const string ALPHANUMERICS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
private const string DIGITS = "0123456789";
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="IsrcDto"/>.
/// </summary>
/// <param name="value">Optional. The value of the ISRC.</param>
/// <param name="includeValue">Whether the value should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="IsrcDto"/>.</returns>
public IsrcDto Create(
string? value = null,
bool includeValue = true)
{
return new IsrcDto(includeValue ? value ?? GenerateValidIsrc() : null);
}
/// <summary>
/// Creates a list of <see cref="IsrcDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<IsrcDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Generates a random ISRC that satisfies the domain format: two letters, three alphanumeric characters and seven digits.
/// </summary>
/// <returns>The generated ISRC value.</returns>
private string GenerateValidIsrc()
{
return _faker.Random.String2(2, LETTERS)
+ _faker.Random.String2(3, ALPHANUMERICS)
+ _faker.Random.String2(7, DIGITS);
}
}
@@ -0,0 +1,179 @@
#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="MusicAlbumMetadataDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MusicAlbumMetadataDtoFixture
{
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="MusicAlbumMetadataDto"/>.
/// </summary>
/// <param name="title">Optional. The title of the album.</param>
/// <param name="originalTitle">Optional. The original title of the album.</param>
/// <param name="releaseTitle">Optional. The title of the specific release (edition) of the album.</param>
/// <param name="description">Optional. A brief description or summary of the album.</param>
/// <param name="disambiguation">Optional. The disambiguation comment 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="script">Optional. The script used by the language of the release of the album.</param>
/// <param name="releaseTypes">Optional. The types 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="includeDisambiguation">Whether the disambiguation 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="includeScript">Whether the script should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeReleaseTypes">Whether the release types 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="MusicAlbumMetadataDto"/>.</returns>
public MusicAlbumMetadataDto Create(
string? title = null,
string? originalTitle = null,
string? releaseTitle = null,
string? description = null,
string? disambiguation = null,
ReleaseInfoDto? releaseInfo = null,
LanguageInfoDto? language = null,
LanguageInfoDto? originalLanguage = null,
List<TagDto>? tags = null,
List<GenreDto>? genres = null,
string? script = null,
List<MusicReleaseType>? releaseTypes = null,
MusicReleaseStatus? releaseStatus = null,
int? totalDiscs = null,
int? totalTracks = null,
bool includeTitle = true,
bool includeOriginalTitle = true,
bool includeDescription = true,
bool includeDisambiguation = true,
bool includeReleaseInfo = true,
bool includeLanguage = true,
bool includeOriginalLanguage = true,
bool includeTags = true,
bool includeGenres = true,
bool includeScript = true,
bool includeReleaseTypes = true,
bool includeReleaseStatus = true,
bool includeTotalDiscs = true,
bool includeTotalTracks = true,
bool includeReleaseTitle = true)
{
return new MusicAlbumMetadataDto(
includeTitle ? (title ?? _faker.Music.Genre()) : null,
includeOriginalTitle ? (originalTitle ?? _faker.Music.Genre()) : null,
includeDescription ? (description ?? _faker.Lorem.Paragraph()) : null,
includeDisambiguation ? (disambiguation ?? _faker.Lorem.Sentence()) : null,
includeReleaseInfo ? (releaseInfo ?? GenerateReleaseInfo()) : null,
includeLanguage ? (language ?? _languageInfoDtoFixture.Create()) : null,
includeOriginalLanguage ? (originalLanguage ?? _languageInfoDtoFixture.Create()) : null,
includeTags ? (tags ?? GenerateDistinctTags()) : null,
includeGenres ? (genres ?? GenerateDistinctGenres()) : null,
includeScript ? (script ?? _faker.Random.String2(4)) : null,
includeReleaseTypes ? (releaseTypes ?? [_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,
includeReleaseTitle ? (releaseTitle ?? _faker.Commerce.ProductName()) : null);
}
/// <summary>
/// Creates a list of <see cref="MusicAlbumMetadataDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<MusicAlbumMetadataDto> 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}";
}
}
@@ -0,0 +1,68 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
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="MusicAreaDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MusicAreaDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="MusicAreaDto"/>.
/// </summary>
/// <param name="musicBrainzAreaId">Optional. The MusicBrainz identifier of the area.</param>
/// <param name="name">Optional. The name of the area.</param>
/// <param name="sortName">Optional. The sort name of the area.</param>
/// <param name="disambiguation">Optional. The disambiguation comment of the area.</param>
/// <param name="type">Optional. The MusicBrainz type of the area.</param>
/// <param name="iso3166Code">Optional. The ISO 3166 code of the area.</param>
/// <param name="includeMusicBrainzAreaId">Whether the MusicBrainz area Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSortName">Whether the sort name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeDisambiguation">Whether the disambiguation should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeType">Whether the type should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIso3166Code">Whether the ISO 3166 code should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="MusicAreaDto"/>.</returns>
public MusicAreaDto Create(
Guid? musicBrainzAreaId = null,
string? name = null,
string? sortName = null,
string? disambiguation = null,
string? type = null,
string? iso3166Code = null,
bool includeMusicBrainzAreaId = true,
bool includeName = true,
bool includeSortName = true,
bool includeDisambiguation = true,
bool includeType = true,
bool includeIso3166Code = true)
{
return new MusicAreaDto(
includeMusicBrainzAreaId ? (musicBrainzAreaId ?? _faker.Random.Guid()) : null,
includeName ? (name ?? _faker.Address.Country()) : null,
includeSortName ? (sortName ?? _faker.Address.Country()) : null,
includeDisambiguation ? (disambiguation ?? _faker.Lorem.Sentence()) : null,
includeType ? (type ?? _faker.Random.ArrayElement(["Country", "City", "Area"])) : null,
includeIso3166Code ? (iso3166Code ?? _faker.Address.CountryCode()) : null);
}
/// <summary>
/// Creates a list of <see cref="MusicAreaDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<MusicAreaDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,79 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
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="MusicArtistAliasDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MusicArtistAliasDtoFixture
{
private const int MINIMUM_ALIAS_YEAR = 1900;
private const int MAXIMUM_ALIAS_YEAR = 2026;
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="MusicArtistAliasDto"/>.
/// </summary>
/// <param name="name">Optional. The name of the alias.</param>
/// <param name="sortName">Optional. The sort name of the alias.</param>
/// <param name="type">Optional. The type of the alias.</param>
/// <param name="locale">Optional. The locale the alias is used in.</param>
/// <param name="isPrimary">Optional. Whether this is the primary alias of the artist.</param>
/// <param name="beginDate">Optional. The date the alias began being used.</param>
/// <param name="endDate">Optional. The date the alias stopped being used.</param>
/// <param name="isEnded">Optional. Whether the alias is no longer used.</param>
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSortName">Whether the sort name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeType">Whether the type should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLocale">Whether the locale should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBeginDate">Whether the begin date should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeEndDate">Whether the end date should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="MusicArtistAliasDto"/>.</returns>
public MusicArtistAliasDto Create(
string? name = null,
string? sortName = null,
string? type = null,
string? locale = null,
bool? isPrimary = null,
DateOnly? beginDate = null,
DateOnly? endDate = null,
bool? isEnded = null,
bool includeName = true,
bool includeSortName = true,
bool includeType = true,
bool includeLocale = true,
bool includeBeginDate = true,
bool includeEndDate = true)
{
int beginYear = Random.Shared.Next(MINIMUM_ALIAS_YEAR, MAXIMUM_ALIAS_YEAR);
int endYear = Random.Shared.Next(beginYear, Math.Max(beginYear + 1, MAXIMUM_ALIAS_YEAR));
return new MusicArtistAliasDto(
includeName ? (name ?? _faker.Name.FullName()) : null,
includeSortName ? (sortName ?? _faker.Name.FullName()) : null,
includeType ? (type ?? _faker.Random.ArrayElement(["Artist name", "Search hint"])) : null,
includeLocale ? (locale ?? _faker.Random.String2(2)) : null,
isPrimary ?? _faker.Random.Bool(),
includeBeginDate ? (beginDate ?? new DateOnly(beginYear, 1, 1)) : null,
includeEndDate ? (endDate ?? new DateOnly(endYear, 1, 1)) : null,
isEnded ?? _faker.Random.Bool());
}
/// <summary>
/// Creates a list of <see cref="MusicArtistAliasDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<MusicArtistAliasDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,123 @@
#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 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="MusicArtistMetadataDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MusicArtistMetadataDtoFixture
{
private const int MINIMUM_LIFESPAN_YEAR = 1900;
private const int MAXIMUM_LIFESPAN_YEAR = 2026;
private readonly Faker _faker = new();
private readonly GenreDtoFixture _genreDtoFixture = new();
private readonly TagDtoFixture _tagDtoFixture = new();
private readonly MusicAreaDtoFixture _musicAreaDtoFixture = new();
private readonly MusicArtistAliasDtoFixture _musicArtistAliasDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="MusicArtistMetadataDto"/>.
/// </summary>
/// <param name="name">Optional. The name of the artist.</param>
/// <param name="sortName">Optional. The sort name of the artist.</param>
/// <param name="disambiguation">Optional. The disambiguation comment of the artist.</param>
/// <param name="type">Optional. The type of the artist.</param>
/// <param name="gender">Optional. The gender of the artist.</param>
/// <param name="country">Optional. The ISO 3166-1 alpha-2 code of the country of the artist.</param>
/// <param name="area">Optional. The area the artist is primarily identified with.</param>
/// <param name="beginArea">Optional. The area the artist began in.</param>
/// <param name="endArea">Optional. The area the artist ended in.</param>
/// <param name="lifeSpanBegin">Optional. The date the artist started existing.</param>
/// <param name="lifeSpanEnd">Optional. The date the artist stopped existing.</param>
/// <param name="isEnded">Optional. Whether the artist no longer exists.</param>
/// <param name="genres">Optional. The genres associated with the artist.</param>
/// <param name="tags">Optional. The tags that describe or categorize the artist.</param>
/// <param name="aliases">Optional. The alternative names of the artist.</param>
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSortName">Whether the sort name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeDisambiguation">Whether the disambiguation should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeType">Whether the type should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGender">Whether the gender should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeCountry">Whether the country should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeArea">Whether the area should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBeginArea">Whether the begin area should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeEndArea">Whether the end area should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLifeSpanBegin">Whether the lifespan begin should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLifeSpanEnd">Whether the lifespan end 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="includeTags">Whether the tags should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAliases">Whether the aliases should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="MusicArtistMetadataDto"/>.</returns>
public MusicArtistMetadataDto Create(
string? name = null,
string? sortName = null,
string? disambiguation = null,
MusicArtistType? type = null,
MusicArtistGender? gender = null,
string? country = null,
MusicAreaDto? area = null,
MusicAreaDto? beginArea = null,
MusicAreaDto? endArea = null,
DateOnly? lifeSpanBegin = null,
DateOnly? lifeSpanEnd = null,
bool? isEnded = null,
List<GenreDto>? genres = null,
List<TagDto>? tags = null,
List<MusicArtistAliasDto>? aliases = null,
bool includeName = true,
bool includeSortName = true,
bool includeDisambiguation = true,
bool includeType = true,
bool includeGender = true,
bool includeCountry = true,
bool includeArea = true,
bool includeBeginArea = true,
bool includeEndArea = true,
bool includeLifeSpanBegin = true,
bool includeLifeSpanEnd = true,
bool includeGenres = true,
bool includeTags = true,
bool includeAliases = true)
{
int lifeSpanBeginYear = Random.Shared.Next(MINIMUM_LIFESPAN_YEAR, MAXIMUM_LIFESPAN_YEAR);
int lifeSpanEndYear = Random.Shared.Next(lifeSpanBeginYear, Math.Max(lifeSpanBeginYear + 1, MAXIMUM_LIFESPAN_YEAR));
return new MusicArtistMetadataDto(
includeName ? (name ?? _faker.Name.FullName()) : null,
includeSortName ? (sortName ?? _faker.Name.FullName()) : null,
includeDisambiguation ? (disambiguation ?? _faker.Lorem.Sentence()) : null,
includeType ? (type ?? _faker.PickRandom<MusicArtistType>()) : null,
includeGender ? (gender ?? _faker.PickRandom<MusicArtistGender>()) : null,
includeCountry ? (country ?? _faker.Address.CountryCode()) : null,
includeArea ? (area ?? _musicAreaDtoFixture.Create()) : null,
includeBeginArea ? (beginArea ?? _musicAreaDtoFixture.Create()) : null,
includeEndArea ? (endArea ?? _musicAreaDtoFixture.Create()) : null,
includeLifeSpanBegin ? (lifeSpanBegin ?? new DateOnly(lifeSpanBeginYear, 1, 1)) : null,
includeLifeSpanEnd ? (lifeSpanEnd ?? new DateOnly(lifeSpanEndYear, 1, 1)) : null,
isEnded ?? _faker.Random.Bool(),
includeGenres ? (genres ?? _genreDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeTags ? (tags ?? _tagDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null,
includeAliases ? (aliases ?? _musicArtistAliasDtoFixture.CreateMany(_faker.Random.Int(1, 3))) : null);
}
/// <summary>
/// Creates a list of <see cref="MusicArtistMetadataDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<MusicArtistMetadataDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,182 @@
#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.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="MusicTrackMetadataDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MusicTrackMetadataDtoFixture
{
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="MusicTrackMetadataDto"/>.
/// </summary>
/// <param name="title">Optional. The title of the track.</param>
/// <param name="originalTitle">Optional. The original title of the track.</param>
/// <param name="description">Optional. A brief description or summary of the track.</param>
/// <param name="disambiguation">Optional. The disambiguation comment of the track.</param>
/// <param name="releaseInfo">Optional. The release information of the track.</param>
/// <param name="language">Optional. The language of the track.</param>
/// <param name="originalLanguage">Optional. The original language of the track.</param>
/// <param name="tags">Optional. The tags that describe or categorize the track.</param>
/// <param name="genres">Optional. The genres associated with the track.</param>
/// <param name="isVideo">Optional. Whether the recording of the track is a video recording.</param>
/// <param name="durationInSeconds">Optional. The duration of the track, in seconds.</param>
/// <param name="sampleRate">Optional. The sample rate of the track, in Hz.</param>
/// <param name="channels">Optional. The number of audio channels.</param>
/// <param name="bitDepth">Optional. The bit depth of the track.</param>
/// <param name="audioCodec">Optional. The audio codec used.</param>
/// <param name="bitrate">Optional. The bitrate of the track, in kbps.</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="includeDisambiguation">Whether the disambiguation 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="includeDurationInSeconds">Whether the duration should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSampleRate">Whether the sample rate should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeChannels">Whether the channels should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBitDepth">Whether the bit depth should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAudioCodec">Whether the audio codec should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBitrate">Whether the bitrate should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="MusicTrackMetadataDto"/>.</returns>
public MusicTrackMetadataDto Create(
string? title = null,
string? originalTitle = null,
string? description = null,
string? disambiguation = null,
ReleaseInfoDto? releaseInfo = null,
LanguageInfoDto? language = null,
LanguageInfoDto? originalLanguage = null,
List<TagDto>? tags = null,
List<GenreDto>? genres = null,
bool? isVideo = null,
int? durationInSeconds = null,
int? sampleRate = null,
int? channels = null,
int? bitDepth = null,
string? audioCodec = null,
int? bitrate = null,
bool includeTitle = true,
bool includeOriginalTitle = true,
bool includeDescription = true,
bool includeDisambiguation = true,
bool includeReleaseInfo = true,
bool includeLanguage = true,
bool includeOriginalLanguage = true,
bool includeTags = true,
bool includeGenres = true,
bool includeDurationInSeconds = true,
bool includeSampleRate = true,
bool includeChannels = true,
bool includeBitDepth = true,
bool includeAudioCodec = true,
bool includeBitrate = true)
{
return new MusicTrackMetadataDto(
includeTitle ? (title ?? _faker.Music.Genre()) : null,
includeOriginalTitle ? (originalTitle ?? _faker.Music.Genre()) : null,
includeDescription ? (description ?? _faker.Lorem.Paragraph()) : null,
includeDisambiguation ? (disambiguation ?? _faker.Lorem.Sentence()) : null,
includeReleaseInfo ? (releaseInfo ?? GenerateReleaseInfo()) : null,
includeLanguage ? (language ?? _languageInfoDtoFixture.Create()) : null,
includeOriginalLanguage ? (originalLanguage ?? _languageInfoDtoFixture.Create()) : null,
includeTags ? (tags ?? GenerateDistinctTags()) : null,
includeGenres ? (genres ?? GenerateDistinctGenres()) : null,
isVideo ?? _faker.Random.Bool(),
includeDurationInSeconds ? (durationInSeconds ?? _faker.Random.Int(60, 7200)) : null,
includeSampleRate ? (sampleRate ?? _faker.Random.Int(8000, 192000)) : null,
includeChannels ? (channels ?? _faker.Random.Int(1, 8)) : null,
includeBitDepth ? (bitDepth ?? _faker.Random.Int(8, 32)) : null,
includeAudioCodec ? (audioCodec ?? _faker.Random.ArrayElement(["FLAC", "MP3", "AAC", "ALAC"])) : null,
includeBitrate ? (bitrate ?? _faker.Random.Int(96, 1411)) : null);
}
/// <summary>
/// Creates a list of <see cref="MusicTrackMetadataDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<MusicTrackMetadataDto> 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}";
}
}
@@ -0,0 +1,75 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.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="MusicWorkDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MusicWorkDtoFixture
{
private readonly Faker _faker = new();
private readonly LanguageInfoDtoFixture _languageInfoDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="MusicWorkDto"/>.
/// </summary>
/// <param name="musicBrainzWorkId">Optional. The MusicBrainz identifier of the work.</param>
/// <param name="title">Optional. The title of the work.</param>
/// <param name="type">Optional. The MusicBrainz type of the work.</param>
/// <param name="languages">Optional. The list of languages of the work.</param>
/// <param name="iswcs">Optional. The list of ISWC of the work.</param>
/// <param name="includeMusicBrainzWorkId">Whether the MusicBrainz work Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTitle">Whether the title should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeType">Whether the type should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLanguages">Whether the languages should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIswcs">Whether the ISWCs should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="MusicWorkDto"/>.</returns>
public MusicWorkDto Create(
Guid? musicBrainzWorkId = null,
string? title = null,
string? type = null,
List<LanguageInfoDto>? languages = null,
List<string>? iswcs = null,
bool includeMusicBrainzWorkId = true,
bool includeTitle = true,
bool includeType = true,
bool includeLanguages = true,
bool includeIswcs = true)
{
return new MusicWorkDto(
includeMusicBrainzWorkId ? (musicBrainzWorkId ?? _faker.Random.Guid()) : null,
includeTitle ? (title ?? _faker.Music.Genre()) : null,
includeType ? (type ?? _faker.Random.ArrayElement(["Song", "Instrumental"])) : null,
includeLanguages ? (languages ?? _languageInfoDtoFixture.CreateMany(_faker.Random.Int(1, 2))) : null,
includeIswcs ? (iswcs ?? GenerateIswcs()) : null);
}
/// <summary>
/// Creates a list of <see cref="MusicWorkDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<MusicWorkDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Creates a list of random ISWC codes.
/// </summary>
/// <returns>The generated ISWC codes.</returns>
private List<string> GenerateIswcs()
{
return [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => $"T{_faker.Random.AlphaNumeric(10)}")];
}
}
@@ -0,0 +1,77 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
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="TrackMetadataLookupDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class TrackMetadataLookupDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="TrackMetadataLookupDto"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the track belongs to.</param>
/// <param name="path">Optional. The file system path of the track.</param>
/// <param name="musicBrainzRecordingId">Optional. The MusicBrainz identifier of the recording of the track.</param>
/// <param name="isrc">Optional. The ISRC of the track.</param>
/// <param name="title">Optional. The title of the track.</param>
/// <param name="artistName">Optional. The name of the artist of the track.</param>
/// <param name="releaseName">Optional. The name of the release the track belongs to.</param>
/// <param name="trackNumber">Optional. The number of the track on its disc.</param>
/// <param name="durationInSeconds">Optional. The duration of the track in seconds.</param>
/// <param name="musicBrainzReleaseId">Optional. The MusicBrainz identifier of the release the track belongs to.</param>
/// <param name="discNumber">Optional. The number of the disc the track belongs to.</param>
/// <param name="musicBrainzWorkId">Optional. The MusicBrainz identifier of the work the track is a recording of.</param>
/// <param name="workTitle">Optional. The title of the work the track is a recording of.</param>
/// <returns>The created <see cref="TrackMetadataLookupDto"/>.</returns>
public TrackMetadataLookupDto Create(
Guid? libraryId = null,
string? path = null,
Guid? musicBrainzRecordingId = null,
string? isrc = null,
string? title = null,
string? artistName = null,
string? releaseName = null,
int? trackNumber = null,
int? durationInSeconds = null,
Guid? musicBrainzReleaseId = null,
int? discNumber = null,
Guid? musicBrainzWorkId = null,
string? workTitle = null)
{
return new TrackMetadataLookupDto(
libraryId ?? Guid.NewGuid(),
path ?? _faker.System.FilePath(),
musicBrainzRecordingId,
isrc,
title,
artistName,
releaseName,
trackNumber,
durationInSeconds,
musicBrainzReleaseId,
discNumber,
musicBrainzWorkId,
workTitle);
}
/// <summary>
/// Creates a list of <see cref="TrackMetadataLookupDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<TrackMetadataLookupDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,54 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.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.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
/// <summary>
/// Fixture class for the <see cref="TrackStreamDataDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class TrackStreamDataDtoFixture
{
private static readonly AudioFileFormat[] s_audioFileFormats = [AudioFileFormat.MP3, AudioFileFormat.FLAC, AudioFileFormat.OGG, AudioFileFormat.WAV];
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="TrackStreamDataDto"/>.
/// </summary>
/// <param name="path">Optional. The file system path of the audio file of the track.</param>
/// <param name="format">Optional. The file format of the audio file of the track.</param>
/// <param name="length">Optional. The length of the audio file of the track, in bytes.</param>
/// <param name="lastModified">Optional. The date and time when the audio file of the track was last modified.</param>
/// <returns>The created <see cref="TrackStreamDataDto"/>.</returns>
public TrackStreamDataDto Create(
string? path = null,
AudioFileFormat? format = null,
long? length = null,
DateTimeOffset? lastModified = null)
{
return new TrackStreamDataDto(
path ?? Path.Combine(_faker.System.DirectoryPath(), _faker.System.FileName("mp3")),
format ?? _faker.PickRandom(s_audioFileFormats),
length ?? _faker.Random.Long(1, 10_000_000),
lastModified ?? _faker.Date.PastOffset());
}
/// <summary>
/// Creates a list of <see cref="TrackStreamDataDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="TrackStreamDataDto"/> instances.</returns>
public List<TrackStreamDataDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,146 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.Common;
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
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.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Fixture class for the <see cref="BookMetadataDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class BookMetadataDtoFixture
{
private readonly Faker _faker = new();
private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new();
private readonly GenreDtoFixture _genreDtoFixture = new();
private readonly TagDtoFixture _tagDtoFixture = new();
private readonly LanguageInfoDtoFixture _languageInfoDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="BookMetadataDto"/>.
/// </summary>
/// <param name="title">Optional. The title of the book.</param>
/// <param name="originalTitle">Optional. The original title of the book.</param>
/// <param name="description">Optional. A brief description or summary of the book.</param>
/// <param name="releaseInfo">Optional. The release information of the book.</param>
/// <param name="genres">Optional. The genres of the book.</param>
/// <param name="tags">Optional. The tags of the book.</param>
/// <param name="language">Optional. The language of the book.</param>
/// <param name="originalLanguage">Optional. The original language of the book.</param>
/// <param name="publisher">Optional. The name of the publisher of the book.</param>
/// <param name="pageCount">Optional. The number of pages in 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="coverImagePath">Optional. The path of the cover image of the book.</param>
/// <param name="includeTitle">Whether the title should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeReleaseInfo">Whether the release info 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="includeTags">Whether the tags 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="includeFormat">Whether the format 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>
/// <returns>The created <see cref="BookMetadataDto"/>.</returns>
public BookMetadataDto Create(
string? title = null,
string? originalTitle = null,
string? description = null,
ReleaseInfoDto? releaseInfo = null,
List<GenreDto>? genres = null,
List<TagDto>? tags = null,
LanguageInfoDto? language = null,
LanguageInfoDto? originalLanguage = null,
string? publisher = null,
int? pageCount = 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<MediaContributorDto>? contributors = null,
List<BookRatingDto>? ratings = null,
string? coverImagePath = null,
bool includeTitle = true,
bool includeReleaseInfo = true,
bool includeGenres = true,
bool includeTags = true,
bool includeLanguage = true,
bool includeFormat = true,
bool includeVolumeNumber = true)
{
int releaseYear = _faker.Random.Int(1900, 2024);
return new BookMetadataDto(
includeTitle ? title ?? _faker.Lorem.Sentence(3) : null,
originalTitle,
description,
includeReleaseInfo ? (releaseInfo ?? _releaseInfoDtoFixture.Create(
originalReleaseDate: new DateOnly(releaseYear, 1, 1),
originalReleaseYear: releaseYear,
releaseCountry: _faker.PickRandom<ReleaseCountry>())) : null,
includeGenres ? (genres ?? [_genreDtoFixture.Create()]) : null,
includeTags ? (tags ?? [_tagDtoFixture.Create()]) : null,
includeLanguage ? (language ?? _languageInfoDtoFixture.Create()) : null,
originalLanguage,
publisher,
pageCount,
includeFormat ? (format ?? _faker.PickRandom<BookFormat>()) : null,
edition,
includeVolumeNumber ? (volumeNumber ?? _faker.Random.Int(1, 10)) : null,
series,
asin,
goodreadsId,
lccn,
oclcNumber,
openLibraryId,
libraryThingId,
googleBooksId,
barnesAndNobleId,
appleBooksId,
isbns,
contributors,
ratings,
coverImagePath);
}
/// <summary>
/// Creates a list of <see cref="BookMetadataDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<BookMetadataDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,61 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Fixture class for the <see cref="BookMetadataLookupDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class BookMetadataLookupDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="BookMetadataLookupDto"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the book belongs to.</param>
/// <param name="path">Optional. The file system path of the book.</param>
/// <param name="isbn">Optional. The ISBN of the book.</param>
/// <param name="openLibraryId">Optional. The Open Library ID of the book.</param>
/// <param name="title">Optional. The title of the book.</param>
/// <param name="author">Optional. The author of the book.</param>
/// <param name="languageCode">Optional. The language code of the book.</param>
/// <param name="includePath">Whether the path should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="BookMetadataLookupDto"/>.</returns>
public BookMetadataLookupDto Create(
Guid? libraryId = null,
string? path = null,
string? isbn = null,
string? openLibraryId = null,
string? title = null,
string? author = null,
string? languageCode = null,
bool includePath = true)
{
return new BookMetadataLookupDto(
libraryId ?? Guid.NewGuid(),
includePath ? (path ?? _faker.System.FilePath()) : null!,
isbn,
openLibraryId,
title,
author,
languageCode);
}
/// <summary>
/// Creates a list of <see cref="BookMetadataLookupDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<BookMetadataLookupDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,56 @@
#region ========================================================================= USING =====================================================================================
using AutoFixture;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
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.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Fixture class for the <see cref="BookRatingDto"/>.
/// </summary>
[ExcludeFromCodeCoverage]
public class BookRatingDtoFixture
{
private readonly Fixture _fixture = new();
/// <summary>
/// Creates a <see cref="BookRatingDto"/>.
/// </summary>
/// <param name="value">Optional. The rating value.</param>
/// <param name="maxValue">Optional. The maximum possible rating value.</param>
/// <param name="source">Optional. The rating source.</param>
/// <param name="voteCount">Optional. The number of votes.</param>
/// <param name="includeSource">Whether the source should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeVoteCount">Whether the vote count should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="BookRatingDto"/>.</returns>
public BookRatingDto Create(
decimal? value = null,
decimal? maxValue = null,
BookRatingSource? source = null,
int? voteCount = null,
bool includeSource = true,
bool includeVoteCount = true)
{
return new BookRatingDto(
value ?? Random.Shared.Next(1, 5),
maxValue ?? 5,
includeSource ? (source ?? _fixture.Create<BookRatingSource>()) : null,
includeVoteCount ? (voteCount ?? Random.Shared.Next(1, 1000)) : null
);
}
/// <summary>
/// Creates a list of <see cref="BookRatingDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<BookRatingDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,38 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Fixture class for the <see cref="BookSeriesDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class BookSeriesDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="BookSeriesDto"/> with randomized test data.
/// </summary>
/// <param name="title">Optional. The title of the book series.</param>
/// <returns>A configured <see cref="BookSeriesDto"/> instance.</returns>
public BookSeriesDto Create(string? title = null)
{
return new BookSeriesDto(title ?? _faker.Lorem.Sentence(3));
}
/// <summary>
/// Creates multiple <see cref="BookSeriesDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="BookSeriesDto"/> instances.</returns>
public List<BookSeriesDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,84 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
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.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Fixture class for the <see cref="IsbnDto"/>.
/// </summary>
[ExcludeFromCodeCoverage]
public class IsbnDtoFixture
{
/// <summary>
/// Creates an <see cref="IsbnDto"/> with a random or explicitly requested format.
/// </summary>
/// <param name="value">Optional. The ISBN value. If not provided, a valid ISBN is generated.</param>
/// <param name="format">Optional. The ISBN format. If not provided, the format is left unspecified.</param>
/// <returns>The created <see cref="IsbnDto"/>.</returns>
public IsbnDto Create(string? value = null, IsbnFormat? format = null)
{
string resolvedValue = value ?? (format == IsbnFormat.Isbn10 ? GenerateValidIsbn10() : GenerateValidIsbn13());
return new IsbnDto(
resolvedValue,
format ?? (resolvedValue.Length > 13 ? IsbnFormat.Isbn13 : IsbnFormat.Isbn10)
);
}
/// <summary>
/// Creates a list of <see cref="IsbnDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<IsbnDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Generates a valid ISBN-10 with the correct checksum.
/// </summary>
/// <returns>A valid ISBN-10 value.</returns>
private string GenerateValidIsbn10()
{
int[] digits = new int[9];
for (int i = 0; i < 9; i++)
digits[i] = Random.Shared.Next(0, 10);
int sum = 0;
for (int i = 0; i < 9; i++)
sum += (10 - i) * digits[i];
int checkDigit = (11 - sum % 11) % 11;
string checkChar = checkDigit == 10 ? "X" : checkDigit.ToString();
return $"{digits[0]}-{digits[1]}{digits[2]}-{digits[3]}{digits[4]}{digits[5]}{digits[6]}{digits[7]}{digits[8]}-{checkChar}";
}
/// <summary>
/// Generates a valid ISBN-13 with the correct checksum.
/// </summary>
/// <returns>A valid ISBN-13 value.</returns>
private string GenerateValidIsbn13()
{
string prefix = Random.Shared.Next(2) == 0 ? "978" : "979";
string group = Random.Shared.Next(0, 99999).ToString().PadLeft(5, '0');
string publisher = Random.Shared.Next(0, 999999).ToString().PadLeft(6, '0');
string title = Random.Shared.Next(0, 99).ToString().PadLeft(2, '0');
string isbn = $"{prefix}{group[..1]}{publisher}{title}";
int sum = 0;
for (int i = 0; i < 12; i++)
sum += (i % 2 == 0 ? 1 : 3) * int.Parse(isbn[i].ToString());
int checkDigit = (10 - sum % 10) % 10;
return $"{prefix}-{group[..1]}-{publisher}-{title}-{checkDigit}";
}
}
@@ -0,0 +1,64 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
/// <summary>
/// Fixture class for the <see cref="ReadingDocumentDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReadingDocumentDtoFixture
{
private readonly ReadingTocEntryDtoFixture _readingTocEntryDtoFixture = new();
private readonly ReadingSpineItemDtoFixture _readingSpineItemDtoFixture = new();
private readonly ReadingResourceInfoDtoFixture _readingResourceInfoDtoFixture = new();
/// <summary>
/// Creates a random valid <see cref="ReadingDocumentDto"/>.
/// </summary>
/// <param name="title">Optional. The title of the book.</param>
/// <param name="author">Optional. The author of the book, if known.</param>
/// <param name="coverResourceKey">Optional. The resource key of the cover image of the book, if applicable.</param>
/// <param name="tableOfContents">Optional. The hierarchical table of contents of the book.</param>
/// <param name="spine">Optional. The ordered spine of the reading sections of the book.</param>
/// <param name="resources">Optional. The resources of the book, keyed by their resource key.</param>
/// <param name="hasTextContent">Optional. Whether the book has extractable text content.</param>
/// <returns>The created <see cref="ReadingDocumentDto"/>.</returns>
public ReadingDocumentDto Create(
string? title = null,
string? author = null,
string? coverResourceKey = null,
IReadOnlyList<ReadingTocEntryDto>? tableOfContents = null,
IReadOnlyList<ReadingSpineItemDto>? spine = null,
IReadOnlyDictionary<string, ReadingResourceInfoDto>? resources = null,
bool? hasTextContent = null)
{
return new ReadingDocumentDto(
title ?? $"Book {Guid.NewGuid():N}",
author,
coverResourceKey,
tableOfContents ?? [.. _readingTocEntryDtoFixture.CreateMany(2)],
spine ?? [.. _readingSpineItemDtoFixture.CreateMany(2)],
resources ?? new Dictionary<string, ReadingResourceInfoDto>
{
[$"resource-{Guid.NewGuid():N}"] = _readingResourceInfoDtoFixture.Create()
},
hasTextContent ?? true
);
}
/// <summary>
/// Creates a list of <see cref="ReadingDocumentDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ReadingDocumentDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
/// <summary>
/// Fixture class for the <see cref="ReadingResourceDataDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReadingResourceDataDtoFixture
{
/// <summary>
/// Creates a random valid <see cref="ReadingResourceDataDto"/>.
/// </summary>
/// <param name="data">Optional. The binary data of the resource.</param>
/// <param name="mimeType">Optional. The MIME type of the resource.</param>
/// <returns>The created <see cref="ReadingResourceDataDto"/>.</returns>
public ReadingResourceDataDto Create(
byte[]? data = null,
string? mimeType = null)
{
return new ReadingResourceDataDto(data ?? Guid.NewGuid().ToByteArray(), mimeType ?? "image/png");
}
/// <summary>
/// Creates a list of <see cref="ReadingResourceDataDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ReadingResourceDataDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
/// <summary>
/// Fixture class for the <see cref="ReadingResourceInfoDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReadingResourceInfoDtoFixture
{
/// <summary>
/// Creates a random valid <see cref="ReadingResourceInfoDto"/>.
/// </summary>
/// <param name="relativeFilePath">Optional. The path of the resource file, relative to the extraction directory of the book.</param>
/// <param name="mimeType">Optional. The MIME type of the resource.</param>
/// <returns>The created <see cref="ReadingResourceInfoDto"/>.</returns>
public ReadingResourceInfoDto Create(
string? relativeFilePath = null,
string? mimeType = null)
{
return new ReadingResourceInfoDto(relativeFilePath ?? $"resources/resource-{Guid.NewGuid():N}.png", mimeType ?? "image/png");
}
/// <summary>
/// Creates a list of <see cref="ReadingResourceInfoDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ReadingResourceInfoDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,41 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
/// <summary>
/// Fixture class for the <see cref="ReadingSectionDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReadingSectionDtoFixture
{
/// <summary>
/// Creates a random valid <see cref="ReadingSectionDto"/>.
/// </summary>
/// <param name="locationRef">Optional. The opaque location reference of the reading section.</param>
/// <param name="title">Optional. The title of the reading section, if known.</param>
/// <param name="contentHtml">Optional. The sanitized HTML content of the reading section.</param>
/// <returns>The created <see cref="ReadingSectionDto"/>.</returns>
public ReadingSectionDto Create(
string? locationRef = null,
string? title = null,
string? contentHtml = null)
{
return new ReadingSectionDto(locationRef ?? $"section-{Guid.NewGuid():N}", title, contentHtml ?? "<section><p>Content</p></section>");
}
/// <summary>
/// Creates a list of <see cref="ReadingSectionDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ReadingSectionDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,41 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
/// <summary>
/// Fixture class for the <see cref="ReadingSpineItemDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReadingSpineItemDtoFixture
{
/// <summary>
/// Creates a random valid <see cref="ReadingSpineItemDto"/>.
/// </summary>
/// <param name="locationRef">Optional. The opaque location reference of the reading section.</param>
/// <param name="title">Optional. The title of the reading section, if known.</param>
/// <param name="relativeSectionFilePath">Optional. The path of the section content file, relative to the extraction directory of the book.</param>
/// <returns>The created <see cref="ReadingSpineItemDto"/>.</returns>
public ReadingSpineItemDto Create(
string? locationRef = null,
string? title = null,
string? relativeSectionFilePath = null)
{
return new ReadingSpineItemDto(locationRef ?? $"section-{Guid.NewGuid():N}", title, relativeSectionFilePath ?? $"sections/{Guid.NewGuid():N}.html");
}
/// <summary>
/// Creates a list of <see cref="ReadingSpineItemDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ReadingSpineItemDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,45 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
/// <summary>
/// Fixture class for the <see cref="ReadingTocEntryDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReadingTocEntryDtoFixture
{
/// <summary>
/// Creates a random valid <see cref="ReadingTocEntryDto"/>.
/// </summary>
/// <param name="label">Optional. The label of the table of contents entry.</param>
/// <param name="locationRef">Optional. The opaque location reference of the reading section the entry points to.</param>
/// <param name="children">Optional. The child entries of the table of contents entry.</param>
/// <returns>The created <see cref="ReadingTocEntryDto"/>.</returns>
public ReadingTocEntryDto Create(
string? label = null,
string? locationRef = null,
IReadOnlyList<ReadingTocEntryDto>? children = null)
{
return new ReadingTocEntryDto(
label ?? $"Chapter {Guid.NewGuid():N}",
locationRef ?? $"section-{Guid.NewGuid():N}",
children ?? []
);
}
/// <summary>
/// Creates a list of <see cref="ReadingTocEntryDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ReadingTocEntryDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,147 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.Common;
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.WrittenContentLibrary;
/// <summary>
/// Fixture class for the <see cref="WrittenContentMetadataDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class WrittenContentMetadataDtoFixture
{
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="WrittenContentMetadataDto"/>.
/// </summary>
/// <param name="title">Optional. The title of the written content.</param>
/// <param name="originalTitle">Optional. The original title of the written content.</param>
/// <param name="description">Optional. A brief description or summary of the written content.</param>
/// <param name="releaseInfo">Optional. The release information of the written content.</param>
/// <param name="genres">Optional. The genres associated with the written content.</param>
/// <param name="tags">Optional. The tags that describe or categorize the written content.</param>
/// <param name="language">Optional. The language in which the written content is written.</param>
/// <param name="originalLanguage">Optional. The original language of the written content.</param>
/// <param name="publisher">Optional. The name of the publisher of the written content.</param>
/// <param name="pageCount">Optional. The number of pages in the written content.</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="includeGenres">Whether the genres 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="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="includePublisher">Whether the publisher should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePageCount">Whether the page count should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="WrittenContentMetadataDto"/>.</returns>
public WrittenContentMetadataDto Create(
string? title = null,
string? originalTitle = null,
string? description = null,
ReleaseInfoDto? releaseInfo = null,
List<GenreDto>? genres = null,
List<TagDto>? tags = null,
LanguageInfoDto? language = null,
LanguageInfoDto? originalLanguage = null,
string? publisher = null,
int? pageCount = null,
bool includeTitle = true,
bool includeOriginalTitle = true,
bool includeDescription = true,
bool includeReleaseInfo = true,
bool includeGenres = true,
bool includeTags = true,
bool includeLanguage = true,
bool includeOriginalLanguage = true,
bool includePublisher = true,
bool includePageCount = true)
{
return new WrittenContentMetadataDto(
includeTitle ? (title ?? _faker.Commerce.ProductName()) : null,
includeOriginalTitle ? (originalTitle ?? _faker.Commerce.ProductName()) : null,
includeDescription ? (description ?? _faker.Lorem.Paragraph()) : null,
includeReleaseInfo ? (releaseInfo ?? CreateReleaseInfo()) : null,
includeGenres ? (genres ?? CreateDistinctGenres()) : null,
includeTags ? (tags ?? CreateDistinctTags()) : null,
includeLanguage ? (language ?? _languageInfoDtoFixture.Create()) : null,
includeOriginalLanguage ? (originalLanguage ?? _languageInfoDtoFixture.Create()) : null,
includePublisher ? (publisher ?? _faker.Company.CompanyName()) : null,
includePageCount ? (pageCount ?? _faker.Random.Int(1, 1000)) : null);
}
/// <summary>
/// Creates a list of <see cref="WrittenContentMetadataDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<WrittenContentMetadataDto> 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 CreateReleaseInfo()
{
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> CreateDistinctGenres()
{
List<GenreDto> genres = [];
while (genres.Count < 2)
{
GenreDto genre = _genreDtoFixture.Create();
if (genres.All(existing => existing.Name != genre.Name))
genres.Add(genre);
}
return genres;
}
/// <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> CreateDistinctTags()
{
List<TagDto> tags = [];
while (tags.Count < 2)
{
TagDto tag = _tagDtoFixture.Create();
if (tags.All(existing => existing.Name != tag.Name))
tags.Add(tag);
}
return tags;
}
}