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

@@ -34,6 +34,7 @@ public static partial class Errors
public static Error UnknownMusicReleaseType => Error.Validation(description: nameof(UnknownMusicReleaseType)); public static Error UnknownMusicReleaseType => Error.Validation(description: nameof(UnknownMusicReleaseType));
public static Error UnknownMusicReleaseStatus => Error.Validation(description: nameof(UnknownMusicReleaseStatus)); public static Error UnknownMusicReleaseStatus => Error.Validation(description: nameof(UnknownMusicReleaseStatus));
public static Error UnknownMusicMediaFormat => Error.Validation(description: nameof(UnknownMusicMediaFormat)); public static Error UnknownMusicMediaFormat => Error.Validation(description: nameof(UnknownMusicMediaFormat));
public static Error UnknownMusicReleasePackaging => Error.Validation(description: nameof(UnknownMusicReleasePackaging));
public static Error UnknownMusicKey => Error.Validation(description: nameof(UnknownMusicKey)); public static Error UnknownMusicKey => Error.Validation(description: nameof(UnknownMusicKey));
public static Error CatalogNumberMustBeMaximum50CharactersLong => Error.Validation(description: nameof(CatalogNumberMustBeMaximum50CharactersLong)); public static Error CatalogNumberMustBeMaximum50CharactersLong => Error.Validation(description: nameof(CatalogNumberMustBeMaximum50CharactersLong));
public static Error TrackNotFound => Error.NotFound(description: nameof(TrackNotFound)); public static Error TrackNotFound => Error.NotFound(description: nameof(TrackNotFound));
@@ -52,5 +53,17 @@ public static partial class Errors
public static Error TheArtistDoesNotHaveTheAlbum => Error.Forbidden(description: nameof(TheArtistDoesNotHaveTheAlbum)); public static Error TheArtistDoesNotHaveTheAlbum => Error.Forbidden(description: nameof(TheArtistDoesNotHaveTheAlbum));
public static Error TheTrackIsAlreadyInTheAlbum => Error.Forbidden(description: nameof(TheTrackIsAlreadyInTheAlbum)); public static Error TheTrackIsAlreadyInTheAlbum => Error.Forbidden(description: nameof(TheTrackIsAlreadyInTheAlbum));
public static Error TheTrackIsNotInTheAlbum => Error.Forbidden(description: nameof(TheTrackIsNotInTheAlbum)); public static Error TheTrackIsNotInTheAlbum => Error.Forbidden(description: nameof(TheTrackIsNotInTheAlbum));
public static Error AreaNameCannotBeEmpty => Error.Validation(description: nameof(AreaNameCannotBeEmpty));
public static Error ArtistAliasNameCannotBeEmpty => Error.Validation(description: nameof(ArtistAliasNameCannotBeEmpty));
public static Error ArtistAliasNameMustBeMaximum255CharactersLong => Error.Validation(description: nameof(ArtistAliasNameMustBeMaximum255CharactersLong));
public static Error AreaNameMustBeMaximum255CharactersLong => Error.Validation(description: nameof(AreaNameMustBeMaximum255CharactersLong));
public static Error UnknownMusicArtistType => Error.Validation(description: nameof(UnknownMusicArtistType));
public static Error UnknownMusicArtistGender => Error.Validation(description: nameof(UnknownMusicArtistGender));
public static Error CountryMustBeMaximum2CharactersLong => Error.Validation(description: nameof(CountryMustBeMaximum2CharactersLong));
public static Error IpiValueCannotBeEmpty => Error.Validation(description: nameof(IpiValueCannotBeEmpty));
public static Error IpiValueMustBeMaximum20CharactersLong => Error.Validation(description: nameof(IpiValueMustBeMaximum20CharactersLong));
public static Error IsniValueCannotBeEmpty => Error.Validation(description: nameof(IsniValueCannotBeEmpty));
public static Error IsniValueMustBeMaximum20CharactersLong => Error.Validation(description: nameof(IsniValueMustBeMaximum20CharactersLong));
public static Error WorkTitleCannotBeEmpty => Error.Validation(description: nameof(WorkTitleCannotBeEmpty));
} }
} }
@@ -43,6 +43,31 @@ public class AudioMetadata : BaseMetadata
/// </summary> /// </summary>
public Optional<int> Bitrate { get; } public Optional<int> Bitrate { get; }
/// <summary>
/// Gets the AcoustID fingerprint identifier of the audio file, if applicable.
/// </summary>
public Optional<string> AcoustId { get; }
/// <summary>
/// Gets the ReplayGain track gain in decibels, if applicable.
/// </summary>
public Optional<decimal> ReplayGainTrackGain { get; }
/// <summary>
/// Gets the ReplayGain track peak, if applicable.
/// </summary>
public Optional<decimal> ReplayGainTrackPeak { get; }
/// <summary>
/// Gets the ReplayGain album gain in decibels, if applicable.
/// </summary>
public Optional<decimal> ReplayGainAlbumGain { get; }
/// <summary>
/// Gets the ReplayGain album peak, if applicable.
/// </summary>
public Optional<decimal> ReplayGainAlbumPeak { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="AudioMetadata"/> class. /// Initializes a new instance of the <see cref="AudioMetadata"/> class.
/// </summary> /// </summary>
@@ -60,6 +85,11 @@ public class AudioMetadata : BaseMetadata
/// <param name="genres">The genres of the audio.</param> /// <param name="genres">The genres of the audio.</param>
/// <param name="tags">The tags associated with the audio.</param> /// <param name="tags">The tags associated with the audio.</param>
/// <param name="bitrate">The bitrate of the audio in kbps.</param> /// <param name="bitrate">The bitrate of the audio in kbps.</param>
/// <param name="acoustId">The AcoustID fingerprint identifier of the audio file.</param>
/// <param name="replayGainTrackGain">The ReplayGain track gain in decibels.</param>
/// <param name="replayGainTrackPeak">The ReplayGain track peak.</param>
/// <param name="replayGainAlbumGain">The ReplayGain album gain in decibels.</param>
/// <param name="replayGainAlbumPeak">The ReplayGain album peak.</param>
private AudioMetadata( private AudioMetadata(
string title, string title,
Optional<string> originalTitle, Optional<string> originalTitle,
@@ -74,7 +104,12 @@ public class AudioMetadata : BaseMetadata
Optional<LanguageInfo> originalLanguage, Optional<LanguageInfo> originalLanguage,
Optional<int> bitDepth, Optional<int> bitDepth,
Optional<string> audioCodec, Optional<string> audioCodec,
Optional<int> bitrate) Optional<int> bitrate,
Optional<string> acoustId,
Optional<decimal> replayGainTrackGain,
Optional<decimal> replayGainTrackPeak,
Optional<decimal> replayGainAlbumGain,
Optional<decimal> replayGainAlbumPeak)
: base(title, originalTitle, description, releaseInfo, genres, tags, language, originalLanguage) : base(title, originalTitle, description, releaseInfo, genres, tags, language, originalLanguage)
{ {
DurationInSeconds = durationInSeconds; DurationInSeconds = durationInSeconds;
@@ -83,6 +118,11 @@ public class AudioMetadata : BaseMetadata
BitDepth = bitDepth; BitDepth = bitDepth;
AudioCodec = audioCodec; AudioCodec = audioCodec;
Bitrate = bitrate; Bitrate = bitrate;
AcoustId = acoustId;
ReplayGainTrackGain = replayGainTrackGain;
ReplayGainTrackPeak = replayGainTrackPeak;
ReplayGainAlbumGain = replayGainAlbumGain;
ReplayGainAlbumPeak = replayGainAlbumPeak;
} }
/// <summary> /// <summary>
@@ -102,6 +142,11 @@ public class AudioMetadata : BaseMetadata
/// <param name="genres">The genres of the audio.</param> /// <param name="genres">The genres of the audio.</param>
/// <param name="tags">The tags associated with the audio.</param> /// <param name="tags">The tags associated with the audio.</param>
/// <param name="bitrate">The bitrate of the audio in kbps.</param> /// <param name="bitrate">The bitrate of the audio in kbps.</param>
/// <param name="acoustId">The AcoustID fingerprint identifier of the audio file.</param>
/// <param name="replayGainTrackGain">The ReplayGain track gain in decibels.</param>
/// <param name="replayGainTrackPeak">The ReplayGain track peak.</param>
/// <param name="replayGainAlbumGain">The ReplayGain album gain in decibels.</param>
/// <param name="replayGainAlbumPeak">The ReplayGain album peak.</param>
/// <returns> /// <returns>
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="AudioMetadata"/>, or an error message. /// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="AudioMetadata"/>, or an error message.
/// </returns> /// </returns>
@@ -119,7 +164,12 @@ public class AudioMetadata : BaseMetadata
Optional<LanguageInfo> originalLanguage, Optional<LanguageInfo> originalLanguage,
Optional<int> bitDepth, Optional<int> bitDepth,
Optional<string> audioCodec, Optional<string> audioCodec,
Optional<int> bitrate) Optional<int> bitrate,
Optional<string> acoustId,
Optional<decimal> replayGainTrackGain,
Optional<decimal> replayGainTrackPeak,
Optional<decimal> replayGainAlbumGain,
Optional<decimal> replayGainAlbumPeak)
{ {
return new AudioMetadata( return new AudioMetadata(
title, title,
@@ -135,7 +185,12 @@ public class AudioMetadata : BaseMetadata
originalLanguage, originalLanguage,
bitDepth, bitDepth,
audioCodec, audioCodec,
bitrate); bitrate,
acoustId,
replayGainTrackGain,
replayGainTrackPeak,
replayGainAlbumGain,
replayGainAlbumPeak);
} }
/// <summary> /// <summary>
@@ -152,5 +207,10 @@ public class AudioMetadata : BaseMetadata
yield return BitDepth; yield return BitDepth;
yield return AudioCodec; yield return AudioCodec;
yield return Bitrate; yield return Bitrate;
yield return AcoustId;
yield return ReplayGainTrackGain;
yield return ReplayGainTrackPeak;
yield return ReplayGainAlbumGain;
yield return ReplayGainAlbumPeak;
} }
} }
@@ -30,6 +30,12 @@ namespace Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLib
public sealed class Artist : AggregateRoot<ArtistId> public sealed class Artist : AggregateRoot<ArtistId>
{ {
private readonly HashSet<MusicMediaContributor> _contributors; private readonly HashSet<MusicMediaContributor> _contributors;
private readonly List<MusicArtistAlias> _aliases;
private readonly List<string> _ipis;
private readonly List<string> _isnis;
private readonly List<Genre> _genres;
private readonly List<Tag> _tags;
private readonly List<AudioRating> _ratings;
private readonly List<Album> _albums; private readonly List<Album> _albums;
/// <summary> /// <summary>
@@ -42,6 +48,61 @@ public sealed class Artist : AggregateRoot<ArtistId>
/// </summary> /// </summary>
public string Name { get; private set; } public string Name { get; private set; }
/// <summary>
/// Gets the sort name of the artist, a variant of the name used when sorting artists, if applicable.
/// </summary>
public Optional<string> SortName { get; private set; }
/// <summary>
/// Gets the disambiguation comment of the artist, used to distinguish artists with the same name, if applicable.
/// </summary>
public Optional<string> Disambiguation { get; private set; }
/// <summary>
/// Gets the type of the artist, describing whether it is a person, a group, or something else, if applicable.
/// </summary>
public Optional<MusicArtistType> Type { get; private set; }
/// <summary>
/// Gets the gender of the artist, applicable only to artists that are persons or characters, if applicable.
/// </summary>
public Optional<MusicArtistGender> Gender { get; private set; }
/// <summary>
/// Gets the ISO 3166-1 alpha-2 code of the country the artist is associated with, if applicable.
/// </summary>
public Optional<string> Country { get; private set; }
/// <summary>
/// Gets the area the artist is primarily identified with, if applicable.
/// </summary>
public Optional<MusicArea> Area { get; private set; }
/// <summary>
/// Gets the area the artist began in, if applicable.
/// </summary>
public Optional<MusicArea> BeginArea { get; private set; }
/// <summary>
/// Gets the area the artist ended in, if applicable.
/// </summary>
public Optional<MusicArea> EndArea { get; private set; }
/// <summary>
/// Gets the date the artist started existing, if applicable.
/// </summary>
public Optional<DateOnly> LifeSpanBegin { get; private set; }
/// <summary>
/// Gets the date the artist stopped existing, if applicable.
/// </summary>
public Optional<DateOnly> LifeSpanEnd { get; private set; }
/// <summary>
/// Gets a value indicating whether the artist no longer exists.
/// </summary>
public bool IsEnded { get; private set; }
/// <summary> /// <summary>
/// Gets the website of the artist, if applicable. /// Gets the website of the artist, if applicable.
/// </summary> /// </summary>
@@ -52,6 +113,36 @@ public sealed class Artist : AggregateRoot<ArtistId>
/// </summary> /// </summary>
public Optional<MusicBrainzId> MusicBrainzArtistId { get; private set; } public Optional<MusicBrainzId> MusicBrainzArtistId { get; private set; }
/// <summary>
/// Gets the list of IPI (Interested Party Information) codes of the artist.
/// </summary>
public IReadOnlyCollection<string> Ipis => _ipis.AsReadOnly();
/// <summary>
/// Gets the list of ISNI (International Standard Name Identifier) codes of the artist.
/// </summary>
public IReadOnlyCollection<string> Isnis => _isnis.AsReadOnly();
/// <summary>
/// Gets the list of alternative names of the artist.
/// </summary>
public IReadOnlyCollection<MusicArtistAlias> Aliases => _aliases.AsReadOnly();
/// <summary>
/// Gets the list of genres associated with the artist.
/// </summary>
public IReadOnlyCollection<Genre> Genres => _genres.AsReadOnly();
/// <summary>
/// Gets the list of tags associated with the artist.
/// </summary>
public IReadOnlyCollection<Tag> Tags => _tags.AsReadOnly();
/// <summary>
/// Gets the list of ratings of the artist.
/// </summary>
public IReadOnlyCollection<AudioRating> Ratings => _ratings.AsReadOnly();
/// <summary> /// <summary>
/// Gets the list of the media contributors that make up the artist. /// Gets the list of the media contributors that make up the artist.
/// </summary> /// </summary>
@@ -68,8 +159,25 @@ public sealed class Artist : AggregateRoot<ArtistId>
/// <param name="id">The object representing the unique identifier of the artist.</param> /// <param name="id">The object representing the unique identifier of the artist.</param>
/// <param name="libraryId">The Id of the media library this artist belongs to.</param> /// <param name="libraryId">The Id of the media library this artist belongs to.</param>
/// <param name="name">The name of the artist.</param> /// <param name="name">The name of the artist.</param>
/// <param name="sortName">The optional sort name of the artist.</param>
/// <param name="disambiguation">The optional disambiguation comment of the artist.</param>
/// <param name="type">The optional type of the artist.</param>
/// <param name="gender">The optional gender of the artist.</param>
/// <param name="country">The optional ISO 3166-1 alpha-2 code of the country of the artist.</param>
/// <param name="area">The optional area the artist is primarily identified with.</param>
/// <param name="beginArea">The optional area the artist began in.</param>
/// <param name="endArea">The optional area the artist ended in.</param>
/// <param name="lifeSpanBegin">The optional date the artist started existing.</param>
/// <param name="lifeSpanEnd">The optional date the artist stopped existing.</param>
/// <param name="isEnded">Whether the artist no longer exists.</param>
/// <param name="website">The optional website of the artist.</param> /// <param name="website">The optional website of the artist.</param>
/// <param name="musicBrainzArtistId">The optional MusicBrainz identifier of the artist.</param> /// <param name="musicBrainzArtistId">The optional MusicBrainz identifier of the artist.</param>
/// <param name="ipis">The list of IPI codes of the artist.</param>
/// <param name="isnis">The list of ISNI codes of the artist.</param>
/// <param name="aliases">The list of alternative names of the artist.</param>
/// <param name="genres">The list of genres associated with the artist.</param>
/// <param name="tags">The list of tags associated with the artist.</param>
/// <param name="ratings">The list of ratings of the artist.</param>
/// <param name="contributors">The list of the media contributors that make up the artist.</param> /// <param name="contributors">The list of the media contributors that make up the artist.</param>
/// <param name="albums">The list of albums of the artist.</param> /// <param name="albums">The list of albums of the artist.</param>
/// <param name="createdOnUtc">The date and time when the entity was created.</param> /// <param name="createdOnUtc">The date and time when the entity was created.</param>
@@ -78,8 +186,25 @@ public sealed class Artist : AggregateRoot<ArtistId>
ArtistId id, ArtistId id,
LibraryId libraryId, LibraryId libraryId,
string name, string name,
Optional<string> sortName,
Optional<string> disambiguation,
Optional<MusicArtistType> type,
Optional<MusicArtistGender> gender,
Optional<string> country,
Optional<MusicArea> area,
Optional<MusicArea> beginArea,
Optional<MusicArea> endArea,
Optional<DateOnly> lifeSpanBegin,
Optional<DateOnly> lifeSpanEnd,
bool isEnded,
Optional<string> website, Optional<string> website,
Optional<MusicBrainzId> musicBrainzArtistId, Optional<MusicBrainzId> musicBrainzArtistId,
List<string> ipis,
List<string> isnis,
List<MusicArtistAlias> aliases,
List<Genre> genres,
List<Tag> tags,
List<AudioRating> ratings,
List<MusicMediaContributor> contributors, List<MusicMediaContributor> contributors,
List<Album> albums, List<Album> albums,
DateTime createdOnUtc, DateTime createdOnUtc,
@@ -88,8 +213,25 @@ public sealed class Artist : AggregateRoot<ArtistId>
Id = id; Id = id;
LibraryId = libraryId; LibraryId = libraryId;
Name = name; Name = name;
SortName = sortName;
Disambiguation = disambiguation;
Type = type;
Gender = gender;
Country = country;
Area = area;
BeginArea = beginArea;
EndArea = endArea;
LifeSpanBegin = lifeSpanBegin;
LifeSpanEnd = lifeSpanEnd;
IsEnded = isEnded;
Website = website; Website = website;
MusicBrainzArtistId = musicBrainzArtistId; MusicBrainzArtistId = musicBrainzArtistId;
_ipis = ipis;
_isnis = isnis;
_aliases = aliases;
_genres = genres;
_tags = tags;
_ratings = ratings;
_contributors = [.. contributors]; _contributors = [.. contributors];
_albums = albums; _albums = albums;
CreatedOnUtc = createdOnUtc; CreatedOnUtc = createdOnUtc;
@@ -101,8 +243,25 @@ public sealed class Artist : AggregateRoot<ArtistId>
/// </summary> /// </summary>
/// <param name="libraryId">The Id of the media library this artist belongs to.</param> /// <param name="libraryId">The Id of the media library this artist belongs to.</param>
/// <param name="name">The name of the artist.</param> /// <param name="name">The name of the artist.</param>
/// <param name="sortName">The optional sort name of the artist.</param>
/// <param name="disambiguation">The optional disambiguation comment of the artist.</param>
/// <param name="type">The optional type of the artist.</param>
/// <param name="gender">The optional gender of the artist.</param>
/// <param name="country">The optional ISO 3166-1 alpha-2 code of the country of the artist.</param>
/// <param name="area">The optional area the artist is primarily identified with.</param>
/// <param name="beginArea">The optional area the artist began in.</param>
/// <param name="endArea">The optional area the artist ended in.</param>
/// <param name="lifeSpanBegin">The optional date the artist started existing.</param>
/// <param name="lifeSpanEnd">The optional date the artist stopped existing.</param>
/// <param name="isEnded">Whether the artist no longer exists.</param>
/// <param name="website">The optional website of the artist.</param> /// <param name="website">The optional website of the artist.</param>
/// <param name="musicBrainzArtistId">The optional MusicBrainz identifier of the artist.</param> /// <param name="musicBrainzArtistId">The optional MusicBrainz identifier of the artist.</param>
/// <param name="ipis">The list of IPI codes of the artist.</param>
/// <param name="isnis">The list of ISNI codes of the artist.</param>
/// <param name="aliases">The list of alternative names of the artist.</param>
/// <param name="genres">The list of genres associated with the artist.</param>
/// <param name="tags">The list of tags associated with the artist.</param>
/// <param name="ratings">The list of ratings of the artist.</param>
/// <param name="contributors">The list of the media contributors that make up the artist.</param> /// <param name="contributors">The list of the media contributors that make up the artist.</param>
/// <param name="albums">The list of albums of the artist.</param> /// <param name="albums">The list of albums of the artist.</param>
/// <returns> /// <returns>
@@ -111,8 +270,25 @@ public sealed class Artist : AggregateRoot<ArtistId>
public static Result<Artist> Create( public static Result<Artist> Create(
LibraryId libraryId, LibraryId libraryId,
string name, string name,
Optional<string> sortName,
Optional<string> disambiguation,
Optional<MusicArtistType> type,
Optional<MusicArtistGender> gender,
Optional<string> country,
Optional<MusicArea> area,
Optional<MusicArea> beginArea,
Optional<MusicArea> endArea,
Optional<DateOnly> lifeSpanBegin,
Optional<DateOnly> lifeSpanEnd,
bool isEnded,
Optional<string> website, Optional<string> website,
Optional<MusicBrainzId> musicBrainzArtistId, Optional<MusicBrainzId> musicBrainzArtistId,
List<string> ipis,
List<string> isnis,
List<MusicArtistAlias> aliases,
List<Genre> genres,
List<Tag> tags,
List<AudioRating> ratings,
List<MusicMediaContributor> contributors, List<MusicMediaContributor> contributors,
List<Album> albums) List<Album> albums)
{ {
@@ -125,8 +301,25 @@ public sealed class Artist : AggregateRoot<ArtistId>
ArtistId.CreateUnique(), ArtistId.CreateUnique(),
libraryId, libraryId,
name, name,
sortName,
disambiguation,
type,
gender,
country,
area,
beginArea,
endArea,
lifeSpanBegin,
lifeSpanEnd,
isEnded,
website, website,
musicBrainzArtistId, musicBrainzArtistId,
ipis,
isnis,
aliases,
genres,
tags,
ratings,
contributors, contributors,
albums, albums,
DateTime.UtcNow, // TODO: should be IDateTimeProvider. DateTime.UtcNow, // TODO: should be IDateTimeProvider.
@@ -139,8 +332,25 @@ public sealed class Artist : AggregateRoot<ArtistId>
/// <param name="id">The object representing the unique identifier of the artist.</param> /// <param name="id">The object representing the unique identifier of the artist.</param>
/// <param name="libraryId">The Id of the media library this artist belongs to.</param> /// <param name="libraryId">The Id of the media library this artist belongs to.</param>
/// <param name="name">The name of the artist.</param> /// <param name="name">The name of the artist.</param>
/// <param name="sortName">The optional sort name of the artist.</param>
/// <param name="disambiguation">The optional disambiguation comment of the artist.</param>
/// <param name="type">The optional type of the artist.</param>
/// <param name="gender">The optional gender of the artist.</param>
/// <param name="country">The optional ISO 3166-1 alpha-2 code of the country of the artist.</param>
/// <param name="area">The optional area the artist is primarily identified with.</param>
/// <param name="beginArea">The optional area the artist began in.</param>
/// <param name="endArea">The optional area the artist ended in.</param>
/// <param name="lifeSpanBegin">The optional date the artist started existing.</param>
/// <param name="lifeSpanEnd">The optional date the artist stopped existing.</param>
/// <param name="isEnded">Whether the artist no longer exists.</param>
/// <param name="website">The optional website of the artist.</param> /// <param name="website">The optional website of the artist.</param>
/// <param name="musicBrainzArtistId">The optional MusicBrainz identifier of the artist.</param> /// <param name="musicBrainzArtistId">The optional MusicBrainz identifier of the artist.</param>
/// <param name="ipis">The list of IPI codes of the artist.</param>
/// <param name="isnis">The list of ISNI codes of the artist.</param>
/// <param name="aliases">The list of alternative names of the artist.</param>
/// <param name="genres">The list of genres associated with the artist.</param>
/// <param name="tags">The list of tags associated with the artist.</param>
/// <param name="ratings">The list of ratings of the artist.</param>
/// <param name="contributors">The list of the media contributors that make up the artist.</param> /// <param name="contributors">The list of the media contributors that make up the artist.</param>
/// <param name="albums">The list of albums of the artist.</param> /// <param name="albums">The list of albums of the artist.</param>
/// <param name="createdOnUtc">The date and time when the entity was created.</param> /// <param name="createdOnUtc">The date and time when the entity was created.</param>
@@ -152,8 +362,25 @@ public sealed class Artist : AggregateRoot<ArtistId>
ArtistId id, ArtistId id,
LibraryId libraryId, LibraryId libraryId,
string name, string name,
Optional<string> sortName,
Optional<string> disambiguation,
Optional<MusicArtistType> type,
Optional<MusicArtistGender> gender,
Optional<string> country,
Optional<MusicArea> area,
Optional<MusicArea> beginArea,
Optional<MusicArea> endArea,
Optional<DateOnly> lifeSpanBegin,
Optional<DateOnly> lifeSpanEnd,
bool isEnded,
Optional<string> website, Optional<string> website,
Optional<MusicBrainzId> musicBrainzArtistId, Optional<MusicBrainzId> musicBrainzArtistId,
List<string> ipis,
List<string> isnis,
List<MusicArtistAlias> aliases,
List<Genre> genres,
List<Tag> tags,
List<AudioRating> ratings,
List<MusicMediaContributor> contributors, List<MusicMediaContributor> contributors,
List<Album> albums, List<Album> albums,
DateTime createdOnUtc, DateTime createdOnUtc,
@@ -168,8 +395,25 @@ public sealed class Artist : AggregateRoot<ArtistId>
id, id,
libraryId, libraryId,
name, name,
sortName,
disambiguation,
type,
gender,
country,
area,
beginArea,
endArea,
lifeSpanBegin,
lifeSpanEnd,
isEnded,
website, website,
musicBrainzArtistId, musicBrainzArtistId,
ipis,
isnis,
aliases,
genres,
tags,
ratings,
contributors, contributors,
albums, albums,
createdOnUtc, createdOnUtc,
@@ -216,14 +460,102 @@ public sealed class Artist : AggregateRoot<ArtistId>
} }
/// <summary> /// <summary>
/// Updates the details of the artist, without touching the albums and the media contributors. /// Replaces the aliases of the artist with the provided <paramref name="aliases"/>.
/// </summary>
/// <param name="aliases">The alternative names of the artist.</param>
public void UpdateAliases(IReadOnlyCollection<MusicArtistAlias> aliases)
{
// Replace the contents of the collection in place, preserving the readonly reference invariants of the aggregate.
_aliases.Clear();
_aliases.AddRange(aliases);
}
/// <summary>
/// Replaces the IPI codes of the artist with the provided <paramref name="ipis"/>.
/// </summary>
/// <param name="ipis">The IPI codes of the artist.</param>
public void UpdateIpis(IReadOnlyCollection<string> ipis)
{
// Replace the contents of the collection in place, preserving the readonly reference invariants of the aggregate.
_ipis.Clear();
_ipis.AddRange(ipis);
}
/// <summary>
/// Replaces the ISNI codes of the artist with the provided <paramref name="isnis"/>.
/// </summary>
/// <param name="isnis">The ISNI codes of the artist.</param>
public void UpdateIsnis(IReadOnlyCollection<string> isnis)
{
// Replace the contents of the collection in place, preserving the readonly reference invariants of the aggregate.
_isnis.Clear();
_isnis.AddRange(isnis);
}
/// <summary>
/// Replaces the genres of the artist with the provided <paramref name="genres"/>.
/// </summary>
/// <param name="genres">The genres of the artist.</param>
public void UpdateGenres(IReadOnlyCollection<Genre> genres)
{
// Replace the contents of the collection in place, preserving the readonly reference invariants of the aggregate.
_genres.Clear();
_genres.AddRange(genres);
}
/// <summary>
/// Replaces the tags of the artist with the provided <paramref name="tags"/>.
/// </summary>
/// <param name="tags">The tags of the artist.</param>
public void UpdateTags(IReadOnlyCollection<Tag> tags)
{
// Replace the contents of the collection in place, preserving the readonly reference invariants of the aggregate.
_tags.Clear();
_tags.AddRange(tags);
}
/// <summary>
/// Replaces the ratings of the artist with the provided <paramref name="ratings"/>.
/// </summary>
/// <param name="ratings">The ratings of the artist.</param>
public void UpdateRatings(IReadOnlyCollection<AudioRating> ratings)
{
// Replace the contents of the collection in place, preserving the readonly reference invariants of the aggregate.
_ratings.Clear();
_ratings.AddRange(ratings);
}
/// <summary>
/// Updates the details of the artist, without touching the albums, the contributors, and the media library metadata collections.
/// </summary> /// </summary>
/// <param name="name">The name of the artist.</param> /// <param name="name">The name of the artist.</param>
/// <param name="sortName">The optional sort name of the artist.</param>
/// <param name="disambiguation">The optional disambiguation comment of the artist.</param>
/// <param name="type">The optional type of the artist.</param>
/// <param name="gender">The optional gender of the artist.</param>
/// <param name="country">The optional ISO 3166-1 alpha-2 code of the country of the artist.</param>
/// <param name="area">The optional area the artist is primarily identified with.</param>
/// <param name="beginArea">The optional area the artist began in.</param>
/// <param name="endArea">The optional area the artist ended in.</param>
/// <param name="lifeSpanBegin">The optional date the artist started existing.</param>
/// <param name="lifeSpanEnd">The optional date the artist stopped existing.</param>
/// <param name="isEnded">Whether the artist no longer exists.</param>
/// <param name="website">The optional website of the artist.</param> /// <param name="website">The optional website of the artist.</param>
/// <param name="musicBrainzArtistId">The optional MusicBrainz identifier of the artist.</param> /// <param name="musicBrainzArtistId">The optional MusicBrainz identifier of the artist.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns> /// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
public Result<Updated> UpdateDetails( public Result<Updated> UpdateDetails(
string name, string name,
Optional<string> sortName,
Optional<string> disambiguation,
Optional<MusicArtistType> type,
Optional<MusicArtistGender> gender,
Optional<string> country,
Optional<MusicArea> area,
Optional<MusicArea> beginArea,
Optional<MusicArea> endArea,
Optional<DateOnly> lifeSpanBegin,
Optional<DateOnly> lifeSpanEnd,
bool isEnded,
Optional<string> website, Optional<string> website,
Optional<MusicBrainzId> musicBrainzArtistId) Optional<MusicBrainzId> musicBrainzArtistId)
{ {
@@ -231,6 +563,17 @@ public sealed class Artist : AggregateRoot<ArtistId>
return Errors.Music.ArtistNameCannotBeEmpty; return Errors.Music.ArtistNameCannotBeEmpty;
Name = name; Name = name;
SortName = sortName;
Disambiguation = disambiguation;
Type = type;
Gender = gender;
Country = country;
Area = area;
BeginArea = beginArea;
EndArea = endArea;
LifeSpanBegin = lifeSpanBegin;
LifeSpanEnd = lifeSpanEnd;
IsEnded = isEnded;
Website = website; Website = website;
MusicBrainzArtistId = musicBrainzArtistId; MusicBrainzArtistId = musicBrainzArtistId;
UpdatedOnUtc = Optional<DateTime>.Some(DateTime.UtcNow); UpdatedOnUtc = Optional<DateTime>.Some(DateTime.UtcNow);
@@ -247,9 +590,14 @@ public sealed class Artist : AggregateRoot<ArtistId>
/// </remarks> /// </remarks>
/// <param name="album">The album to update.</param> /// <param name="album">The album to update.</param>
/// <param name="metadata">The album metadata of the album.</param> /// <param name="metadata">The album metadata of the album.</param>
/// <param name="disambiguation">The optional disambiguation comment of the album.</param>
/// <param name="mediaFormat">The optional physical or digital medium of the album.</param> /// <param name="mediaFormat">The optional physical or digital medium of the album.</param>
/// <param name="packaging">The optional outermost physical packaging of the album.</param>
/// <param name="script">The optional script used by the language of the release of the album.</param>
/// <param name="barcode">The optional barcode of the album.</param> /// <param name="barcode">The optional barcode of the album.</param>
/// <param name="catalogNumber">The optional catalog number of the album.</param> /// <param name="catalogNumbers">The catalog numbers of the album.</param>
/// <param name="label">The optional name of the label that issued the album.</param>
/// <param name="asin">The optional ASIN of the album.</param>
/// <param name="musicBrainzReleaseId">The optional MusicBrainz identifier of the release.</param> /// <param name="musicBrainzReleaseId">The optional MusicBrainz identifier of the release.</param>
/// <param name="musicBrainzReleaseGroupId">The optional MusicBrainz identifier of the release group.</param> /// <param name="musicBrainzReleaseGroupId">The optional MusicBrainz identifier of the release group.</param>
/// <param name="musicBrainzReleaseArtistId">The optional MusicBrainz identifier of the release artist.</param> /// <param name="musicBrainzReleaseArtistId">The optional MusicBrainz identifier of the release artist.</param>
@@ -259,9 +607,14 @@ public sealed class Artist : AggregateRoot<ArtistId>
public Result<Updated> UpdateAlbum( public Result<Updated> UpdateAlbum(
Album album, Album album,
AlbumMetadata metadata, AlbumMetadata metadata,
Optional<string> disambiguation,
Optional<MusicMediaFormat> mediaFormat, Optional<MusicMediaFormat> mediaFormat,
Optional<MusicReleasePackaging> packaging,
Optional<string> script,
Optional<Barcode> barcode, Optional<Barcode> barcode,
Optional<string> catalogNumber, List<string> catalogNumbers,
Optional<string> label,
Optional<string> asin,
Optional<MusicBrainzId> musicBrainzReleaseId, Optional<MusicBrainzId> musicBrainzReleaseId,
Optional<MusicBrainzId> musicBrainzReleaseGroupId, Optional<MusicBrainzId> musicBrainzReleaseGroupId,
Optional<MusicBrainzId> musicBrainzReleaseArtistId, Optional<MusicBrainzId> musicBrainzReleaseArtistId,
@@ -272,7 +625,7 @@ public sealed class Artist : AggregateRoot<ArtistId>
if (!_albums.Contains(album)) if (!_albums.Contains(album))
return Errors.Music.AlbumNotFound; return Errors.Music.AlbumNotFound;
album.UpdateDetails(metadata, mediaFormat, barcode, catalogNumber, musicBrainzReleaseId, musicBrainzReleaseGroupId, musicBrainzReleaseArtistId); album.UpdateDetails(metadata, disambiguation, mediaFormat, packaging, script, barcode, catalogNumbers, label, asin, musicBrainzReleaseId, musicBrainzReleaseGroupId, musicBrainzReleaseArtistId);
album.UpdateContributors(contributors); album.UpdateContributors(contributors);
album.UpdateRatings(ratings); album.UpdateRatings(ratings);
UpdatedOnUtc = Optional<DateTime>.Some(DateTime.UtcNow); UpdatedOnUtc = Optional<DateTime>.Some(DateTime.UtcNow);
@@ -296,10 +649,10 @@ public sealed class Artist : AggregateRoot<ArtistId>
/// <param name="script">The optional script used by the language of the track.</param> /// <param name="script">The optional script used by the language of the track.</param>
/// <param name="key">The optional musical key of the track.</param> /// <param name="key">The optional musical key of the track.</param>
/// <param name="bpm">The optional tempo of the track in beats per minute.</param> /// <param name="bpm">The optional tempo of the track in beats per minute.</param>
/// <param name="work">The optional title of the work the track is a recording of.</param> /// <param name="isVideo">Whether the recording of the track is a video recording.</param>
/// <param name="work">The optional work the track is a recording of.</param>
/// <param name="musicBrainzRecordingId">The optional MusicBrainz identifier of the recording.</param> /// <param name="musicBrainzRecordingId">The optional MusicBrainz identifier of the recording.</param>
/// <param name="musicBrainzTrackId">The optional MusicBrainz identifier of the track.</param> /// <param name="musicBrainzTrackId">The optional MusicBrainz identifier of the track.</param>
/// <param name="musicBrainzWorkId">The optional MusicBrainz identifier of the work.</param>
/// <param name="moods">The moods of the track.</param> /// <param name="moods">The moods of the track.</param>
/// <param name="isrcs">The ISRCs of the track.</param> /// <param name="isrcs">The ISRCs of the track.</param>
/// <param name="contributors">The media contributors of the track.</param> /// <param name="contributors">The media contributors of the track.</param>
@@ -315,10 +668,10 @@ public sealed class Artist : AggregateRoot<ArtistId>
Optional<string> script, Optional<string> script,
Optional<MusicKey> key, Optional<MusicKey> key,
Optional<int> bpm, Optional<int> bpm,
Optional<string> work, bool isVideo,
Optional<MusicWork> work,
Optional<MusicBrainzId> musicBrainzRecordingId, Optional<MusicBrainzId> musicBrainzRecordingId,
Optional<MusicBrainzId> musicBrainzTrackId, Optional<MusicBrainzId> musicBrainzTrackId,
Optional<MusicBrainzId> musicBrainzWorkId,
IReadOnlyCollection<Mood> moods, IReadOnlyCollection<Mood> moods,
IReadOnlyCollection<Isrc> isrcs, IReadOnlyCollection<Isrc> isrcs,
IReadOnlyCollection<MusicMediaContributor> contributors, IReadOnlyCollection<MusicMediaContributor> contributors,
@@ -338,10 +691,10 @@ public sealed class Artist : AggregateRoot<ArtistId>
script, script,
key, key,
bpm, bpm,
isVideo,
work, work,
musicBrainzRecordingId, musicBrainzRecordingId,
musicBrainzTrackId, musicBrainzTrackId);
musicBrainzWorkId);
track.UpdateMoods(moods); track.UpdateMoods(moods);
track.UpdateIsrcs(isrcs); track.UpdateIsrcs(isrcs);
track.UpdateContributors(contributors); track.UpdateContributors(contributors);
@@ -21,26 +21,52 @@ public sealed class Album : Entity<AlbumId>
private readonly List<MusicMediaContributor> _contributors; private readonly List<MusicMediaContributor> _contributors;
private readonly List<AudioRating> _ratings; private readonly List<AudioRating> _ratings;
private readonly List<Track> _tracks; private readonly List<Track> _tracks;
private readonly List<string> _catalogNumbers;
/// <summary> /// <summary>
/// Gets the album metadata of the album. /// Gets the album metadata of the album.
/// </summary> /// </summary>
public AlbumMetadata Metadata { get; private set; } public AlbumMetadata Metadata { get; private set; }
/// <summary>
/// Gets the disambiguation comment of the album, used to distinguish albums with the same title, if applicable.
/// </summary>
public Optional<string> Disambiguation { get; private set; }
/// <summary> /// <summary>
/// Gets the physical or digital medium of the album, if applicable. /// Gets the physical or digital medium of the album, if applicable.
/// </summary> /// </summary>
public Optional<MusicMediaFormat> MediaFormat { get; private set; } public Optional<MusicMediaFormat> MediaFormat { get; private set; }
/// <summary>
/// Gets the outermost physical packaging of the album, if applicable.
/// </summary>
public Optional<MusicReleasePackaging> Packaging { get; private set; }
/// <summary>
/// Gets the script used by the language of the release of the album, if applicable.
/// </summary>
public Optional<string> Script { get; private set; }
/// <summary> /// <summary>
/// Gets the barcode of the album, if applicable. /// Gets the barcode of the album, if applicable.
/// </summary> /// </summary>
public Optional<Barcode> Barcode { get; private set; } public Optional<Barcode> Barcode { get; private set; }
/// <summary> /// <summary>
/// Gets the catalog number of the album, if applicable. /// Gets the catalog numbers of the album.
/// </summary> /// </summary>
public Optional<string> CatalogNumber { get; private set; } public IReadOnlyCollection<string> CatalogNumbers => _catalogNumbers.AsReadOnly();
/// <summary>
/// Gets the name of the label that issued the album, if applicable.
/// </summary>
public Optional<string> Label { get; private set; }
/// <summary>
/// Gets the ASIN (Amazon Standard Identification Number) of the album, if applicable.
/// </summary>
public Optional<string> ASIN { get; private set; }
/// <summary> /// <summary>
/// Gets the MusicBrainz identifier of the release, if applicable. /// Gets the MusicBrainz identifier of the release, if applicable.
@@ -77,9 +103,14 @@ public sealed class Album : Entity<AlbumId>
/// </summary> /// </summary>
/// <param name="id">The object representing the unique identifier of the album.</param> /// <param name="id">The object representing the unique identifier of the album.</param>
/// <param name="metadata">The album metadata of the album.</param> /// <param name="metadata">The album metadata of the album.</param>
/// <param name="disambiguation">The optional disambiguation comment of the album.</param>
/// <param name="mediaFormat">The optional physical or digital medium of the album.</param> /// <param name="mediaFormat">The optional physical or digital medium of the album.</param>
/// <param name="packaging">The optional outermost physical packaging of the album.</param>
/// <param name="script">The optional script used by the language of the release of the album.</param>
/// <param name="barcode">The optional barcode of the album.</param> /// <param name="barcode">The optional barcode of the album.</param>
/// <param name="catalogNumber">The optional catalog number of the album.</param> /// <param name="catalogNumbers">The catalog numbers of the album.</param>
/// <param name="label">The optional name of the label that issued the album.</param>
/// <param name="asin">The optional ASIN of the album.</param>
/// <param name="musicBrainzReleaseId">The optional MusicBrainz identifier of the release.</param> /// <param name="musicBrainzReleaseId">The optional MusicBrainz identifier of the release.</param>
/// <param name="musicBrainzReleaseGroupId">The optional MusicBrainz identifier of the release group.</param> /// <param name="musicBrainzReleaseGroupId">The optional MusicBrainz identifier of the release group.</param>
/// <param name="musicBrainzReleaseArtistId">The optional MusicBrainz identifier of the release artist.</param> /// <param name="musicBrainzReleaseArtistId">The optional MusicBrainz identifier of the release artist.</param>
@@ -91,9 +122,14 @@ public sealed class Album : Entity<AlbumId>
private Album( private Album(
AlbumId id, AlbumId id,
AlbumMetadata metadata, AlbumMetadata metadata,
Optional<string> disambiguation,
Optional<MusicMediaFormat> mediaFormat, Optional<MusicMediaFormat> mediaFormat,
Optional<MusicReleasePackaging> packaging,
Optional<string> script,
Optional<Barcode> barcode, Optional<Barcode> barcode,
Optional<string> catalogNumber, List<string> catalogNumbers,
Optional<string> label,
Optional<string> asin,
Optional<MusicBrainzId> musicBrainzReleaseId, Optional<MusicBrainzId> musicBrainzReleaseId,
Optional<MusicBrainzId> musicBrainzReleaseGroupId, Optional<MusicBrainzId> musicBrainzReleaseGroupId,
Optional<MusicBrainzId> musicBrainzReleaseArtistId, Optional<MusicBrainzId> musicBrainzReleaseArtistId,
@@ -105,9 +141,14 @@ public sealed class Album : Entity<AlbumId>
{ {
Id = id; Id = id;
Metadata = metadata; Metadata = metadata;
Disambiguation = disambiguation;
MediaFormat = mediaFormat; MediaFormat = mediaFormat;
Packaging = packaging;
Script = script;
Barcode = barcode; Barcode = barcode;
CatalogNumber = catalogNumber; _catalogNumbers = catalogNumbers;
Label = label;
ASIN = asin;
MusicBrainzReleaseId = musicBrainzReleaseId; MusicBrainzReleaseId = musicBrainzReleaseId;
MusicBrainzReleaseGroupId = musicBrainzReleaseGroupId; MusicBrainzReleaseGroupId = musicBrainzReleaseGroupId;
MusicBrainzReleaseArtistId = musicBrainzReleaseArtistId; MusicBrainzReleaseArtistId = musicBrainzReleaseArtistId;
@@ -122,9 +163,14 @@ public sealed class Album : Entity<AlbumId>
/// Creates a new instance of the <see cref="Album"/> class. /// Creates a new instance of the <see cref="Album"/> class.
/// </summary> /// </summary>
/// <param name="metadata">The album metadata of the album.</param> /// <param name="metadata">The album metadata of the album.</param>
/// <param name="disambiguation">The optional disambiguation comment of the album.</param>
/// <param name="mediaFormat">The optional physical or digital medium of the album.</param> /// <param name="mediaFormat">The optional physical or digital medium of the album.</param>
/// <param name="packaging">The optional outermost physical packaging of the album.</param>
/// <param name="script">The optional script used by the language of the release of the album.</param>
/// <param name="barcode">The optional barcode of the album.</param> /// <param name="barcode">The optional barcode of the album.</param>
/// <param name="catalogNumber">The optional catalog number of the album.</param> /// <param name="catalogNumbers">The catalog numbers of the album.</param>
/// <param name="label">The optional name of the label that issued the album.</param>
/// <param name="asin">The optional ASIN of the album.</param>
/// <param name="musicBrainzReleaseId">The optional MusicBrainz identifier of the release.</param> /// <param name="musicBrainzReleaseId">The optional MusicBrainz identifier of the release.</param>
/// <param name="musicBrainzReleaseGroupId">The optional MusicBrainz identifier of the release group.</param> /// <param name="musicBrainzReleaseGroupId">The optional MusicBrainz identifier of the release group.</param>
/// <param name="musicBrainzReleaseArtistId">The optional MusicBrainz identifier of the release artist.</param> /// <param name="musicBrainzReleaseArtistId">The optional MusicBrainz identifier of the release artist.</param>
@@ -136,9 +182,14 @@ public sealed class Album : Entity<AlbumId>
/// </returns> /// </returns>
public static Result<Album> Create( public static Result<Album> Create(
AlbumMetadata metadata, AlbumMetadata metadata,
Optional<string> disambiguation,
Optional<MusicMediaFormat> mediaFormat, Optional<MusicMediaFormat> mediaFormat,
Optional<MusicReleasePackaging> packaging,
Optional<string> script,
Optional<Barcode> barcode, Optional<Barcode> barcode,
Optional<string> catalogNumber, List<string> catalogNumbers,
Optional<string> label,
Optional<string> asin,
Optional<MusicBrainzId> musicBrainzReleaseId, Optional<MusicBrainzId> musicBrainzReleaseId,
Optional<MusicBrainzId> musicBrainzReleaseGroupId, Optional<MusicBrainzId> musicBrainzReleaseGroupId,
Optional<MusicBrainzId> musicBrainzReleaseArtistId, Optional<MusicBrainzId> musicBrainzReleaseArtistId,
@@ -149,9 +200,14 @@ public sealed class Album : Entity<AlbumId>
return new Album( return new Album(
AlbumId.CreateUnique(), AlbumId.CreateUnique(),
metadata, metadata,
disambiguation,
mediaFormat, mediaFormat,
packaging,
script,
barcode, barcode,
catalogNumber, catalogNumbers,
label,
asin,
musicBrainzReleaseId, musicBrainzReleaseId,
musicBrainzReleaseGroupId, musicBrainzReleaseGroupId,
musicBrainzReleaseArtistId, musicBrainzReleaseArtistId,
@@ -167,9 +223,14 @@ public sealed class Album : Entity<AlbumId>
/// </summary> /// </summary>
/// <param name="id">The object representing the unique identifier of the album.</param> /// <param name="id">The object representing the unique identifier of the album.</param>
/// <param name="metadata">The album metadata of the album.</param> /// <param name="metadata">The album metadata of the album.</param>
/// <param name="disambiguation">The optional disambiguation comment of the album.</param>
/// <param name="mediaFormat">The optional physical or digital medium of the album.</param> /// <param name="mediaFormat">The optional physical or digital medium of the album.</param>
/// <param name="packaging">The optional outermost physical packaging of the album.</param>
/// <param name="script">The optional script used by the language of the release of the album.</param>
/// <param name="barcode">The optional barcode of the album.</param> /// <param name="barcode">The optional barcode of the album.</param>
/// <param name="catalogNumber">The optional catalog number of the album.</param> /// <param name="catalogNumbers">The catalog numbers of the album.</param>
/// <param name="label">The optional name of the label that issued the album.</param>
/// <param name="asin">The optional ASIN of the album.</param>
/// <param name="musicBrainzReleaseId">The optional MusicBrainz identifier of the release.</param> /// <param name="musicBrainzReleaseId">The optional MusicBrainz identifier of the release.</param>
/// <param name="musicBrainzReleaseGroupId">The optional MusicBrainz identifier of the release group.</param> /// <param name="musicBrainzReleaseGroupId">The optional MusicBrainz identifier of the release group.</param>
/// <param name="musicBrainzReleaseArtistId">The optional MusicBrainz identifier of the release artist.</param> /// <param name="musicBrainzReleaseArtistId">The optional MusicBrainz identifier of the release artist.</param>
@@ -184,9 +245,14 @@ public sealed class Album : Entity<AlbumId>
public static Result<Album> Create( public static Result<Album> Create(
AlbumId id, AlbumId id,
AlbumMetadata metadata, AlbumMetadata metadata,
Optional<string> disambiguation,
Optional<MusicMediaFormat> mediaFormat, Optional<MusicMediaFormat> mediaFormat,
Optional<MusicReleasePackaging> packaging,
Optional<string> script,
Optional<Barcode> barcode, Optional<Barcode> barcode,
Optional<string> catalogNumber, List<string> catalogNumbers,
Optional<string> label,
Optional<string> asin,
Optional<MusicBrainzId> musicBrainzReleaseId, Optional<MusicBrainzId> musicBrainzReleaseId,
Optional<MusicBrainzId> musicBrainzReleaseGroupId, Optional<MusicBrainzId> musicBrainzReleaseGroupId,
Optional<MusicBrainzId> musicBrainzReleaseArtistId, Optional<MusicBrainzId> musicBrainzReleaseArtistId,
@@ -199,9 +265,14 @@ public sealed class Album : Entity<AlbumId>
return new Album( return new Album(
id, id,
metadata, metadata,
disambiguation,
mediaFormat, mediaFormat,
packaging,
script,
barcode, barcode,
catalogNumber, catalogNumbers,
label,
asin,
musicBrainzReleaseId, musicBrainzReleaseId,
musicBrainzReleaseGroupId, musicBrainzReleaseGroupId,
musicBrainzReleaseArtistId, musicBrainzReleaseArtistId,
@@ -264,26 +335,42 @@ public sealed class Album : Entity<AlbumId>
/// Updates the details of the album, without touching the ratings, the media contributors, and the tracks. /// Updates the details of the album, without touching the ratings, the media contributors, and the tracks.
/// </summary> /// </summary>
/// <param name="metadata">The album metadata of the album.</param> /// <param name="metadata">The album metadata of the album.</param>
/// <param name="disambiguation">The optional disambiguation comment of the album.</param>
/// <param name="mediaFormat">The optional physical or digital medium of the album.</param> /// <param name="mediaFormat">The optional physical or digital medium of the album.</param>
/// <param name="packaging">The optional outermost physical packaging of the album.</param>
/// <param name="script">The optional script used by the language of the release of the album.</param>
/// <param name="barcode">The optional barcode of the album.</param> /// <param name="barcode">The optional barcode of the album.</param>
/// <param name="catalogNumber">The optional catalog number of the album.</param> /// <param name="catalogNumbers">The catalog numbers of the album.</param>
/// <param name="label">The optional name of the label that issued the album.</param>
/// <param name="asin">The optional ASIN of the album.</param>
/// <param name="musicBrainzReleaseId">The optional MusicBrainz identifier of the release.</param> /// <param name="musicBrainzReleaseId">The optional MusicBrainz identifier of the release.</param>
/// <param name="musicBrainzReleaseGroupId">The optional MusicBrainz identifier of the release group.</param> /// <param name="musicBrainzReleaseGroupId">The optional MusicBrainz identifier of the release group.</param>
/// <param name="musicBrainzReleaseArtistId">The optional MusicBrainz identifier of the release artist.</param> /// <param name="musicBrainzReleaseArtistId">The optional MusicBrainz identifier of the release artist.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns> /// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
internal Result<Updated> UpdateDetails( internal Result<Updated> UpdateDetails(
AlbumMetadata metadata, AlbumMetadata metadata,
Optional<string> disambiguation,
Optional<MusicMediaFormat> mediaFormat, Optional<MusicMediaFormat> mediaFormat,
Optional<MusicReleasePackaging> packaging,
Optional<string> script,
Optional<Barcode> barcode, Optional<Barcode> barcode,
Optional<string> catalogNumber, List<string> catalogNumbers,
Optional<string> label,
Optional<string> asin,
Optional<MusicBrainzId> musicBrainzReleaseId, Optional<MusicBrainzId> musicBrainzReleaseId,
Optional<MusicBrainzId> musicBrainzReleaseGroupId, Optional<MusicBrainzId> musicBrainzReleaseGroupId,
Optional<MusicBrainzId> musicBrainzReleaseArtistId) Optional<MusicBrainzId> musicBrainzReleaseArtistId)
{ {
Metadata = metadata; Metadata = metadata;
Disambiguation = disambiguation;
MediaFormat = mediaFormat; MediaFormat = mediaFormat;
Packaging = packaging;
Script = script;
Barcode = barcode; Barcode = barcode;
CatalogNumber = catalogNumber; _catalogNumbers.Clear();
_catalogNumbers.AddRange(catalogNumbers);
Label = label;
ASIN = asin;
MusicBrainzReleaseId = musicBrainzReleaseId; MusicBrainzReleaseId = musicBrainzReleaseId;
MusicBrainzReleaseGroupId = musicBrainzReleaseGroupId; MusicBrainzReleaseGroupId = musicBrainzReleaseGroupId;
MusicBrainzReleaseArtistId = musicBrainzReleaseArtistId; MusicBrainzReleaseArtistId = musicBrainzReleaseArtistId;
@@ -34,6 +34,11 @@ public sealed class Track : Entity<TrackId>
/// </summary> /// </summary>
public AudioMetadata Metadata { get; private set; } public AudioMetadata Metadata { get; private set; }
/// <summary>
/// Gets the disambiguation comment of the track, used to distinguish tracks with the same title, if applicable.
/// </summary>
public Optional<string> Disambiguation { get; private set; }
/// <summary> /// <summary>
/// Gets the number of the track on its disc. /// Gets the number of the track on its disc.
/// </summary> /// </summary>
@@ -60,9 +65,14 @@ public sealed class Track : Entity<TrackId>
public Optional<int> Bpm { get; private set; } public Optional<int> Bpm { get; private set; }
/// <summary> /// <summary>
/// Gets the title of the work the track is a recording of, if applicable. /// Gets a value indicating whether the recording of the track is a video recording.
/// </summary> /// </summary>
public Optional<string> Work { get; private set; } public bool IsVideo { get; private set; }
/// <summary>
/// Gets the work the track is a recording of, if applicable.
/// </summary>
public Optional<MusicWork> Work { get; private set; }
/// <summary> /// <summary>
/// Gets the MusicBrainz identifier of the recording, if applicable. /// Gets the MusicBrainz identifier of the recording, if applicable.
@@ -74,11 +84,6 @@ public sealed class Track : Entity<TrackId>
/// </summary> /// </summary>
public Optional<MusicBrainzId> MusicBrainzTrackId { get; private set; } public Optional<MusicBrainzId> MusicBrainzTrackId { get; private set; }
/// <summary>
/// Gets the MusicBrainz identifier of the work, if applicable.
/// </summary>
public Optional<MusicBrainzId> MusicBrainzWorkId { get; private set; }
/// <summary> /// <summary>
/// Gets the list of moods of the track. /// Gets the list of moods of the track.
/// </summary> /// </summary>
@@ -105,36 +110,38 @@ public sealed class Track : Entity<TrackId>
/// <param name="id">The object representing the unique identifier of the track.</param> /// <param name="id">The object representing the unique identifier of the track.</param>
/// <param name="path">The file system path of the track.</param> /// <param name="path">The file system path of the track.</param>
/// <param name="metadata">The audio metadata of the track.</param> /// <param name="metadata">The audio metadata of the track.</param>
/// <param name="disambiguation">The optional disambiguation comment of the track.</param>
/// <param name="trackNumber">The number of the track on its disc.</param> /// <param name="trackNumber">The number of the track on its disc.</param>
/// <param name="discNumber">The optional number of the disc the track belongs to.</param> /// <param name="discNumber">The optional number of the disc the track belongs to.</param>
/// <param name="moods">The list of moods of the track.</param> /// <param name="moods">The list of moods of the track.</param>
/// <param name="script">The optional script used by the language of the track.</param> /// <param name="script">The optional script used by the language of the track.</param>
/// <param name="key">The optional musical key of the track.</param> /// <param name="key">The optional musical key of the track.</param>
/// <param name="bpm">The optional tempo of the track in beats per minute.</param> /// <param name="bpm">The optional tempo of the track in beats per minute.</param>
/// <param name="isVideo">Whether the recording of the track is a video recording.</param>
/// <param name="isrcs">The list of ISRC of the track.</param> /// <param name="isrcs">The list of ISRC of the track.</param>
/// <param name="work">The optional title of the work the track is a recording of.</param> /// <param name="work">The optional work the track is a recording of.</param>
/// <param name="musicBrainzRecordingId">The optional MusicBrainz identifier of the recording.</param> /// <param name="musicBrainzRecordingId">The optional MusicBrainz identifier of the recording.</param>
/// <param name="musicBrainzTrackId">The optional MusicBrainz identifier of the track.</param> /// <param name="musicBrainzTrackId">The optional MusicBrainz identifier of the track.</param>
/// <param name="musicBrainzWorkId">The optional MusicBrainz identifier of the work.</param>
/// <param name="contributors">The list of the media contributors of the track.</param> /// <param name="contributors">The list of the media contributors of the track.</param>
/// <param name="ratings">The list of ratings for the track.</param> /// <param name="ratings">The list of ratings of the track.</param>
/// <param name="createdOnUtc">The date and time when the entity was created.</param> /// <param name="createdOnUtc">The date and time when the entity was created.</param>
/// <param name="updatedOnUtc">The date and time when the entity was last updated.</param> /// <param name="updatedOnUtc">The date and time when the entity was last updated.</param>
private Track( private Track(
TrackId id, TrackId id,
string path, string path,
AudioMetadata metadata, AudioMetadata metadata,
Optional<string> disambiguation,
int trackNumber, int trackNumber,
Optional<int> discNumber, Optional<int> discNumber,
List<Mood> moods, List<Mood> moods,
Optional<string> script, Optional<string> script,
Optional<MusicKey> key, Optional<MusicKey> key,
Optional<int> bpm, Optional<int> bpm,
bool isVideo,
List<Isrc> isrcs, List<Isrc> isrcs,
Optional<string> work, Optional<MusicWork> work,
Optional<MusicBrainzId> musicBrainzRecordingId, Optional<MusicBrainzId> musicBrainzRecordingId,
Optional<MusicBrainzId> musicBrainzTrackId, Optional<MusicBrainzId> musicBrainzTrackId,
Optional<MusicBrainzId> musicBrainzWorkId,
List<MusicMediaContributor> contributors, List<MusicMediaContributor> contributors,
List<AudioRating> ratings, List<AudioRating> ratings,
DateTime createdOnUtc, DateTime createdOnUtc,
@@ -143,6 +150,7 @@ public sealed class Track : Entity<TrackId>
Id = id; Id = id;
Path = path; Path = path;
Metadata = metadata; Metadata = metadata;
Disambiguation = disambiguation;
TrackNumber = trackNumber; TrackNumber = trackNumber;
DiscNumber = discNumber; DiscNumber = discNumber;
_moods = moods; _moods = moods;
@@ -150,10 +158,10 @@ public sealed class Track : Entity<TrackId>
Script = script; Script = script;
Key = key; Key = key;
Bpm = bpm; Bpm = bpm;
IsVideo = isVideo;
Work = work; Work = work;
MusicBrainzRecordingId = musicBrainzRecordingId; MusicBrainzRecordingId = musicBrainzRecordingId;
MusicBrainzTrackId = musicBrainzTrackId; MusicBrainzTrackId = musicBrainzTrackId;
MusicBrainzWorkId = musicBrainzWorkId;
_contributors = contributors; _contributors = contributors;
_ratings = ratings; _ratings = ratings;
CreatedOnUtc = createdOnUtc; CreatedOnUtc = createdOnUtc;
@@ -165,36 +173,38 @@ public sealed class Track : Entity<TrackId>
/// </summary> /// </summary>
/// <param name="path">The file system path of the track.</param> /// <param name="path">The file system path of the track.</param>
/// <param name="metadata">The audio metadata of the track.</param> /// <param name="metadata">The audio metadata of the track.</param>
/// <param name="disambiguation">The optional disambiguation comment of the track.</param>
/// <param name="trackNumber">The number of the track on its disc.</param> /// <param name="trackNumber">The number of the track on its disc.</param>
/// <param name="discNumber">The optional number of the disc the track belongs to.</param> /// <param name="discNumber">The optional number of the disc the track belongs to.</param>
/// <param name="moods">The list of moods of the track.</param> /// <param name="moods">The list of moods of the track.</param>
/// <param name="script">The optional script used by the language of the track.</param> /// <param name="script">The optional script used by the language of the track.</param>
/// <param name="key">The optional musical key of the track.</param> /// <param name="key">The optional musical key of the track.</param>
/// <param name="bpm">The optional tempo of the track in beats per minute.</param> /// <param name="bpm">The optional tempo of the track in beats per minute.</param>
/// <param name="isVideo">Whether the recording of the track is a video recording.</param>
/// <param name="isrcs">The list of ISRC of the track.</param> /// <param name="isrcs">The list of ISRC of the track.</param>
/// <param name="work">The optional title of the work the track is a recording of.</param> /// <param name="work">The optional work the track is a recording of.</param>
/// <param name="musicBrainzRecordingId">The optional MusicBrainz identifier of the recording.</param> /// <param name="musicBrainzRecordingId">The optional MusicBrainz identifier of the recording.</param>
/// <param name="musicBrainzTrackId">The optional MusicBrainz identifier of the track.</param> /// <param name="musicBrainzTrackId">The optional MusicBrainz identifier of the track.</param>
/// <param name="musicBrainzWorkId">The optional MusicBrainz identifier of the work.</param>
/// <param name="contributors">The list of the media contributors of the track.</param> /// <param name="contributors">The list of the media contributors of the track.</param>
/// <param name="ratings">The list of ratings for the track.</param> /// <param name="ratings">The list of ratings of the track.</param>
/// <returns> /// <returns>
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Track"/>, or an error message. /// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Track"/>, or an error message.
/// </returns> /// </returns>
public static Result<Track> Create( public static Result<Track> Create(
string path, string path,
AudioMetadata metadata, AudioMetadata metadata,
Optional<string> disambiguation,
int trackNumber, int trackNumber,
Optional<int> discNumber, Optional<int> discNumber,
List<Mood> moods, List<Mood> moods,
Optional<string> script, Optional<string> script,
Optional<MusicKey> key, Optional<MusicKey> key,
Optional<int> bpm, Optional<int> bpm,
bool isVideo,
List<Isrc> isrcs, List<Isrc> isrcs,
Optional<string> work, Optional<MusicWork> work,
Optional<MusicBrainzId> musicBrainzRecordingId, Optional<MusicBrainzId> musicBrainzRecordingId,
Optional<MusicBrainzId> musicBrainzTrackId, Optional<MusicBrainzId> musicBrainzTrackId,
Optional<MusicBrainzId> musicBrainzWorkId,
List<MusicMediaContributor> contributors, List<MusicMediaContributor> contributors,
List<AudioRating> ratings) List<AudioRating> ratings)
{ {
@@ -202,17 +212,18 @@ public sealed class Track : Entity<TrackId>
TrackId.CreateUnique(), TrackId.CreateUnique(),
path, path,
metadata, metadata,
disambiguation,
trackNumber, trackNumber,
discNumber, discNumber,
moods, moods,
script, script,
key, key,
bpm, bpm,
isVideo,
isrcs, isrcs,
work, work,
musicBrainzRecordingId, musicBrainzRecordingId,
musicBrainzTrackId, musicBrainzTrackId,
musicBrainzWorkId,
contributors, contributors,
ratings, ratings,
DateTime.UtcNow, // TODO: should be IDateTimeProvider DateTime.UtcNow, // TODO: should be IDateTimeProvider
@@ -225,19 +236,20 @@ public sealed class Track : Entity<TrackId>
/// <param name="id">The object representing the unique identifier of the track.</param> /// <param name="id">The object representing the unique identifier of the track.</param>
/// <param name="path">The file system path of the track.</param> /// <param name="path">The file system path of the track.</param>
/// <param name="metadata">The audio metadata of the track.</param> /// <param name="metadata">The audio metadata of the track.</param>
/// <param name="disambiguation">The optional disambiguation comment of the track.</param>
/// <param name="trackNumber">The number of the track on its disc.</param> /// <param name="trackNumber">The number of the track on its disc.</param>
/// <param name="discNumber">The optional number of the disc the track belongs to.</param> /// <param name="discNumber">The optional number of the disc the track belongs to.</param>
/// <param name="moods">The list of moods of the track.</param> /// <param name="moods">The list of moods of the track.</param>
/// <param name="script">The optional script used by the language of the track.</param> /// <param name="script">The optional script used by the language of the track.</param>
/// <param name="key">The optional musical key of the track.</param> /// <param name="key">The optional musical key of the track.</param>
/// <param name="bpm">The optional tempo of the track in beats per minute.</param> /// <param name="bpm">The optional tempo of the track in beats per minute.</param>
/// <param name="isVideo">Whether the recording of the track is a video recording.</param>
/// <param name="isrcs">The list of ISRC of the track.</param> /// <param name="isrcs">The list of ISRC of the track.</param>
/// <param name="work">The optional title of the work the track is a recording of.</param> /// <param name="work">The optional work the track is a recording of.</param>
/// <param name="musicBrainzRecordingId">The optional MusicBrainz identifier of the recording.</param> /// <param name="musicBrainzRecordingId">The optional MusicBrainz identifier of the recording.</param>
/// <param name="musicBrainzTrackId">The optional MusicBrainz identifier of the track.</param> /// <param name="musicBrainzTrackId">The optional MusicBrainz identifier of the track.</param>
/// <param name="musicBrainzWorkId">The optional MusicBrainz identifier of the work.</param>
/// <param name="contributors">The list of the media contributors of the track.</param> /// <param name="contributors">The list of the media contributors of the track.</param>
/// <param name="ratings">The list of ratings for the track.</param> /// <param name="ratings">The list of ratings of the track.</param>
/// <param name="createdOnUtc">The date and time when the entity was created.</param> /// <param name="createdOnUtc">The date and time when the entity was created.</param>
/// <param name="updatedOnUtc">The date and time when the entity was last updated.</param> /// <param name="updatedOnUtc">The date and time when the entity was last updated.</param>
/// <returns> /// <returns>
@@ -247,17 +259,18 @@ public sealed class Track : Entity<TrackId>
TrackId id, TrackId id,
string path, string path,
AudioMetadata metadata, AudioMetadata metadata,
Optional<string> disambiguation,
int trackNumber, int trackNumber,
Optional<int> discNumber, Optional<int> discNumber,
List<Mood> moods, List<Mood> moods,
Optional<string> script, Optional<string> script,
Optional<MusicKey> key, Optional<MusicKey> key,
Optional<int> bpm, Optional<int> bpm,
bool isVideo,
List<Isrc> isrcs, List<Isrc> isrcs,
Optional<string> work, Optional<MusicWork> work,
Optional<MusicBrainzId> musicBrainzRecordingId, Optional<MusicBrainzId> musicBrainzRecordingId,
Optional<MusicBrainzId> musicBrainzTrackId, Optional<MusicBrainzId> musicBrainzTrackId,
Optional<MusicBrainzId> musicBrainzWorkId,
List<MusicMediaContributor> contributors, List<MusicMediaContributor> contributors,
List<AudioRating> ratings, List<AudioRating> ratings,
DateTime createdOnUtc, DateTime createdOnUtc,
@@ -267,17 +280,18 @@ public sealed class Track : Entity<TrackId>
id, id,
path, path,
metadata, metadata,
disambiguation,
trackNumber, trackNumber,
discNumber, discNumber,
moods, moods,
script, script,
key, key,
bpm, bpm,
isVideo,
isrcs, isrcs,
work, work,
musicBrainzRecordingId, musicBrainzRecordingId,
musicBrainzTrackId, musicBrainzTrackId,
musicBrainzWorkId,
contributors, contributors,
ratings, ratings,
createdOnUtc, createdOnUtc,
@@ -338,10 +352,10 @@ public sealed class Track : Entity<TrackId>
/// <param name="script">The optional script used by the language of the track.</param> /// <param name="script">The optional script used by the language of the track.</param>
/// <param name="key">The optional musical key of the track.</param> /// <param name="key">The optional musical key of the track.</param>
/// <param name="bpm">The optional tempo of the track in beats per minute.</param> /// <param name="bpm">The optional tempo of the track in beats per minute.</param>
/// <param name="work">The optional title of the work the track is a recording of.</param> /// <param name="isVideo">Whether the recording of the track is a video recording.</param>
/// <param name="work">The optional work the track is a recording of.</param>
/// <param name="musicBrainzRecordingId">The optional MusicBrainz identifier of the recording.</param> /// <param name="musicBrainzRecordingId">The optional MusicBrainz identifier of the recording.</param>
/// <param name="musicBrainzTrackId">The optional MusicBrainz identifier of the track.</param> /// <param name="musicBrainzTrackId">The optional MusicBrainz identifier of the track.</param>
/// <param name="musicBrainzWorkId">The optional MusicBrainz identifier of the work.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns> /// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
internal Result<Updated> UpdateDetails( internal Result<Updated> UpdateDetails(
string path, string path,
@@ -351,10 +365,10 @@ public sealed class Track : Entity<TrackId>
Optional<string> script, Optional<string> script,
Optional<MusicKey> key, Optional<MusicKey> key,
Optional<int> bpm, Optional<int> bpm,
Optional<string> work, bool isVideo,
Optional<MusicWork> work,
Optional<MusicBrainzId> musicBrainzRecordingId, Optional<MusicBrainzId> musicBrainzRecordingId,
Optional<MusicBrainzId> musicBrainzTrackId, Optional<MusicBrainzId> musicBrainzTrackId)
Optional<MusicBrainzId> musicBrainzWorkId)
{ {
Path = path; Path = path;
Metadata = metadata; Metadata = metadata;
@@ -363,10 +377,10 @@ public sealed class Track : Entity<TrackId>
Script = script; Script = script;
Key = key; Key = key;
Bpm = bpm; Bpm = bpm;
IsVideo = isVideo;
Work = work; Work = work;
MusicBrainzRecordingId = musicBrainzRecordingId; MusicBrainzRecordingId = musicBrainzRecordingId;
MusicBrainzTrackId = musicBrainzTrackId; MusicBrainzTrackId = musicBrainzTrackId;
MusicBrainzWorkId = musicBrainzWorkId;
UpdatedOnUtc = Optional<DateTime>.Some(DateTime.UtcNow); UpdatedOnUtc = Optional<DateTime>.Some(DateTime.UtcNow);
return Result.Updated; return Result.Updated;
} }
@@ -14,10 +14,18 @@ namespace Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLib
[DebuggerDisplay("{Title}")] [DebuggerDisplay("{Title}")]
public class AlbumMetadata : BaseMetadata public class AlbumMetadata : BaseMetadata
{ {
private readonly List<MusicReleaseType> _releaseTypes;
/// <summary> /// <summary>
/// Gets the type of the release, if applicable. /// Gets the title of the specific release (edition) the album files match, if different from the release group title.
/// </summary> /// </summary>
public Optional<MusicReleaseType> ReleaseType { get; } public Optional<string> ReleaseTitle { get; }
/// <summary>
/// Gets the set of types of the release, if applicable.
/// A MusicBrainz release group can carry more than one type at the same time, for example an album that is also a compilation.
/// </summary>
public IReadOnlyCollection<MusicReleaseType> ReleaseTypes => _releaseTypes.AsReadOnly();
/// <summary> /// <summary>
/// Gets the status of the release, if applicable. /// Gets the status of the release, if applicable.
@@ -39,32 +47,35 @@ public class AlbumMetadata : BaseMetadata
/// </summary> /// </summary>
/// <param name="title">The title of the album.</param> /// <param name="title">The title of the album.</param>
/// <param name="originalTitle">The optional original title of the album, if applicable.</param> /// <param name="originalTitle">The optional original title of the album, if applicable.</param>
/// <param name="releaseTitle">The optional title of the specific release (edition) of the album.</param>
/// <param name="description">The description of the album, if applicable.</param> /// <param name="description">The description of the album, if applicable.</param>
/// <param name="releaseInfo">The release information of the album.</param> /// <param name="releaseInfo">The release information of the album.</param>
/// <param name="genres">The genres of the album.</param> /// <param name="genres">The genres of the album.</param>
/// <param name="tags">The tags associated with the album.</param> /// <param name="tags">The tags associated with the album.</param>
/// <param name="language">The language of the album, if applicable.</param> /// <param name="language">The language of the album, if applicable.</param>
/// <param name="originalLanguage">The optional original language of the album, if applicable.</param> /// <param name="originalLanguage">The optional original language of the album, if applicable.</param>
/// <param name="releaseType">The optional type of the release.</param> /// <param name="releaseTypes">The set of types of the release, if applicable.</param>
/// <param name="releaseStatus">The optional status of the release.</param> /// <param name="releaseStatus">The optional status of the release.</param>
/// <param name="totalDiscs">The optional number of discs of the release.</param> /// <param name="totalDiscs">The optional number of discs of the release.</param>
/// <param name="totalTracks">The number of tracks of the release.</param> /// <param name="totalTracks">The number of tracks of the release.</param>
private AlbumMetadata( private AlbumMetadata(
string title, string title,
Optional<string> originalTitle, Optional<string> originalTitle,
Optional<string> releaseTitle,
Optional<string> description, Optional<string> description,
ReleaseInfo releaseInfo, ReleaseInfo releaseInfo,
List<Genre> genres, List<Genre> genres,
List<Tag> tags, List<Tag> tags,
Optional<LanguageInfo> language, Optional<LanguageInfo> language,
Optional<LanguageInfo> originalLanguage, Optional<LanguageInfo> originalLanguage,
Optional<MusicReleaseType> releaseType, List<MusicReleaseType> releaseTypes,
Optional<MusicReleaseStatus> releaseStatus, Optional<MusicReleaseStatus> releaseStatus,
Optional<int> totalDiscs, Optional<int> totalDiscs,
int totalTracks) int totalTracks)
: base(title, originalTitle, description, releaseInfo, genres, tags, language, originalLanguage) : base(title, originalTitle, description, releaseInfo, genres, tags, language, originalLanguage)
{ {
ReleaseType = releaseType; ReleaseTitle = releaseTitle;
_releaseTypes = releaseTypes;
ReleaseStatus = releaseStatus; ReleaseStatus = releaseStatus;
TotalDiscs = totalDiscs; TotalDiscs = totalDiscs;
TotalTracks = totalTracks; TotalTracks = totalTracks;
@@ -75,13 +86,14 @@ public class AlbumMetadata : BaseMetadata
/// </summary> /// </summary>
/// <param name="title">The title of the album.</param> /// <param name="title">The title of the album.</param>
/// <param name="originalTitle">The optional original title of the album, if applicable.</param> /// <param name="originalTitle">The optional original title of the album, if applicable.</param>
/// <param name="releaseTitle">The optional title of the specific release (edition) of the album.</param>
/// <param name="description">The description of the album, if applicable.</param> /// <param name="description">The description of the album, if applicable.</param>
/// <param name="releaseInfo">The release information of the album.</param> /// <param name="releaseInfo">The release information of the album.</param>
/// <param name="genres">The genres of the album.</param> /// <param name="genres">The genres of the album.</param>
/// <param name="tags">The tags associated with the album.</param> /// <param name="tags">The tags associated with the album.</param>
/// <param name="language">The language of the album, if applicable.</param> /// <param name="language">The language of the album, if applicable.</param>
/// <param name="originalLanguage">The optional original language of the album, if applicable.</param> /// <param name="originalLanguage">The optional original language of the album, if applicable.</param>
/// <param name="releaseType">The optional type of the release.</param> /// <param name="releaseTypes">The set of types of the release, if applicable.</param>
/// <param name="releaseStatus">The optional status of the release.</param> /// <param name="releaseStatus">The optional status of the release.</param>
/// <param name="totalDiscs">The optional number of discs of the release.</param> /// <param name="totalDiscs">The optional number of discs of the release.</param>
/// <param name="totalTracks">The number of tracks of the release.</param> /// <param name="totalTracks">The number of tracks of the release.</param>
@@ -91,13 +103,14 @@ public class AlbumMetadata : BaseMetadata
public static Result<AlbumMetadata> Create( public static Result<AlbumMetadata> Create(
string title, string title,
Optional<string> originalTitle, Optional<string> originalTitle,
Optional<string> releaseTitle,
Optional<string> description, Optional<string> description,
ReleaseInfo releaseInfo, ReleaseInfo releaseInfo,
List<Genre> genres, List<Genre> genres,
List<Tag> tags, List<Tag> tags,
Optional<LanguageInfo> language, Optional<LanguageInfo> language,
Optional<LanguageInfo> originalLanguage, Optional<LanguageInfo> originalLanguage,
Optional<MusicReleaseType> releaseType, List<MusicReleaseType> releaseTypes,
Optional<MusicReleaseStatus> releaseStatus, Optional<MusicReleaseStatus> releaseStatus,
Optional<int> totalDiscs, Optional<int> totalDiscs,
int totalTracks) int totalTracks)
@@ -105,13 +118,14 @@ public class AlbumMetadata : BaseMetadata
return new AlbumMetadata( return new AlbumMetadata(
title, title,
originalTitle, originalTitle,
releaseTitle,
description, description,
releaseInfo, releaseInfo,
genres, genres,
tags, tags,
language, language,
originalLanguage, originalLanguage,
releaseType, releaseTypes,
releaseStatus, releaseStatus,
totalDiscs, totalDiscs,
totalTracks); totalTracks);
@@ -125,7 +139,9 @@ public class AlbumMetadata : BaseMetadata
{ {
foreach (object component in base.GetEqualityComponents()) foreach (object component in base.GetEqualityComponents())
yield return component; yield return component;
yield return ReleaseType; yield return ReleaseTitle;
foreach (MusicReleaseType releaseType in _releaseTypes)
yield return releaseType;
yield return ReleaseStatus; yield return ReleaseStatus;
yield return TotalDiscs; yield return TotalDiscs;
yield return TotalTracks; yield return TotalTracks;
@@ -40,6 +40,11 @@ public class AudioMetadataFixture
/// <param name="bitDepth">Optional. The bit depth of the audio.</param> /// <param name="bitDepth">Optional. The bit depth of the audio.</param>
/// <param name="audioCodec">Optional. The audio codec used.</param> /// <param name="audioCodec">Optional. The audio codec used.</param>
/// <param name="bitrate">Optional. The bitrate of the audio, in kbps.</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> /// <returns>The created <see cref="AudioMetadata"/>.</returns>
public AudioMetadata Create( public AudioMetadata Create(
string? title = null, string? title = null,
@@ -55,7 +60,12 @@ public class AudioMetadataFixture
Optional<LanguageInfo>? originalLanguage = null, Optional<LanguageInfo>? originalLanguage = null,
Optional<int>? bitDepth = null, Optional<int>? bitDepth = null,
Optional<string>? audioCodec = 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( return AudioMetadata.Create(
title ?? _faker.Music.Genre(), title ?? _faker.Music.Genre(),
@@ -71,7 +81,12 @@ public class AudioMetadataFixture
originalLanguage ?? Optional<LanguageInfo>.None(), originalLanguage ?? Optional<LanguageInfo>.None(),
bitDepth ?? Optional<int>.Some(_faker.Random.Int(8, 32)), bitDepth ?? Optional<int>.Some(_faker.Random.Int(8, 32)),
audioCodec ?? Optional<string>.Some("PCM"), 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> /// <summary>
@@ -1,13 +1,18 @@
#region ========================================================================= USING ===================================================================================== #region ========================================================================= USING =====================================================================================
using Bogus; using Bogus;
using Lumina.Domain.Common.Primitives; 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.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate; using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities; using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects; 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.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities; using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects; using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
@@ -22,35 +27,96 @@ namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext
[ExcludeFromCodeCoverage] [ExcludeFromCodeCoverage]
public class ArtistFixture public class ArtistFixture
{ {
private const int MINIMUM_LIFESPAN_YEAR = 1900;
private const int MAXIMUM_LIFESPAN_YEAR = 2026;
private readonly Faker _faker = new(); private readonly Faker _faker = new();
private readonly LibraryIdFixture _libraryIdFixture = new(); private readonly LibraryIdFixture _libraryIdFixture = new();
private readonly AlbumFixture _albumFixture = new(); private readonly AlbumFixture _albumFixture = new();
private readonly MusicBrainzIdFixture _musicBrainzIdFixture = new(); private readonly MusicBrainzIdFixture _musicBrainzIdFixture = new();
private readonly MusicMediaContributorFixture _musicMediaContributorFixture = 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> /// <summary>
/// Creates a random valid <see cref="Artist"/> domain aggregate root. /// Creates a random valid <see cref="Artist"/> domain aggregate root.
/// </summary> /// </summary>
/// <param name="libraryId">Optional. The Id of the media library this artist belongs to.</param> /// <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="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="website">Optional. The website of the artist.</param>
/// <param name="musicBrainzArtistId">Optional. The MusicBrainz identifier 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="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> /// <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> /// <returns>The created <see cref="Artist"/> domain aggregate root.</returns>
public Artist Create( public Artist Create(
LibraryId? libraryId = null, LibraryId? libraryId = null,
string? name = 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<string>? website = null,
Optional<MusicBrainzId>? musicBrainzArtistId = 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<MusicMediaContributor>? contributors = null,
List<Album>? albums = 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( Result<Artist> artistResult = Artist.Create(
libraryId ?? _libraryIdFixture.Create(), libraryId ?? _libraryIdFixture.Create(),
name ?? _faker.Name.FullName(), 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()), website ?? Optional<string>.Some(_faker.Internet.Url()),
musicBrainzArtistId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()), 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())], contributors ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(_ => _musicMediaContributorFixture.Create())],
albums ?? [_albumFixture.Create()]); albums ?? [_albumFixture.Create()]);
@@ -32,9 +32,14 @@ public class AlbumFixture
/// Creates a random valid <see cref="Album"/> domain entity. /// Creates a random valid <see cref="Album"/> domain entity.
/// </summary> /// </summary>
/// <param name="metadata">Optional. The album metadata of the album.</param> /// <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="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="barcode">Optional. The barcode of the album.</param>
/// <param name="catalogNumber">Optional. The catalog number 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="musicBrainzReleaseId">Optional. The MusicBrainz identifier of the release.</param>
/// <param name="musicBrainzReleaseGroupId">Optional. The MusicBrainz identifier of the release group.</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="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> /// <returns>The created <see cref="Album"/> domain entity.</returns>
public Album Create( public Album Create(
AlbumMetadata? metadata = null, AlbumMetadata? metadata = null,
Optional<string>? disambiguation = null,
Optional<MusicMediaFormat>? mediaFormat = null, Optional<MusicMediaFormat>? mediaFormat = null,
Optional<MusicReleasePackaging>? packaging = null,
Optional<string>? script = null,
Optional<Barcode>? barcode = 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>? musicBrainzReleaseId = null,
Optional<MusicBrainzId>? musicBrainzReleaseGroupId = null, Optional<MusicBrainzId>? musicBrainzReleaseGroupId = null,
Optional<MusicBrainzId>? musicBrainzReleaseArtistId = null, Optional<MusicBrainzId>? musicBrainzReleaseArtistId = null,
@@ -56,9 +66,14 @@ public class AlbumFixture
{ {
Result<Album> albumResult = Album.Create( Result<Album> albumResult = Album.Create(
metadata ?? _albumMetadataFixture.Create(), metadata ?? _albumMetadataFixture.Create(),
disambiguation ?? Optional<string>.Some(_faker.Lorem.Sentence()),
mediaFormat ?? Optional<MusicMediaFormat>.Some(_faker.PickRandom<MusicMediaFormat>()), 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()), 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()), musicBrainzReleaseId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
musicBrainzReleaseGroupId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()), musicBrainzReleaseGroupId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
musicBrainzReleaseArtistId ?? 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 IsrcFixture _isrcFixture = new();
private readonly MusicMediaContributorFixture _musicMediaContributorFixture = new(); private readonly MusicMediaContributorFixture _musicMediaContributorFixture = new();
private readonly MusicBrainzIdFixture _musicBrainzIdFixture = new(); private readonly MusicBrainzIdFixture _musicBrainzIdFixture = new();
private readonly MusicWorkFixture _musicWorkFixture = new();
private readonly AudioRatingFixture _audioRatingFixture = new(); private readonly AudioRatingFixture _audioRatingFixture = new();
/// <summary> /// <summary>
@@ -36,51 +37,54 @@ public class TrackFixture
/// </summary> /// </summary>
/// <param name="path">Optional. The file system path of the track.</param> /// <param name="path">Optional. The file system path of the track.</param>
/// <param name="metadata">Optional. The audio metadata of the track.</param> /// <param name="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="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="discNumber">Optional. The number of the disc the track belongs to.</param>
/// <param name="moods">Optional. The moods of the track.</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="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="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="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="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="musicBrainzRecordingId">Optional. The MusicBrainz identifier of the recording.</param>
/// <param name="musicBrainzTrackId">Optional. The MusicBrainz identifier of the track.</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="contributors">Optional. The media contributors of the track.</param>
/// <param name="ratings">Optional. The ratings of the track.</param> /// <param name="ratings">Optional. The ratings of the track.</param>
/// <returns>The created <see cref="Track"/> domain entity.</returns> /// <returns>The created <see cref="Track"/> domain entity.</returns>
public Track Create( public Track Create(
string? path = null, string? path = null,
AudioMetadata? metadata = null, AudioMetadata? metadata = null,
Optional<string>? disambiguation = null,
int? trackNumber = null, int? trackNumber = null,
Optional<int>? discNumber = null, Optional<int>? discNumber = null,
List<Mood>? moods = null, List<Mood>? moods = null,
Optional<string>? script = null, Optional<string>? script = null,
Optional<MusicKey>? key = null, Optional<MusicKey>? key = null,
Optional<int>? bpm = null, Optional<int>? bpm = null,
bool? isVideo = null,
List<Isrc>? isrcs = null, List<Isrc>? isrcs = null,
Optional<string>? work = null, Optional<MusicWork>? work = null,
Optional<MusicBrainzId>? musicBrainzRecordingId = null, Optional<MusicBrainzId>? musicBrainzRecordingId = null,
Optional<MusicBrainzId>? musicBrainzTrackId = null, Optional<MusicBrainzId>? musicBrainzTrackId = null,
Optional<MusicBrainzId>? musicBrainzWorkId = null,
List<MusicMediaContributor>? contributors = null, List<MusicMediaContributor>? contributors = null,
List<AudioRating>? ratings = null) List<AudioRating>? ratings = null)
{ {
Result<Track> trackResult = Track.Create( Result<Track> trackResult = Track.Create(
path ?? _faker.System.FilePath(), path ?? _faker.System.FilePath(),
metadata ?? _audioMetadataFixture.Create(), metadata ?? _audioMetadataFixture.Create(),
disambiguation ?? Optional<string>.None(),
trackNumber ?? _faker.Random.Int(1, 30), trackNumber ?? _faker.Random.Int(1, 30),
discNumber ?? Optional<int>.Some(_faker.Random.Int(1, 2)), discNumber ?? Optional<int>.Some(_faker.Random.Int(1, 2)),
moods ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(_ => _moodFixture.Create())], moods ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(_ => _moodFixture.Create())],
script ?? Optional<string>.Some(_faker.Lorem.Word()), script ?? Optional<string>.Some(_faker.Lorem.Word()),
key ?? Optional<MusicKey>.Some(_faker.PickRandom<MusicKey>()), key ?? Optional<MusicKey>.Some(_faker.PickRandom<MusicKey>()),
bpm ?? Optional<int>.Some(_faker.Random.Int(60, 220)), 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())], 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()), musicBrainzRecordingId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
musicBrainzTrackId ?? 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())], contributors ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(_ => _musicMediaContributorFixture.Create())],
ratings ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _audioRatingFixture.Create())]); ratings ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _audioRatingFixture.Create())]);
@@ -30,13 +30,14 @@ public class AlbumMetadataFixture
/// </summary> /// </summary>
/// <param name="title">Optional. The title of the album.</param> /// <param name="title">Optional. The title of the album.</param>
/// <param name="originalTitle">Optional. The original 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="description">Optional. The description of the album.</param>
/// <param name="releaseInfo">Optional. The release information 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="genres">Optional. The genres of the album.</param>
/// <param name="tags">Optional. The tags associated with 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="language">Optional. The language of the album.</param>
/// <param name="originalLanguage">Optional. The original 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="releaseStatus">Optional. The status of the release.</param>
/// <param name="totalDiscs">Optional. The number of discs 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="totalTracks">Optional. The number of tracks of the release.</param>
@@ -44,13 +45,14 @@ public class AlbumMetadataFixture
public AlbumMetadata Create( public AlbumMetadata Create(
string? title = null, string? title = null,
Optional<string>? originalTitle = null, Optional<string>? originalTitle = null,
Optional<string>? releaseTitle = null,
Optional<string>? description = null, Optional<string>? description = null,
ReleaseInfo? releaseInfo = null, ReleaseInfo? releaseInfo = null,
List<Genre>? genres = null, List<Genre>? genres = null,
List<Tag>? tags = null, List<Tag>? tags = null,
Optional<LanguageInfo>? language = null, Optional<LanguageInfo>? language = null,
Optional<LanguageInfo>? originalLanguage = null, Optional<LanguageInfo>? originalLanguage = null,
Optional<MusicReleaseType>? releaseType = null, List<MusicReleaseType>? releaseTypes = null,
Optional<MusicReleaseStatus>? releaseStatus = null, Optional<MusicReleaseStatus>? releaseStatus = null,
Optional<int>? totalDiscs = null, Optional<int>? totalDiscs = null,
int? totalTracks = null) int? totalTracks = null)
@@ -58,13 +60,14 @@ public class AlbumMetadataFixture
Result<AlbumMetadata> metadataResult = AlbumMetadata.Create( Result<AlbumMetadata> metadataResult = AlbumMetadata.Create(
title ?? _faker.Commerce.ProductName(), title ?? _faker.Commerce.ProductName(),
originalTitle ?? Optional<string>.None(), originalTitle ?? Optional<string>.None(),
releaseTitle ?? Optional<string>.Some(_faker.Commerce.ProductName()),
description ?? Optional<string>.Some(_faker.Lorem.Sentence()), description ?? Optional<string>.Some(_faker.Lorem.Sentence()),
releaseInfo ?? _releaseInfoFixture.Create(), releaseInfo ?? _releaseInfoFixture.Create(),
genres ?? [_genreFixture.Create(), _genreFixture.Create()], genres ?? [_genreFixture.Create(), _genreFixture.Create()],
tags ?? [_tagFixture.Create(), _tagFixture.Create()], tags ?? [_tagFixture.Create(), _tagFixture.Create()],
language ?? Optional<LanguageInfo>.Some(_languageInfoFixture.Create()), language ?? Optional<LanguageInfo>.Some(_languageInfoFixture.Create()),
originalLanguage ?? Optional<LanguageInfo>.None(), originalLanguage ?? Optional<LanguageInfo>.None(),
releaseType ?? Optional<MusicReleaseType>.Some(_faker.PickRandom<MusicReleaseType>()), releaseTypes ?? [_faker.PickRandom<MusicReleaseType>()],
releaseStatus ?? Optional<MusicReleaseStatus>.Some(_faker.PickRandom<MusicReleaseStatus>()), releaseStatus ?? Optional<MusicReleaseStatus>.Some(_faker.PickRandom<MusicReleaseStatus>()),
totalDiscs ?? Optional<int>.Some(_faker.Random.Int(1, 4)), totalDiscs ?? Optional<int>.Some(_faker.Random.Int(1, 4)),
totalTracks ?? _faker.Random.Int(1, 50)); totalTracks ?? _faker.Random.Int(1, 50));
@@ -41,7 +41,12 @@ public class AudioMetadataTests
Optional<LanguageInfo>.None(), Optional<LanguageInfo>.None(),
Optional<int>.Some(16), Optional<int>.Some(16),
Optional<string>.Some("PCM"), Optional<string>.Some("PCM"),
Optional<int>.Some(1411)); Optional<int>.Some(1411),
Optional<string>.Some("f0e9c1a2-0000-0000-0000-000000000000"),
Optional<decimal>.Some(-6.53m),
Optional<decimal>.Some(0.988m),
Optional<decimal>.Some(-7.01m),
Optional<decimal>.Some(1.001m));
// Assert // Assert
Assert.False(result.IsFailure); Assert.False(result.IsFailure);
@@ -75,7 +80,12 @@ public class AudioMetadataTests
Optional<LanguageInfo>.None(), Optional<LanguageInfo>.None(),
Optional<int>.None(), Optional<int>.None(),
Optional<string>.None(), Optional<string>.None(),
Optional<int>.None()); Optional<int>.None(),
Optional<string>.None(),
Optional<decimal>.None(),
Optional<decimal>.None(),
Optional<decimal>.None(),
Optional<decimal>.None());
// Assert // Assert
Assert.False(result.IsFailure); Assert.False(result.IsFailure);
@@ -190,7 +200,12 @@ public class AudioMetadataTests
Optional<LanguageInfo>.Some(originalLanguage), Optional<LanguageInfo>.Some(originalLanguage),
Optional<int>.Some(16), Optional<int>.Some(16),
Optional<string>.Some("PCM"), Optional<string>.Some("PCM"),
Optional<int>.Some(1411)); Optional<int>.Some(1411),
Optional<string>.Some("f0e9c1a2-0000-0000-0000-000000000000"),
Optional<decimal>.Some(-6.53m),
Optional<decimal>.Some(0.988m),
Optional<decimal>.Some(-7.01m),
Optional<decimal>.Some(1.001m));
// Assert // Assert
Assert.False(result.IsFailure); Assert.False(result.IsFailure);
@@ -222,7 +237,12 @@ public class AudioMetadataTests
Optional<LanguageInfo>.None(), Optional<LanguageInfo>.None(),
Optional<int>.None(), Optional<int>.None(),
Optional<string>.None(), Optional<string>.None(),
Optional<int>.None()); Optional<int>.None(),
Optional<string>.None(),
Optional<decimal>.None(),
Optional<decimal>.None(),
Optional<decimal>.None(),
Optional<decimal>.None());
// Assert // Assert
Assert.False(result.IsFailure); Assert.False(result.IsFailure);
@@ -41,6 +41,7 @@ public class ArtistTests
private readonly AudioMetadataFixture _audioMetadataFixture = new(); private readonly AudioMetadataFixture _audioMetadataFixture = new();
private readonly MoodFixture _moodFixture = new(); private readonly MoodFixture _moodFixture = new();
private readonly IsrcFixture _isrcFixture = new(); private readonly IsrcFixture _isrcFixture = new();
private readonly MusicWorkFixture _musicWorkFixture = new();
[Fact] [Fact]
public void AddTrackToAlbum_WhenAlbumIsOwnedByTheArtist_ShouldAddTheTrackAndReturnSuccess() public void AddTrackToAlbum_WhenAlbumIsOwnedByTheArtist_ShouldAddTheTrackAndReturnSuccess()
@@ -109,8 +110,25 @@ public class ArtistTests
Result<Artist> result = Artist.Create( Result<Artist> result = Artist.Create(
libraryId, libraryId,
"Queen", "Queen",
Optional<string>.None(),
Optional<string>.None(),
Optional<MusicArtistType>.None(),
Optional<MusicArtistGender>.None(),
Optional<string>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<DateOnly>.None(),
Optional<DateOnly>.None(),
false,
Optional<string>.Some("https://www.queenonline.com"), Optional<string>.Some("https://www.queenonline.com"),
Optional<MusicBrainzId>.Some(musicBrainzArtistId), Optional<MusicBrainzId>.Some(musicBrainzArtistId),
[],
[],
[],
[],
[],
[],
contributors, contributors,
[album]); [album]);
@@ -141,8 +159,25 @@ public class ArtistTests
libraryId, libraryId,
"Queen", "Queen",
Optional<string>.None(), Optional<string>.None(),
Optional<string>.None(),
Optional<MusicArtistType>.None(),
Optional<MusicArtistGender>.None(),
Optional<string>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<DateOnly>.None(),
Optional<DateOnly>.None(),
false,
Optional<string>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
[], [],
[],
[],
[],
[],
[],
[],
[album]); [album]);
// Assert // Assert
@@ -165,8 +200,25 @@ public class ArtistTests
_libraryIdFixture.Create(), _libraryIdFixture.Create(),
name!, name!,
Optional<string>.None(), Optional<string>.None(),
Optional<string>.None(),
Optional<MusicArtistType>.None(),
Optional<MusicArtistGender>.None(),
Optional<string>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<DateOnly>.None(),
Optional<DateOnly>.None(),
false,
Optional<string>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
[], [],
[],
[],
[],
[],
[],
[],
[_albumFixture.Create()]); [_albumFixture.Create()]);
// Assert // Assert
@@ -182,8 +234,25 @@ public class ArtistTests
_libraryIdFixture.Create(), _libraryIdFixture.Create(),
"Queen", "Queen",
Optional<string>.None(), Optional<string>.None(),
Optional<string>.None(),
Optional<MusicArtistType>.None(),
Optional<MusicArtistGender>.None(),
Optional<string>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<DateOnly>.None(),
Optional<DateOnly>.None(),
false,
Optional<string>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
[], [],
[],
[],
[],
[],
[],
[],
[]); []);
// Assert // Assert
@@ -206,9 +275,26 @@ public class ArtistTests
artistId, artistId,
libraryId, libraryId,
"Queen", "Queen",
Optional<string>.None(),
Optional<string>.None(),
Optional<MusicArtistType>.None(),
Optional<MusicArtistGender>.None(),
Optional<string>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<DateOnly>.None(),
Optional<DateOnly>.None(),
false,
Optional<string>.Some("https://www.queenonline.com"), Optional<string>.Some("https://www.queenonline.com"),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
[], [],
[],
[],
[],
[],
[],
[],
[album], [album],
createdOnUtc, createdOnUtc,
Optional<DateTime>.Some(updatedOnUtc)); Optional<DateTime>.Some(updatedOnUtc));
@@ -236,8 +322,25 @@ public class ArtistTests
_libraryIdFixture.Create(), _libraryIdFixture.Create(),
name!, name!,
Optional<string>.None(), Optional<string>.None(),
Optional<string>.None(),
Optional<MusicArtistType>.None(),
Optional<MusicArtistGender>.None(),
Optional<string>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<DateOnly>.None(),
Optional<DateOnly>.None(),
false,
Optional<string>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
[], [],
[],
[],
[],
[],
[],
[],
[_albumFixture.Create()], [_albumFixture.Create()],
DateTime.UtcNow, DateTime.UtcNow,
Optional<DateTime>.None()); Optional<DateTime>.None());
@@ -256,9 +359,26 @@ public class ArtistTests
_libraryIdFixture.Create(), _libraryIdFixture.Create(),
"Queen", "Queen",
Optional<string>.None(), Optional<string>.None(),
Optional<string>.None(),
Optional<MusicArtistType>.None(),
Optional<MusicArtistGender>.None(),
Optional<string>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<DateOnly>.None(),
Optional<DateOnly>.None(),
false,
Optional<string>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
[], [],
[], [],
[],
[],
[],
[],
[],
[],
DateTime.UtcNow, DateTime.UtcNow,
Optional<DateTime>.None()); Optional<DateTime>.None());
@@ -394,6 +514,17 @@ public class ArtistTests
// Act // Act
Result<Updated> result = artist.UpdateDetails( Result<Updated> result = artist.UpdateDetails(
"Queen", "Queen",
Optional<string>.None(),
Optional<string>.None(),
Optional<MusicArtistType>.None(),
Optional<MusicArtistGender>.None(),
Optional<string>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<DateOnly>.None(),
Optional<DateOnly>.None(),
false,
Optional<string>.Some("https://www.queenonline.com"), Optional<string>.Some("https://www.queenonline.com"),
Optional<MusicBrainzId>.Some(musicBrainzArtistId)); Optional<MusicBrainzId>.Some(musicBrainzArtistId));
@@ -415,7 +546,21 @@ public class ArtistTests
Optional<DateTime> originalUpdatedOnUtc = artist.UpdatedOnUtc; Optional<DateTime> originalUpdatedOnUtc = artist.UpdatedOnUtc;
// Act // Act
Result<Updated> result = artist.UpdateDetails(" ", Optional<string>.None(), Optional<MusicBrainzId>.None()); Result<Updated> result = artist.UpdateDetails(
" ",
Optional<string>.None(),
Optional<string>.None(),
Optional<MusicArtistType>.None(),
Optional<MusicArtistGender>.None(),
Optional<string>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<MusicArea>.None(),
Optional<DateOnly>.None(),
Optional<DateOnly>.None(),
false,
Optional<string>.None(),
Optional<MusicBrainzId>.None());
// Assert // Assert
Assert.True(result.IsFailure); Assert.True(result.IsFailure);
@@ -433,7 +578,7 @@ public class ArtistTests
AlbumMetadata metadata = _albumMetadataFixture.Create(title: "A Night at the Opera"); AlbumMetadata metadata = _albumMetadataFixture.Create(title: "A Night at the Opera");
Optional<MusicMediaFormat> mediaFormat = Optional<MusicMediaFormat>.Some(MusicMediaFormat.CD); Optional<MusicMediaFormat> mediaFormat = Optional<MusicMediaFormat>.Some(MusicMediaFormat.CD);
Optional<Barcode> barcode = Optional<Barcode>.Some(_barcodeFixture.Create()); Optional<Barcode> barcode = Optional<Barcode>.Some(_barcodeFixture.Create());
Optional<string> catalogNumber = Optional<string>.Some("CAT-123456"); List<string> catalogNumbers = ["CAT-123456"];
Optional<MusicBrainzId> releaseId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()); Optional<MusicBrainzId> releaseId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create());
Optional<MusicBrainzId> releaseGroupId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()); Optional<MusicBrainzId> releaseGroupId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create());
Optional<MusicBrainzId> releaseArtistId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()); Optional<MusicBrainzId> releaseArtistId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create());
@@ -445,9 +590,14 @@ public class ArtistTests
Result<Updated> result = artist.UpdateAlbum( Result<Updated> result = artist.UpdateAlbum(
album, album,
metadata, metadata,
Optional<string>.None(),
mediaFormat, mediaFormat,
Optional<MusicReleasePackaging>.None(),
Optional<string>.None(),
barcode, barcode,
catalogNumber, catalogNumbers,
Optional<string>.None(),
Optional<string>.None(),
releaseId, releaseId,
releaseGroupId, releaseGroupId,
releaseArtistId, releaseArtistId,
@@ -459,7 +609,7 @@ public class ArtistTests
Assert.Equal(metadata, album.Metadata); Assert.Equal(metadata, album.Metadata);
Assert.Equal(mediaFormat, album.MediaFormat); Assert.Equal(mediaFormat, album.MediaFormat);
Assert.Equal(barcode, album.Barcode); Assert.Equal(barcode, album.Barcode);
Assert.Equal(catalogNumber, album.CatalogNumber); Assert.Equal(catalogNumbers, album.CatalogNumbers);
Assert.Equal(releaseId, album.MusicBrainzReleaseId); Assert.Equal(releaseId, album.MusicBrainzReleaseId);
Assert.Equal(releaseGroupId, album.MusicBrainzReleaseGroupId); Assert.Equal(releaseGroupId, album.MusicBrainzReleaseGroupId);
Assert.Equal(releaseArtistId, album.MusicBrainzReleaseArtistId); Assert.Equal(releaseArtistId, album.MusicBrainzReleaseArtistId);
@@ -483,8 +633,13 @@ public class ArtistTests
Result<Updated> result = artist.UpdateAlbum( Result<Updated> result = artist.UpdateAlbum(
foreignAlbum, foreignAlbum,
_albumMetadataFixture.Create(), _albumMetadataFixture.Create(),
Optional<string>.None(),
Optional<MusicMediaFormat>.None(), Optional<MusicMediaFormat>.None(),
Optional<MusicReleasePackaging>.None(),
Optional<string>.None(),
Optional<Barcode>.None(), Optional<Barcode>.None(),
[],
Optional<string>.None(),
Optional<string>.None(), Optional<string>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
@@ -512,10 +667,9 @@ public class ArtistTests
Optional<string> script = Optional<string>.Some("Latin"); Optional<string> script = Optional<string>.Some("Latin");
Optional<MusicKey> key = Optional<MusicKey>.Some(MusicKey.BMajor); Optional<MusicKey> key = Optional<MusicKey>.Some(MusicKey.BMajor);
Optional<int> bpm = Optional<int>.Some(72); Optional<int> bpm = Optional<int>.Some(72);
Optional<string> work = Optional<string>.Some("Bohemian Rhapsody"); Optional<MusicWork> work = Optional<MusicWork>.Some(_musicWorkFixture.Create(title: "Bohemian Rhapsody"));
Optional<MusicBrainzId> recordingId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()); Optional<MusicBrainzId> recordingId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create());
Optional<MusicBrainzId> musicBrainzTrackId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()); Optional<MusicBrainzId> musicBrainzTrackId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create());
Optional<MusicBrainzId> workId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create());
List<Mood> moods = [_moodFixture.Create(name: "epic")]; List<Mood> moods = [_moodFixture.Create(name: "epic")];
List<Isrc> isrcs = [_isrcFixture.Create(value: "GBUM71029604")]; List<Isrc> isrcs = [_isrcFixture.Create(value: "GBUM71029604")];
List<MusicMediaContributor> contributors = [_musicMediaContributorFixture.Create()]; List<MusicMediaContributor> contributors = [_musicMediaContributorFixture.Create()];
@@ -533,10 +687,10 @@ public class ArtistTests
script, script,
key, key,
bpm, bpm,
true,
work, work,
recordingId, recordingId,
musicBrainzTrackId, musicBrainzTrackId,
workId,
moods, moods,
isrcs, isrcs,
contributors, contributors,
@@ -551,10 +705,10 @@ public class ArtistTests
Assert.Equal(script, track.Script); Assert.Equal(script, track.Script);
Assert.Equal(key, track.Key); Assert.Equal(key, track.Key);
Assert.Equal(bpm, track.Bpm); Assert.Equal(bpm, track.Bpm);
Assert.True(track.IsVideo);
Assert.Equal(work, track.Work); Assert.Equal(work, track.Work);
Assert.Equal(recordingId, track.MusicBrainzRecordingId); Assert.Equal(recordingId, track.MusicBrainzRecordingId);
Assert.Equal(musicBrainzTrackId, track.MusicBrainzTrackId); Assert.Equal(musicBrainzTrackId, track.MusicBrainzTrackId);
Assert.Equal(workId, track.MusicBrainzWorkId);
Assert.Equal(moods, track.Moods); Assert.Equal(moods, track.Moods);
Assert.Equal(isrcs, track.Isrcs); Assert.Equal(isrcs, track.Isrcs);
Assert.Equal(contributors, track.Contributors); Assert.Equal(contributors, track.Contributors);
@@ -585,8 +739,8 @@ public class ArtistTests
Optional<string>.None(), Optional<string>.None(),
Optional<MusicKey>.None(), Optional<MusicKey>.None(),
Optional<int>.None(), Optional<int>.None(),
Optional<string>.None(), false,
Optional<MusicBrainzId>.None(), Optional<MusicWork>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
[], [],
@@ -622,8 +776,8 @@ public class ArtistTests
Optional<string>.None(), Optional<string>.None(),
Optional<MusicKey>.None(), Optional<MusicKey>.None(),
Optional<int>.None(), Optional<int>.None(),
Optional<string>.None(), false,
Optional<MusicBrainzId>.None(), Optional<MusicWork>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
[], [],
@@ -71,7 +71,7 @@ public class AlbumTests
AlbumMetadata metadata = _albumMetadataFixture.Create(title: "A Night at the Opera"); AlbumMetadata metadata = _albumMetadataFixture.Create(title: "A Night at the Opera");
Optional<MusicMediaFormat> mediaFormat = Optional<MusicMediaFormat>.Some(MusicMediaFormat.Vinyl); Optional<MusicMediaFormat> mediaFormat = Optional<MusicMediaFormat>.Some(MusicMediaFormat.Vinyl);
Optional<Barcode> barcode = Optional<Barcode>.Some(_barcodeFixture.Create()); Optional<Barcode> barcode = Optional<Barcode>.Some(_barcodeFixture.Create());
Optional<string> catalogNumber = Optional<string>.Some("CAT-001"); List<string> catalogNumbers = ["CAT-001"];
Optional<MusicBrainzId> releaseId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()); Optional<MusicBrainzId> releaseId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create());
Optional<MusicBrainzId> releaseGroupId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()); Optional<MusicBrainzId> releaseGroupId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create());
Optional<MusicBrainzId> releaseArtistId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()); Optional<MusicBrainzId> releaseArtistId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create());
@@ -83,9 +83,14 @@ public class AlbumTests
// Act // Act
Result<Album> result = Album.Create( Result<Album> result = Album.Create(
metadata, metadata,
Optional<string>.None(),
mediaFormat, mediaFormat,
Optional<MusicReleasePackaging>.Some(MusicReleasePackaging.Digipak),
Optional<string>.None(),
barcode, barcode,
catalogNumber, catalogNumbers,
Optional<string>.Some("Label"),
Optional<string>.Some("ASIN"),
releaseId, releaseId,
releaseGroupId, releaseGroupId,
releaseArtistId, releaseArtistId,
@@ -100,7 +105,7 @@ public class AlbumTests
Assert.Equal(metadata, album.Metadata); Assert.Equal(metadata, album.Metadata);
Assert.Equal(mediaFormat, album.MediaFormat); Assert.Equal(mediaFormat, album.MediaFormat);
Assert.Equal(barcode, album.Barcode); Assert.Equal(barcode, album.Barcode);
Assert.Equal(catalogNumber, album.CatalogNumber); Assert.Equal(catalogNumbers, album.CatalogNumbers);
Assert.Equal(releaseId, album.MusicBrainzReleaseId); Assert.Equal(releaseId, album.MusicBrainzReleaseId);
Assert.Equal(releaseGroupId, album.MusicBrainzReleaseGroupId); Assert.Equal(releaseGroupId, album.MusicBrainzReleaseGroupId);
Assert.Equal(releaseArtistId, album.MusicBrainzReleaseArtistId); Assert.Equal(releaseArtistId, album.MusicBrainzReleaseArtistId);
@@ -117,8 +122,13 @@ public class AlbumTests
// Act // Act
Result<Album> result = Album.Create( Result<Album> result = Album.Create(
_albumMetadataFixture.Create(), _albumMetadataFixture.Create(),
Optional<string>.None(),
Optional<MusicMediaFormat>.None(), Optional<MusicMediaFormat>.None(),
Optional<MusicReleasePackaging>.None(),
Optional<string>.None(),
Optional<Barcode>.None(), Optional<Barcode>.None(),
[],
Optional<string>.None(),
Optional<string>.None(), Optional<string>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
@@ -132,7 +142,7 @@ public class AlbumTests
Album album = result.Value; Album album = result.Value;
Assert.False(album.MediaFormat.HasValue); Assert.False(album.MediaFormat.HasValue);
Assert.False(album.Barcode.HasValue); Assert.False(album.Barcode.HasValue);
Assert.False(album.CatalogNumber.HasValue); Assert.Empty(album.CatalogNumbers);
Assert.False(album.MusicBrainzReleaseId.HasValue); Assert.False(album.MusicBrainzReleaseId.HasValue);
Assert.False(album.MusicBrainzReleaseGroupId.HasValue); Assert.False(album.MusicBrainzReleaseGroupId.HasValue);
Assert.False(album.MusicBrainzReleaseArtistId.HasValue); Assert.False(album.MusicBrainzReleaseArtistId.HasValue);
@@ -144,8 +154,13 @@ public class AlbumTests
// Act // Act
Result<Album> result = Album.Create( Result<Album> result = Album.Create(
_albumMetadataFixture.Create(), _albumMetadataFixture.Create(),
Optional<string>.None(),
Optional<MusicMediaFormat>.None(), Optional<MusicMediaFormat>.None(),
Optional<MusicReleasePackaging>.None(),
Optional<string>.None(),
Optional<Barcode>.None(), Optional<Barcode>.None(),
[],
Optional<string>.None(),
Optional<string>.None(), Optional<string>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
@@ -174,9 +189,14 @@ public class AlbumTests
Result<Album> result = Album.Create( Result<Album> result = Album.Create(
albumId, albumId,
metadata, metadata,
Optional<string>.None(),
Optional<MusicMediaFormat>.Some(MusicMediaFormat.CD), Optional<MusicMediaFormat>.Some(MusicMediaFormat.CD),
Optional<MusicReleasePackaging>.None(),
Optional<string>.None(),
Optional<Barcode>.Some(_barcodeFixture.Create()), Optional<Barcode>.Some(_barcodeFixture.Create()),
Optional<string>.Some("CAT-002"), ["CAT-002"],
Optional<string>.None(),
Optional<string>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
@@ -299,7 +319,7 @@ public class AlbumTests
AlbumMetadata metadata = _albumMetadataFixture.Create(title: "A Day at the Races"); AlbumMetadata metadata = _albumMetadataFixture.Create(title: "A Day at the Races");
Optional<MusicMediaFormat> mediaFormat = Optional<MusicMediaFormat>.Some(MusicMediaFormat.Cassette); Optional<MusicMediaFormat> mediaFormat = Optional<MusicMediaFormat>.Some(MusicMediaFormat.Cassette);
Optional<Barcode> barcode = Optional<Barcode>.Some(_barcodeFixture.Create()); Optional<Barcode> barcode = Optional<Barcode>.Some(_barcodeFixture.Create());
Optional<string> catalogNumber = Optional<string>.Some("CAT-003"); List<string> catalogNumbers = ["CAT-003"];
Optional<MusicBrainzId> releaseId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()); Optional<MusicBrainzId> releaseId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create());
Optional<MusicBrainzId> releaseGroupId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()); Optional<MusicBrainzId> releaseGroupId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create());
Optional<MusicBrainzId> releaseArtistId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()); Optional<MusicBrainzId> releaseArtistId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create());
@@ -308,9 +328,14 @@ public class AlbumTests
// Act // Act
Result<Updated> result = album.UpdateDetails( Result<Updated> result = album.UpdateDetails(
metadata, metadata,
Optional<string>.None(),
mediaFormat, mediaFormat,
Optional<MusicReleasePackaging>.None(),
Optional<string>.None(),
barcode, barcode,
catalogNumber, catalogNumbers,
Optional<string>.None(),
Optional<string>.None(),
releaseId, releaseId,
releaseGroupId, releaseGroupId,
releaseArtistId); releaseArtistId);
@@ -320,7 +345,7 @@ public class AlbumTests
Assert.Equal(metadata, album.Metadata); Assert.Equal(metadata, album.Metadata);
Assert.Equal(mediaFormat, album.MediaFormat); Assert.Equal(mediaFormat, album.MediaFormat);
Assert.Equal(barcode, album.Barcode); Assert.Equal(barcode, album.Barcode);
Assert.Equal(catalogNumber, album.CatalogNumber); Assert.Equal(catalogNumbers, album.CatalogNumbers);
Assert.Equal(releaseId, album.MusicBrainzReleaseId); Assert.Equal(releaseId, album.MusicBrainzReleaseId);
Assert.Equal(releaseGroupId, album.MusicBrainzReleaseGroupId); Assert.Equal(releaseGroupId, album.MusicBrainzReleaseGroupId);
Assert.Equal(releaseArtistId, album.MusicBrainzReleaseArtistId); Assert.Equal(releaseArtistId, album.MusicBrainzReleaseArtistId);
@@ -339,8 +364,13 @@ public class AlbumTests
// Act // Act
Result<Updated> result = album.UpdateDetails( Result<Updated> result = album.UpdateDetails(
_albumMetadataFixture.Create(), _albumMetadataFixture.Create(),
Optional<string>.None(),
Optional<MusicMediaFormat>.None(), Optional<MusicMediaFormat>.None(),
Optional<MusicReleasePackaging>.None(),
Optional<string>.None(),
Optional<Barcode>.None(), Optional<Barcode>.None(),
[],
Optional<string>.None(),
Optional<string>.None(), Optional<string>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
@@ -350,7 +380,7 @@ public class AlbumTests
Assert.False(result.IsFailure); Assert.False(result.IsFailure);
Assert.False(album.MediaFormat.HasValue); Assert.False(album.MediaFormat.HasValue);
Assert.False(album.Barcode.HasValue); Assert.False(album.Barcode.HasValue);
Assert.False(album.CatalogNumber.HasValue); Assert.Empty(album.CatalogNumbers);
Assert.False(album.MusicBrainzReleaseId.HasValue); Assert.False(album.MusicBrainzReleaseId.HasValue);
Assert.False(album.MusicBrainzReleaseGroupId.HasValue); Assert.False(album.MusicBrainzReleaseGroupId.HasValue);
Assert.False(album.MusicBrainzReleaseArtistId.HasValue); Assert.False(album.MusicBrainzReleaseArtistId.HasValue);
@@ -30,6 +30,7 @@ public class TrackTests
private readonly AudioRatingFixture _audioRatingFixture = new(); private readonly AudioRatingFixture _audioRatingFixture = new();
private readonly AudioMetadataFixture _audioMetadataFixture = new(); private readonly AudioMetadataFixture _audioMetadataFixture = new();
private readonly MusicBrainzIdFixture _musicBrainzIdFixture = new(); private readonly MusicBrainzIdFixture _musicBrainzIdFixture = new();
private readonly MusicWorkFixture _musicWorkFixture = new();
[Fact] [Fact]
public void Create_WhenCalledWithValidData_ShouldCreateTrackWithAllPropertiesPopulated() public void Create_WhenCalledWithValidData_ShouldCreateTrackWithAllPropertiesPopulated()
@@ -54,9 +55,9 @@ public class TrackTests
Assert.True(track.Bpm.HasValue); Assert.True(track.Bpm.HasValue);
Assert.NotEmpty(track.Isrcs); Assert.NotEmpty(track.Isrcs);
Assert.True(track.Work.HasValue); Assert.True(track.Work.HasValue);
Assert.NotEqual(Guid.Empty, track.Work.Value.MusicBrainzWorkId.Value);
Assert.True(track.MusicBrainzRecordingId.HasValue); Assert.True(track.MusicBrainzRecordingId.HasValue);
Assert.True(track.MusicBrainzTrackId.HasValue); Assert.True(track.MusicBrainzTrackId.HasValue);
Assert.True(track.MusicBrainzWorkId.HasValue);
Assert.NotEmpty(track.Contributors); Assert.NotEmpty(track.Contributors);
Assert.NotEmpty(track.Ratings); Assert.NotEmpty(track.Ratings);
Assert.InRange(track.CreatedOnUtc, beforeCreate, DateTime.UtcNow); Assert.InRange(track.CreatedOnUtc, beforeCreate, DateTime.UtcNow);
@@ -76,17 +77,18 @@ public class TrackTests
sourceTrack.Id, sourceTrack.Id,
sourceTrack.Path, sourceTrack.Path,
sourceTrack.Metadata, sourceTrack.Metadata,
sourceTrack.Disambiguation,
sourceTrack.TrackNumber, sourceTrack.TrackNumber,
sourceTrack.DiscNumber, sourceTrack.DiscNumber,
[.. sourceTrack.Moods], [.. sourceTrack.Moods],
sourceTrack.Script, sourceTrack.Script,
sourceTrack.Key, sourceTrack.Key,
sourceTrack.Bpm, sourceTrack.Bpm,
sourceTrack.IsVideo,
[.. sourceTrack.Isrcs], [.. sourceTrack.Isrcs],
sourceTrack.Work, sourceTrack.Work,
sourceTrack.MusicBrainzRecordingId, sourceTrack.MusicBrainzRecordingId,
sourceTrack.MusicBrainzTrackId, sourceTrack.MusicBrainzTrackId,
sourceTrack.MusicBrainzWorkId,
[.. sourceTrack.Contributors], [.. sourceTrack.Contributors],
[.. sourceTrack.Ratings], [.. sourceTrack.Ratings],
createdOnUtc, createdOnUtc,
@@ -195,10 +197,10 @@ public class TrackTests
Optional<string> script = Optional<string>.Some("Latin"); Optional<string> script = Optional<string>.Some("Latin");
Optional<MusicKey> key = Optional<MusicKey>.Some(MusicKey.DMajor); Optional<MusicKey> key = Optional<MusicKey>.Some(MusicKey.DMajor);
Optional<int> bpm = Optional<int>.Some(128); Optional<int> bpm = Optional<int>.Some(128);
Optional<string> work = Optional<string>.Some("Symphony No. 5"); bool isVideo = true;
Optional<MusicWork> work = Optional<MusicWork>.Some(_musicWorkFixture.Create(title: "Symphony No. 5"));
Optional<MusicBrainzId> recordingId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()); Optional<MusicBrainzId> recordingId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create());
Optional<MusicBrainzId> trackId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()); Optional<MusicBrainzId> trackId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create());
Optional<MusicBrainzId> workId = Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create());
DateTime beforeUpdate = DateTime.UtcNow; DateTime beforeUpdate = DateTime.UtcNow;
// Act // Act
@@ -210,10 +212,10 @@ public class TrackTests
script, script,
key, key,
bpm, bpm,
isVideo,
work, work,
recordingId, recordingId,
trackId, trackId);
workId);
// Assert // Assert
Assert.False(result.IsFailure); Assert.False(result.IsFailure);
@@ -224,10 +226,10 @@ public class TrackTests
Assert.Equal(script, track.Script); Assert.Equal(script, track.Script);
Assert.Equal(key, track.Key); Assert.Equal(key, track.Key);
Assert.Equal(bpm, track.Bpm); Assert.Equal(bpm, track.Bpm);
Assert.True(track.IsVideo);
Assert.Equal(work, track.Work); Assert.Equal(work, track.Work);
Assert.Equal(recordingId, track.MusicBrainzRecordingId); Assert.Equal(recordingId, track.MusicBrainzRecordingId);
Assert.Equal(trackId, track.MusicBrainzTrackId); Assert.Equal(trackId, track.MusicBrainzTrackId);
Assert.Equal(workId, track.MusicBrainzWorkId);
Assert.True(track.UpdatedOnUtc.HasValue); Assert.True(track.UpdatedOnUtc.HasValue);
Assert.True(track.UpdatedOnUtc.Value >= beforeUpdate); Assert.True(track.UpdatedOnUtc.Value >= beforeUpdate);
// the collections are not part of the details update // the collections are not part of the details update
@@ -245,10 +247,9 @@ public class TrackTests
key: Optional<MusicKey>.None(), key: Optional<MusicKey>.None(),
bpm: Optional<int>.None(), bpm: Optional<int>.None(),
isrcs: [], isrcs: [],
work: Optional<string>.None(), work: Optional<MusicWork>.None(),
musicBrainzRecordingId: Optional<MusicBrainzId>.None(), musicBrainzRecordingId: Optional<MusicBrainzId>.None(),
musicBrainzTrackId: Optional<MusicBrainzId>.None(), musicBrainzTrackId: Optional<MusicBrainzId>.None(),
musicBrainzWorkId: Optional<MusicBrainzId>.None(),
contributors: [], contributors: [],
ratings: []); ratings: []);
@@ -260,7 +261,6 @@ public class TrackTests
Assert.False(track.Work.HasValue); Assert.False(track.Work.HasValue);
Assert.False(track.MusicBrainzRecordingId.HasValue); Assert.False(track.MusicBrainzRecordingId.HasValue);
Assert.False(track.MusicBrainzTrackId.HasValue); Assert.False(track.MusicBrainzTrackId.HasValue);
Assert.False(track.MusicBrainzWorkId.HasValue);
Assert.Empty(track.Moods); Assert.Empty(track.Moods);
Assert.Empty(track.Isrcs); Assert.Empty(track.Isrcs);
Assert.Empty(track.Contributors); Assert.Empty(track.Contributors);
@@ -280,17 +280,18 @@ public class TrackTests
sourceTrack.Id, sourceTrack.Id,
sourceTrack.Path, sourceTrack.Path,
sourceTrack.Metadata, sourceTrack.Metadata,
sourceTrack.Disambiguation,
sourceTrack.TrackNumber, sourceTrack.TrackNumber,
sourceTrack.DiscNumber, sourceTrack.DiscNumber,
[.. sourceTrack.Moods], [.. sourceTrack.Moods],
sourceTrack.Script, sourceTrack.Script,
sourceTrack.Key, sourceTrack.Key,
sourceTrack.Bpm, sourceTrack.Bpm,
sourceTrack.IsVideo,
[.. sourceTrack.Isrcs], [.. sourceTrack.Isrcs],
sourceTrack.Work, sourceTrack.Work,
sourceTrack.MusicBrainzRecordingId, sourceTrack.MusicBrainzRecordingId,
sourceTrack.MusicBrainzTrackId, sourceTrack.MusicBrainzTrackId,
sourceTrack.MusicBrainzWorkId,
[.. sourceTrack.Contributors], [.. sourceTrack.Contributors],
[.. sourceTrack.Ratings], [.. sourceTrack.Ratings],
createdOnUtc, createdOnUtc,
@@ -305,7 +306,6 @@ public class TrackTests
Assert.Equal(sourceTrack.Work, track.Work); Assert.Equal(sourceTrack.Work, track.Work);
Assert.Equal(sourceTrack.MusicBrainzRecordingId, track.MusicBrainzRecordingId); Assert.Equal(sourceTrack.MusicBrainzRecordingId, track.MusicBrainzRecordingId);
Assert.Equal(sourceTrack.MusicBrainzTrackId, track.MusicBrainzTrackId); Assert.Equal(sourceTrack.MusicBrainzTrackId, track.MusicBrainzTrackId);
Assert.Equal(sourceTrack.MusicBrainzWorkId, track.MusicBrainzWorkId);
// The pre-existing identity and the provided timestamps must survive the rehydration. // The pre-existing identity and the provided timestamps must survive the rehydration.
Assert.Equal(sourceTrack.Id, track.Id); Assert.Equal(sourceTrack.Id, track.Id);
Assert.Equal(createdOnUtc, track.CreatedOnUtc); Assert.Equal(createdOnUtc, track.CreatedOnUtc);
@@ -380,8 +380,8 @@ public class TrackTests
Optional<string>.None(), Optional<string>.None(),
Optional<MusicKey>.None(), Optional<MusicKey>.None(),
Optional<int>.None(), Optional<int>.None(),
Optional<string>.None(), false,
Optional<MusicBrainzId>.None(), Optional<MusicWork>.None(),
Optional<MusicBrainzId>.None(), Optional<MusicBrainzId>.None(),
Optional<MusicBrainzId>.None()); Optional<MusicBrainzId>.None());
@@ -391,9 +391,9 @@ public class TrackTests
Assert.False(track.Script.HasValue); Assert.False(track.Script.HasValue);
Assert.False(track.Key.HasValue); Assert.False(track.Key.HasValue);
Assert.False(track.Bpm.HasValue); Assert.False(track.Bpm.HasValue);
Assert.False(track.IsVideo);
Assert.False(track.Work.HasValue); Assert.False(track.Work.HasValue);
Assert.False(track.MusicBrainzRecordingId.HasValue); Assert.False(track.MusicBrainzRecordingId.HasValue);
Assert.False(track.MusicBrainzTrackId.HasValue); Assert.False(track.MusicBrainzTrackId.HasValue);
Assert.False(track.MusicBrainzWorkId.HasValue);
} }
} }
@@ -37,13 +37,14 @@ public class AlbumMetadataTests
Result<AlbumMetadata> result = AlbumMetadata.Create( Result<AlbumMetadata> result = AlbumMetadata.Create(
"A Night at the Opera", "A Night at the Opera",
Optional<string>.Some("A Night at the Opera (original)"), Optional<string>.Some("A Night at the Opera (original)"),
Optional<string>.Some("A Night at the Opera (2011 remaster)"),
Optional<string>.Some("The fourth studio album by the British rock band Queen."), Optional<string>.Some("The fourth studio album by the British rock band Queen."),
releaseInfo, releaseInfo,
[genre], [genre],
[tag], [tag],
Optional<LanguageInfo>.Some(language), Optional<LanguageInfo>.Some(language),
Optional<LanguageInfo>.Some(originalLanguage), Optional<LanguageInfo>.Some(originalLanguage),
Optional<MusicReleaseType>.Some(MusicReleaseType.Album), [MusicReleaseType.Album],
Optional<MusicReleaseStatus>.Some(MusicReleaseStatus.Official), Optional<MusicReleaseStatus>.Some(MusicReleaseStatus.Official),
Optional<int>.Some(2), Optional<int>.Some(2),
12); 12);
@@ -53,13 +54,14 @@ public class AlbumMetadataTests
AlbumMetadata metadata = result.Value; AlbumMetadata metadata = result.Value;
Assert.Equal("A Night at the Opera", metadata.Title); Assert.Equal("A Night at the Opera", metadata.Title);
Assert.Equal(Optional<string>.Some("A Night at the Opera (original)"), metadata.OriginalTitle); Assert.Equal(Optional<string>.Some("A Night at the Opera (original)"), metadata.OriginalTitle);
Assert.Equal(Optional<string>.Some("A Night at the Opera (2011 remaster)"), metadata.ReleaseTitle);
Assert.Equal(Optional<string>.Some("The fourth studio album by the British rock band Queen."), metadata.Description); Assert.Equal(Optional<string>.Some("The fourth studio album by the British rock band Queen."), metadata.Description);
Assert.Equal(releaseInfo, metadata.ReleaseInfo); Assert.Equal(releaseInfo, metadata.ReleaseInfo);
Assert.Equal(genre, Assert.Single(metadata.Genres)); Assert.Equal(genre, Assert.Single(metadata.Genres));
Assert.Equal(tag, Assert.Single(metadata.Tags)); Assert.Equal(tag, Assert.Single(metadata.Tags));
Assert.Equal(Optional<LanguageInfo>.Some(language), metadata.Language); Assert.Equal(Optional<LanguageInfo>.Some(language), metadata.Language);
Assert.Equal(Optional<LanguageInfo>.Some(originalLanguage), metadata.OriginalLanguage); Assert.Equal(Optional<LanguageInfo>.Some(originalLanguage), metadata.OriginalLanguage);
Assert.Equal(Optional<MusicReleaseType>.Some(MusicReleaseType.Album), metadata.ReleaseType); Assert.Equal(new[] { MusicReleaseType.Album }, metadata.ReleaseTypes);
Assert.Equal(Optional<MusicReleaseStatus>.Some(MusicReleaseStatus.Official), metadata.ReleaseStatus); Assert.Equal(Optional<MusicReleaseStatus>.Some(MusicReleaseStatus.Official), metadata.ReleaseStatus);
Assert.Equal(Optional<int>.Some(2), metadata.TotalDiscs); Assert.Equal(Optional<int>.Some(2), metadata.TotalDiscs);
Assert.Equal(12, metadata.TotalTracks); Assert.Equal(12, metadata.TotalTracks);
@@ -73,12 +75,13 @@ public class AlbumMetadataTests
"A Night at the Opera", "A Night at the Opera",
Optional<string>.None(), Optional<string>.None(),
Optional<string>.None(), Optional<string>.None(),
Optional<string>.None(),
_releaseInfoFixture.Create(), _releaseInfoFixture.Create(),
[], [],
[], [],
Optional<LanguageInfo>.None(), Optional<LanguageInfo>.None(),
Optional<LanguageInfo>.None(), Optional<LanguageInfo>.None(),
Optional<MusicReleaseType>.None(), [],
Optional<MusicReleaseStatus>.None(), Optional<MusicReleaseStatus>.None(),
Optional<int>.None(), Optional<int>.None(),
12); 12);
@@ -87,10 +90,11 @@ public class AlbumMetadataTests
Assert.False(result.IsFailure); Assert.False(result.IsFailure);
AlbumMetadata metadata = result.Value; AlbumMetadata metadata = result.Value;
Assert.False(metadata.OriginalTitle.HasValue); Assert.False(metadata.OriginalTitle.HasValue);
Assert.False(metadata.ReleaseTitle.HasValue);
Assert.False(metadata.Description.HasValue); Assert.False(metadata.Description.HasValue);
Assert.False(metadata.Language.HasValue); Assert.False(metadata.Language.HasValue);
Assert.False(metadata.OriginalLanguage.HasValue); Assert.False(metadata.OriginalLanguage.HasValue);
Assert.False(metadata.ReleaseType.HasValue); Assert.Empty(metadata.ReleaseTypes);
Assert.False(metadata.ReleaseStatus.HasValue); Assert.False(metadata.ReleaseStatus.HasValue);
Assert.False(metadata.TotalDiscs.HasValue); Assert.False(metadata.TotalDiscs.HasValue);
Assert.Empty(metadata.Genres); Assert.Empty(metadata.Genres);
@@ -113,12 +117,13 @@ public class AlbumMetadataTests
"A Night at the Opera", "A Night at the Opera",
Optional<string>.None(), Optional<string>.None(),
Optional<string>.None(), Optional<string>.None(),
Optional<string>.None(),
_releaseInfoFixture.Create(), _releaseInfoFixture.Create(),
expectedGenres, expectedGenres,
expectedTags, expectedTags,
Optional<LanguageInfo>.None(), Optional<LanguageInfo>.None(),
Optional<LanguageInfo>.None(), Optional<LanguageInfo>.None(),
Optional<MusicReleaseType>.None(), [],
Optional<MusicReleaseStatus>.None(), Optional<MusicReleaseStatus>.None(),
Optional<int>.None(), Optional<int>.None(),
12); 12);
@@ -139,26 +144,28 @@ public class AlbumMetadataTests
AlbumMetadata firstMetadata = _albumMetadataFixture.Create( AlbumMetadata firstMetadata = _albumMetadataFixture.Create(
title: "A Night at the Opera", title: "A Night at the Opera",
originalTitle: Optional<string>.None(), originalTitle: Optional<string>.None(),
releaseTitle: Optional<string>.Some("A Night at the Opera (2011 remaster)"),
description: Optional<string>.None(), description: Optional<string>.None(),
releaseInfo: releaseInfo, releaseInfo: releaseInfo,
genres: [_genreFixture.Create(name: "Rock")], genres: [_genreFixture.Create(name: "Rock")],
tags: [_tagFixture.Create(name: "classic")], tags: [_tagFixture.Create(name: "classic")],
language: Optional<LanguageInfo>.None(), language: Optional<LanguageInfo>.None(),
originalLanguage: Optional<LanguageInfo>.None(), originalLanguage: Optional<LanguageInfo>.None(),
releaseType: Optional<MusicReleaseType>.Some(MusicReleaseType.Album), releaseTypes: [MusicReleaseType.Album],
releaseStatus: Optional<MusicReleaseStatus>.Some(MusicReleaseStatus.Official), releaseStatus: Optional<MusicReleaseStatus>.Some(MusicReleaseStatus.Official),
totalDiscs: Optional<int>.Some(2), totalDiscs: Optional<int>.Some(2),
totalTracks: 12); totalTracks: 12);
AlbumMetadata secondMetadata = _albumMetadataFixture.Create( AlbumMetadata secondMetadata = _albumMetadataFixture.Create(
title: "A Night at the Opera", title: "A Night at the Opera",
originalTitle: Optional<string>.None(), originalTitle: Optional<string>.None(),
releaseTitle: Optional<string>.Some("A Night at the Opera (2011 remaster)"),
description: Optional<string>.None(), description: Optional<string>.None(),
releaseInfo: releaseInfo, releaseInfo: releaseInfo,
genres: [_genreFixture.Create(name: "Rock")], genres: [_genreFixture.Create(name: "Rock")],
tags: [_tagFixture.Create(name: "classic")], tags: [_tagFixture.Create(name: "classic")],
language: Optional<LanguageInfo>.None(), language: Optional<LanguageInfo>.None(),
originalLanguage: Optional<LanguageInfo>.None(), originalLanguage: Optional<LanguageInfo>.None(),
releaseType: Optional<MusicReleaseType>.Some(MusicReleaseType.Album), releaseTypes: [MusicReleaseType.Album],
releaseStatus: Optional<MusicReleaseStatus>.Some(MusicReleaseStatus.Official), releaseStatus: Optional<MusicReleaseStatus>.Some(MusicReleaseStatus.Official),
totalDiscs: Optional<int>.Some(2), totalDiscs: Optional<int>.Some(2),
totalTracks: 12); totalTracks: 12);
@@ -191,11 +198,11 @@ public class AlbumMetadataTests
AlbumMetadata firstMetadata = _albumMetadataFixture.Create( AlbumMetadata firstMetadata = _albumMetadataFixture.Create(
title: "A Night at the Opera", title: "A Night at the Opera",
releaseInfo: releaseInfo, releaseInfo: releaseInfo,
releaseType: Optional<MusicReleaseType>.Some(MusicReleaseType.Album)); releaseTypes: [MusicReleaseType.Album]);
AlbumMetadata secondMetadata = _albumMetadataFixture.Create( AlbumMetadata secondMetadata = _albumMetadataFixture.Create(
title: "A Night at the Opera", title: "A Night at the Opera",
releaseInfo: releaseInfo, releaseInfo: releaseInfo,
releaseType: Optional<MusicReleaseType>.Some(MusicReleaseType.Single)); releaseTypes: [MusicReleaseType.Single]);
// Assert // Assert
Assert.NotEqual(firstMetadata, secondMetadata); Assert.NotEqual(firstMetadata, secondMetadata);