Extends the music library aggregates and metadata with the new artist, area, and work details

This commit is contained in:
BinaryAlley committed 2026-10-06 14:52:00 +03:00
1 parent e20e244a04
commit ed96046769
16 files changed
+986 -129

No files matched your search

@@ -40,6 +40,11 @@ public class AudioMetadataFixture
/// <param name="bitDepth">Optional. The bit depth of the audio.</param>
/// <param name="audioCodec">Optional. The audio codec used.</param>
/// <param name="bitrate">Optional. The bitrate of the audio, in kbps.</param>
/// <param name="acoustId">Optional. The AcoustID fingerprint identifier of the audio file.</param>
/// <param name="replayGainTrackGain">Optional. The ReplayGain track gain, in decibels.</param>
/// <param name="replayGainTrackPeak">Optional. The ReplayGain track peak.</param>
/// <param name="replayGainAlbumGain">Optional. The ReplayGain album gain, in decibels.</param>
/// <param name="replayGainAlbumPeak">Optional. The ReplayGain album peak.</param>
/// <returns>The created <see cref="AudioMetadata"/>.</returns>
public AudioMetadata Create(
string? title = null,
@@ -55,7 +60,12 @@ public class AudioMetadataFixture
Optional<LanguageInfo>? originalLanguage = null,
Optional<int>? bitDepth = null,
Optional<string>? audioCodec = null,
Optional<int>? bitrate = null)
Optional<int>? bitrate = null,
Optional<string>? acoustId = null,
Optional<decimal>? replayGainTrackGain = null,
Optional<decimal>? replayGainTrackPeak = null,
Optional<decimal>? replayGainAlbumGain = null,
Optional<decimal>? replayGainAlbumPeak = null)
{
return AudioMetadata.Create(
title ?? _faker.Music.Genre(),
@@ -71,7 +81,12 @@ public class AudioMetadataFixture
originalLanguage ?? Optional<LanguageInfo>.None(),
bitDepth ?? Optional<int>.Some(_faker.Random.Int(8, 32)),
audioCodec ?? Optional<string>.Some("PCM"),
bitrate ?? Optional<int>.Some(_faker.Random.Int(128, 320))).Value;
bitrate ?? Optional<int>.Some(_faker.Random.Int(128, 320)),
acoustId ?? Optional<string>.None(),
replayGainTrackGain ?? Optional<decimal>.None(),
replayGainTrackPeak ?? Optional<decimal>.None(),
replayGainAlbumGain ?? Optional<decimal>.None(),
replayGainAlbumPeak ?? Optional<decimal>.None()).Value;
}
/// <summary>
@@ -1,13 +1,18 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Common.ValueObjects.Metadata;
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Common.ValueObjects.Metadata;
using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -22,35 +27,96 @@ namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext
[ExcludeFromCodeCoverage]
public class ArtistFixture
{
private const int MINIMUM_LIFESPAN_YEAR = 1900;
private const int MAXIMUM_LIFESPAN_YEAR = 2026;
private readonly Faker _faker = new();
private readonly LibraryIdFixture _libraryIdFixture = new();
private readonly AlbumFixture _albumFixture = new();
private readonly MusicBrainzIdFixture _musicBrainzIdFixture = new();
private readonly MusicMediaContributorFixture _musicMediaContributorFixture = new();
private readonly MusicAreaFixture _musicAreaFixture = new();
private readonly MusicArtistAliasFixture _musicArtistAliasFixture = new();
private readonly GenreFixture _genreFixture = new();
private readonly TagFixture _tagFixture = new();
private readonly AudioRatingFixture _audioRatingFixture = new();
/// <summary>
/// Creates a random valid <see cref="Artist"/> domain aggregate root.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library this artist belongs to.</param>
/// <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 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 associated with 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="albums">Optional. The albums of the artist. Defaults to a single random album, since an artist must have at least one.</param>
/// <returns>The created <see cref="Artist"/> domain aggregate root.</returns>
public Artist Create(
LibraryId? libraryId = null,
string? name = null,
Optional<string>? sortName = null,
Optional<string>? disambiguation = null,
Optional<MusicArtistType>? type = null,
Optional<MusicArtistGender>? gender = null,
Optional<string>? country = null,
Optional<MusicArea>? area = null,
Optional<MusicArea>? beginArea = null,
Optional<MusicArea>? endArea = null,
Optional<DateOnly>? lifeSpanBegin = null,
Optional<DateOnly>? lifeSpanEnd = null,
bool? isEnded = null,
Optional<string>? website = null,
Optional<MusicBrainzId>? musicBrainzArtistId = null,
List<string>? ipis = null,
List<string>? isnis = null,
List<MusicArtistAlias>? aliases = null,
List<Genre>? genres = null,
List<Tag>? tags = null,
List<AudioRating>? ratings = null,
List<MusicMediaContributor>? contributors = null,
List<Album>? albums = null)
{
int lifeSpanBeginYear = Random.Shared.Next(MINIMUM_LIFESPAN_YEAR, MAXIMUM_LIFESPAN_YEAR);
int lifeSpanEndYear = Random.Shared.Next(lifeSpanBeginYear, Math.Max(lifeSpanBeginYear + 1, MAXIMUM_LIFESPAN_YEAR));
Result<Artist> artistResult = Artist.Create(
libraryId ?? _libraryIdFixture.Create(),
name ?? _faker.Name.FullName(),
sortName ?? Optional<string>.Some(_faker.Name.FullName()),
disambiguation ?? Optional<string>.Some(_faker.Lorem.Sentence()),
type ?? Optional<MusicArtistType>.Some(_faker.PickRandom<MusicArtistType>()),
gender ?? Optional<MusicArtistGender>.Some(_faker.PickRandom<MusicArtistGender>()),
country ?? Optional<string>.Some(_faker.Address.CountryCode()),
area ?? Optional<MusicArea>.Some(_musicAreaFixture.Create()),
beginArea ?? Optional<MusicArea>.Some(_musicAreaFixture.Create()),
endArea ?? Optional<MusicArea>.Some(_musicAreaFixture.Create()),
lifeSpanBegin ?? Optional<DateOnly>.Some(new DateOnly(lifeSpanBeginYear, 1, 1)),
lifeSpanEnd ?? Optional<DateOnly>.Some(new DateOnly(lifeSpanEndYear, 1, 1)),
isEnded ?? _faker.Random.Bool(),
website ?? Optional<string>.Some(_faker.Internet.Url()),
musicBrainzArtistId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
ipis ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.AlphaNumeric(9))],
isnis ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.AlphaNumeric(16))],
aliases ?? _musicArtistAliasFixture.CreateMany(_faker.Random.Int(1, 2)),
genres ?? _genreFixture.CreateMany(_faker.Random.Int(1, 2)),
tags ?? _tagFixture.CreateMany(_faker.Random.Int(1, 2)),
ratings ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _audioRatingFixture.Create())],
contributors ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(_ => _musicMediaContributorFixture.Create())],
albums ?? [_albumFixture.Create()]);
@@ -32,9 +32,14 @@ public class AlbumFixture
/// Creates a random valid <see cref="Album"/> domain entity.
/// </summary>
/// <param name="metadata">Optional. The album metadata of the album.</param>
/// <param name="disambiguation">Optional. The disambiguation comment of the album.</param>
/// <param name="mediaFormat">Optional. The physical or digital medium of the album.</param>
/// <param name="packaging">Optional. The outermost physical packaging of the album.</param>
/// <param name="script">Optional. The script used by the language of the release of the album.</param>
/// <param name="barcode">Optional. The barcode of the album.</param>
/// <param name="catalogNumber">Optional. The catalog number of the album.</param>
/// <param name="label">Optional. The name of the label that issued the album.</param>
/// <param name="asin">Optional. The ASIN of the album.</param>
/// <param name="musicBrainzReleaseId">Optional. The MusicBrainz identifier of the release.</param>
/// <param name="musicBrainzReleaseGroupId">Optional. The MusicBrainz identifier of the release group.</param>
/// <param name="musicBrainzReleaseArtistId">Optional. The MusicBrainz identifier of the release artist.</param>
@@ -44,9 +49,14 @@ public class AlbumFixture
/// <returns>The created <see cref="Album"/> domain entity.</returns>
public Album Create(
AlbumMetadata? metadata = null,
Optional<string>? disambiguation = null,
Optional<MusicMediaFormat>? mediaFormat = null,
Optional<MusicReleasePackaging>? packaging = null,
Optional<string>? script = null,
Optional<Barcode>? barcode = null,
Optional<string>? catalogNumber = null,
List<string>? catalogNumbers = null,
Optional<string>? label = null,
Optional<string>? asin = null,
Optional<MusicBrainzId>? musicBrainzReleaseId = null,
Optional<MusicBrainzId>? musicBrainzReleaseGroupId = null,
Optional<MusicBrainzId>? musicBrainzReleaseArtistId = null,
@@ -56,9 +66,14 @@ public class AlbumFixture
{
Result<Album> albumResult = Album.Create(
metadata ?? _albumMetadataFixture.Create(),
disambiguation ?? Optional<string>.Some(_faker.Lorem.Sentence()),
mediaFormat ?? Optional<MusicMediaFormat>.Some(_faker.PickRandom<MusicMediaFormat>()),
packaging ?? Optional<MusicReleasePackaging>.Some(_faker.PickRandom<MusicReleasePackaging>()),
script ?? Optional<string>.Some(_faker.Random.String2(4)),
barcode ?? Optional<Barcode>.Some(_barcodeFixture.Create()),
catalogNumber ?? Optional<string>.Some(_faker.Random.String2(_faker.Random.Int(5, 20))),
catalogNumbers ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.String2(_faker.Random.Int(5, 20)))],
label ?? Optional<string>.Some(_faker.Company.CompanyName()),
asin ?? Optional<string>.Some(_faker.Random.AlphaNumeric(10)),
musicBrainzReleaseId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
musicBrainzReleaseGroupId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
musicBrainzReleaseArtistId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
@@ -29,6 +29,7 @@ public class TrackFixture
private readonly IsrcFixture _isrcFixture = new();
private readonly MusicMediaContributorFixture _musicMediaContributorFixture = new();
private readonly MusicBrainzIdFixture _musicBrainzIdFixture = new();
private readonly MusicWorkFixture _musicWorkFixture = new();
private readonly AudioRatingFixture _audioRatingFixture = new();
/// <summary>
@@ -36,51 +37,54 @@ public class TrackFixture
/// </summary>
/// <param name="path">Optional. The file system path of the track.</param>
/// <param name="metadata">Optional. The audio metadata of the track.</param>
/// <param name="disambiguation">Optional. The disambiguation comment of the track.</param>
/// <param name="trackNumber">Optional. The number of the track on its disc.</param>
/// <param name="discNumber">Optional. The number of the disc the track belongs to.</param>
/// <param name="moods">Optional. The moods of the track.</param>
/// <param name="script">Optional. The script used by the language of the track.</param>
/// <param name="key">Optional. The musical key of the track.</param>
/// <param name="bpm">Optional. The tempo of the track in beats per minute.</param>
/// <param name="isVideo">Optional. Whether the recording of the track is a video recording.</param>
/// <param name="isrcs">Optional. The ISRCs of the track.</param>
/// <param name="work">Optional. The title of the work the track is a recording of.</param>
/// <param name="work">Optional. The work the track is a recording of.</param>
/// <param name="musicBrainzRecordingId">Optional. The MusicBrainz identifier of the recording.</param>
/// <param name="musicBrainzTrackId">Optional. The MusicBrainz identifier of the track.</param>
/// <param name="musicBrainzWorkId">Optional. The MusicBrainz identifier of the work.</param>
/// <param name="contributors">Optional. The media contributors of the track.</param>
/// <param name="ratings">Optional. The ratings of the track.</param>
/// <returns>The created <see cref="Track"/> domain entity.</returns>
public Track Create(
string? path = null,
AudioMetadata? metadata = null,
Optional<string>? disambiguation = null,
int? trackNumber = null,
Optional<int>? discNumber = null,
List<Mood>? moods = null,
Optional<string>? script = null,
Optional<MusicKey>? key = null,
Optional<int>? bpm = null,
bool? isVideo = null,
List<Isrc>? isrcs = null,
Optional<string>? work = null,
Optional<MusicWork>? work = null,
Optional<MusicBrainzId>? musicBrainzRecordingId = null,
Optional<MusicBrainzId>? musicBrainzTrackId = null,
Optional<MusicBrainzId>? musicBrainzWorkId = null,
List<MusicMediaContributor>? contributors = null,
List<AudioRating>? ratings = null)
{
Result<Track> trackResult = Track.Create(
path ?? _faker.System.FilePath(),
metadata ?? _audioMetadataFixture.Create(),
disambiguation ?? Optional<string>.None(),
trackNumber ?? _faker.Random.Int(1, 30),
discNumber ?? Optional<int>.Some(_faker.Random.Int(1, 2)),
moods ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(_ => _moodFixture.Create())],
script ?? Optional<string>.Some(_faker.Lorem.Word()),
key ?? Optional<MusicKey>.Some(_faker.PickRandom<MusicKey>()),
bpm ?? Optional<int>.Some(_faker.Random.Int(60, 220)),
isVideo ?? _faker.Random.Bool(),
isrcs ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _isrcFixture.Create())],
work ?? Optional<string>.Some(_faker.Lorem.Sentence()),
work ?? Optional<MusicWork>.Some(_musicWorkFixture.Create()),
musicBrainzRecordingId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
musicBrainzTrackId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
musicBrainzWorkId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
contributors ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(_ => _musicMediaContributorFixture.Create())],
ratings ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _audioRatingFixture.Create())]);
@@ -30,13 +30,14 @@ public class AlbumMetadataFixture
/// </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. The description of the album.</param>
/// <param name="releaseInfo">Optional. The release information of the album.</param>
/// <param name="genres">Optional. The genres of the album.</param>
/// <param name="tags">Optional. The tags associated with 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="releaseType">Optional. The type of the release.</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>
@@ -44,13 +45,14 @@ public class AlbumMetadataFixture
public AlbumMetadata Create(
string? title = null,
Optional<string>? originalTitle = null,
Optional<string>? releaseTitle = null,
Optional<string>? description = null,
ReleaseInfo? releaseInfo = null,
List<Genre>? genres = null,
List<Tag>? tags = null,
Optional<LanguageInfo>? language = null,
Optional<LanguageInfo>? originalLanguage = null,
Optional<MusicReleaseType>? releaseType = null,
List<MusicReleaseType>? releaseTypes = null,
Optional<MusicReleaseStatus>? releaseStatus = null,
Optional<int>? totalDiscs = null,
int? totalTracks = null)
@@ -58,13 +60,14 @@ public class AlbumMetadataFixture
Result<AlbumMetadata> metadataResult = AlbumMetadata.Create(
title ?? _faker.Commerce.ProductName(),
originalTitle ?? Optional<string>.None(),
releaseTitle ?? Optional<string>.Some(_faker.Commerce.ProductName()),
description ?? Optional<string>.Some(_faker.Lorem.Sentence()),
releaseInfo ?? _releaseInfoFixture.Create(),
genres ?? [_genreFixture.Create(), _genreFixture.Create()],
tags ?? [_tagFixture.Create(), _tagFixture.Create()],
language ?? Optional<LanguageInfo>.Some(_languageInfoFixture.Create()),
originalLanguage ?? Optional<LanguageInfo>.None(),
releaseType ?? Optional<MusicReleaseType>.Some(_faker.PickRandom<MusicReleaseType>()),
releaseTypes ?? [_faker.PickRandom<MusicReleaseType>()],
releaseStatus ?? Optional<MusicReleaseStatus>.Some(_faker.PickRandom<MusicReleaseStatus>()),
totalDiscs ?? Optional<int>.Some(_faker.Random.Int(1, 4)),
totalTracks ?? _faker.Random.Int(1, 50));