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