diff --git a/src/Lumina.Domain/Common/Errors/Errors.Music.cs b/src/Lumina.Domain/Common/Errors/Errors.Music.cs index 42acfa31..d4cca16a 100644 --- a/src/Lumina.Domain/Common/Errors/Errors.Music.cs +++ b/src/Lumina.Domain/Common/Errors/Errors.Music.cs @@ -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)); } } diff --git a/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/Common/ValueObjects/AudioMetadata.cs b/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/Common/ValueObjects/AudioMetadata.cs index 1326fb7d..27db4eda 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/Common/ValueObjects/AudioMetadata.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/Common/ValueObjects/AudioMetadata.cs @@ -43,6 +43,31 @@ public class AudioMetadata : BaseMetadata /// public Optional Bitrate { get; } + /// + /// Gets the AcoustID fingerprint identifier of the audio file, if applicable. + /// + public Optional AcoustId { get; } + + /// + /// Gets the ReplayGain track gain in decibels, if applicable. + /// + public Optional ReplayGainTrackGain { get; } + + /// + /// Gets the ReplayGain track peak, if applicable. + /// + public Optional ReplayGainTrackPeak { get; } + + /// + /// Gets the ReplayGain album gain in decibels, if applicable. + /// + public Optional ReplayGainAlbumGain { get; } + + /// + /// Gets the ReplayGain album peak, if applicable. + /// + public Optional ReplayGainAlbumPeak { get; } + /// /// Initializes a new instance of the class. /// @@ -60,6 +85,11 @@ public class AudioMetadata : BaseMetadata /// The genres of the audio. /// The tags associated with the audio. /// The bitrate of the audio in kbps. + /// The AcoustID fingerprint identifier of the audio file. + /// The ReplayGain track gain in decibels. + /// The ReplayGain track peak. + /// The ReplayGain album gain in decibels. + /// The ReplayGain album peak. private AudioMetadata( string title, Optional originalTitle, @@ -74,7 +104,12 @@ public class AudioMetadata : BaseMetadata Optional originalLanguage, Optional bitDepth, Optional audioCodec, - Optional bitrate) + Optional bitrate, + Optional acoustId, + Optional replayGainTrackGain, + Optional replayGainTrackPeak, + Optional replayGainAlbumGain, + Optional 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; } /// @@ -102,6 +142,11 @@ public class AudioMetadata : BaseMetadata /// The genres of the audio. /// The tags associated with the audio. /// The bitrate of the audio in kbps. + /// The AcoustID fingerprint identifier of the audio file. + /// The ReplayGain track gain in decibels. + /// The ReplayGain track peak. + /// The ReplayGain album gain in decibels. + /// The ReplayGain album peak. /// /// An containing either a successfully created , or an error message. /// @@ -119,7 +164,12 @@ public class AudioMetadata : BaseMetadata Optional originalLanguage, Optional bitDepth, Optional audioCodec, - Optional bitrate) + Optional bitrate, + Optional acoustId, + Optional replayGainTrackGain, + Optional replayGainTrackPeak, + Optional replayGainAlbumGain, + Optional replayGainAlbumPeak) { return new AudioMetadata( title, @@ -135,7 +185,12 @@ public class AudioMetadata : BaseMetadata originalLanguage, bitDepth, audioCodec, - bitrate); + bitrate, + acoustId, + replayGainTrackGain, + replayGainTrackPeak, + replayGainAlbumGain, + replayGainAlbumPeak); } /// @@ -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; } } diff --git a/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Artist.cs b/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Artist.cs index ea66a780..62baa2ee 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Artist.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Artist.cs @@ -30,6 +30,12 @@ namespace Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLib public sealed class Artist : AggregateRoot { private readonly HashSet _contributors; + private readonly List _aliases; + private readonly List _ipis; + private readonly List _isnis; + private readonly List _genres; + private readonly List _tags; + private readonly List _ratings; private readonly List _albums; /// @@ -42,6 +48,61 @@ public sealed class Artist : AggregateRoot /// public string Name { get; private set; } + /// + /// Gets the sort name of the artist, a variant of the name used when sorting artists, if applicable. + /// + public Optional SortName { get; private set; } + + /// + /// Gets the disambiguation comment of the artist, used to distinguish artists with the same name, if applicable. + /// + public Optional Disambiguation { get; private set; } + + /// + /// Gets the type of the artist, describing whether it is a person, a group, or something else, if applicable. + /// + public Optional Type { get; private set; } + + /// + /// Gets the gender of the artist, applicable only to artists that are persons or characters, if applicable. + /// + public Optional Gender { get; private set; } + + /// + /// Gets the ISO 3166-1 alpha-2 code of the country the artist is associated with, if applicable. + /// + public Optional Country { get; private set; } + + /// + /// Gets the area the artist is primarily identified with, if applicable. + /// + public Optional Area { get; private set; } + + /// + /// Gets the area the artist began in, if applicable. + /// + public Optional BeginArea { get; private set; } + + /// + /// Gets the area the artist ended in, if applicable. + /// + public Optional EndArea { get; private set; } + + /// + /// Gets the date the artist started existing, if applicable. + /// + public Optional LifeSpanBegin { get; private set; } + + /// + /// Gets the date the artist stopped existing, if applicable. + /// + public Optional LifeSpanEnd { get; private set; } + + /// + /// Gets a value indicating whether the artist no longer exists. + /// + public bool IsEnded { get; private set; } + /// /// Gets the website of the artist, if applicable. /// @@ -52,6 +113,36 @@ public sealed class Artist : AggregateRoot /// public Optional MusicBrainzArtistId { get; private set; } + /// + /// Gets the list of IPI (Interested Party Information) codes of the artist. + /// + public IReadOnlyCollection Ipis => _ipis.AsReadOnly(); + + /// + /// Gets the list of ISNI (International Standard Name Identifier) codes of the artist. + /// + public IReadOnlyCollection Isnis => _isnis.AsReadOnly(); + + /// + /// Gets the list of alternative names of the artist. + /// + public IReadOnlyCollection Aliases => _aliases.AsReadOnly(); + + /// + /// Gets the list of genres associated with the artist. + /// + public IReadOnlyCollection Genres => _genres.AsReadOnly(); + + /// + /// Gets the list of tags associated with the artist. + /// + public IReadOnlyCollection Tags => _tags.AsReadOnly(); + + /// + /// Gets the list of ratings of the artist. + /// + public IReadOnlyCollection Ratings => _ratings.AsReadOnly(); + /// /// Gets the list of the media contributors that make up the artist. /// @@ -68,8 +159,25 @@ public sealed class Artist : AggregateRoot /// The object representing the unique identifier of the artist. /// The Id of the media library this artist belongs to. /// The name of the artist. + /// The optional sort name of the artist. + /// The optional disambiguation comment of the artist. + /// The optional type of the artist. + /// The optional gender of the artist. + /// The optional ISO 3166-1 alpha-2 code of the country of the artist. + /// The optional area the artist is primarily identified with. + /// The optional area the artist began in. + /// The optional area the artist ended in. + /// The optional date the artist started existing. + /// The optional date the artist stopped existing. + /// Whether the artist no longer exists. /// The optional website of the artist. /// The optional MusicBrainz identifier of the artist. + /// The list of IPI codes of the artist. + /// The list of ISNI codes of the artist. + /// The list of alternative names of the artist. + /// The list of genres associated with the artist. + /// The list of tags associated with the artist. + /// The list of ratings of the artist. /// The list of the media contributors that make up the artist. /// The list of albums of the artist. /// The date and time when the entity was created. @@ -78,8 +186,25 @@ public sealed class Artist : AggregateRoot ArtistId id, LibraryId libraryId, string name, + Optional sortName, + Optional disambiguation, + Optional type, + Optional gender, + Optional country, + Optional area, + Optional beginArea, + Optional endArea, + Optional lifeSpanBegin, + Optional lifeSpanEnd, + bool isEnded, Optional website, Optional musicBrainzArtistId, + List ipis, + List isnis, + List aliases, + List genres, + List tags, + List ratings, List contributors, List albums, DateTime createdOnUtc, @@ -88,8 +213,25 @@ public sealed class Artist : AggregateRoot 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 /// /// The Id of the media library this artist belongs to. /// The name of the artist. + /// The optional sort name of the artist. + /// The optional disambiguation comment of the artist. + /// The optional type of the artist. + /// The optional gender of the artist. + /// The optional ISO 3166-1 alpha-2 code of the country of the artist. + /// The optional area the artist is primarily identified with. + /// The optional area the artist began in. + /// The optional area the artist ended in. + /// The optional date the artist started existing. + /// The optional date the artist stopped existing. + /// Whether the artist no longer exists. /// The optional website of the artist. /// The optional MusicBrainz identifier of the artist. + /// The list of IPI codes of the artist. + /// The list of ISNI codes of the artist. + /// The list of alternative names of the artist. + /// The list of genres associated with the artist. + /// The list of tags associated with the artist. + /// The list of ratings of the artist. /// The list of the media contributors that make up the artist. /// The list of albums of the artist. /// @@ -111,8 +270,25 @@ public sealed class Artist : AggregateRoot public static Result Create( LibraryId libraryId, string name, + Optional sortName, + Optional disambiguation, + Optional type, + Optional gender, + Optional country, + Optional area, + Optional beginArea, + Optional endArea, + Optional lifeSpanBegin, + Optional lifeSpanEnd, + bool isEnded, Optional website, Optional musicBrainzArtistId, + List ipis, + List isnis, + List aliases, + List genres, + List tags, + List ratings, List contributors, List albums) { @@ -125,8 +301,25 @@ public sealed class Artist : AggregateRoot 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 /// The object representing the unique identifier of the artist. /// The Id of the media library this artist belongs to. /// The name of the artist. + /// The optional sort name of the artist. + /// The optional disambiguation comment of the artist. + /// The optional type of the artist. + /// The optional gender of the artist. + /// The optional ISO 3166-1 alpha-2 code of the country of the artist. + /// The optional area the artist is primarily identified with. + /// The optional area the artist began in. + /// The optional area the artist ended in. + /// The optional date the artist started existing. + /// The optional date the artist stopped existing. + /// Whether the artist no longer exists. /// The optional website of the artist. /// The optional MusicBrainz identifier of the artist. + /// The list of IPI codes of the artist. + /// The list of ISNI codes of the artist. + /// The list of alternative names of the artist. + /// The list of genres associated with the artist. + /// The list of tags associated with the artist. + /// The list of ratings of the artist. /// The list of the media contributors that make up the artist. /// The list of albums of the artist. /// The date and time when the entity was created. @@ -152,8 +362,25 @@ public sealed class Artist : AggregateRoot ArtistId id, LibraryId libraryId, string name, + Optional sortName, + Optional disambiguation, + Optional type, + Optional gender, + Optional country, + Optional area, + Optional beginArea, + Optional endArea, + Optional lifeSpanBegin, + Optional lifeSpanEnd, + bool isEnded, Optional website, Optional musicBrainzArtistId, + List ipis, + List isnis, + List aliases, + List genres, + List tags, + List ratings, List contributors, List albums, DateTime createdOnUtc, @@ -168,8 +395,25 @@ public sealed class Artist : AggregateRoot 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 } /// - /// Updates the details of the artist, without touching the albums and the media contributors. + /// Replaces the aliases of the artist with the provided . + /// + /// The alternative names of the artist. + public void UpdateAliases(IReadOnlyCollection aliases) + { + // Replace the contents of the collection in place, preserving the readonly reference invariants of the aggregate. + _aliases.Clear(); + _aliases.AddRange(aliases); + } + + /// + /// Replaces the IPI codes of the artist with the provided . + /// + /// The IPI codes of the artist. + public void UpdateIpis(IReadOnlyCollection ipis) + { + // Replace the contents of the collection in place, preserving the readonly reference invariants of the aggregate. + _ipis.Clear(); + _ipis.AddRange(ipis); + } + + /// + /// Replaces the ISNI codes of the artist with the provided . + /// + /// The ISNI codes of the artist. + public void UpdateIsnis(IReadOnlyCollection isnis) + { + // Replace the contents of the collection in place, preserving the readonly reference invariants of the aggregate. + _isnis.Clear(); + _isnis.AddRange(isnis); + } + + /// + /// Replaces the genres of the artist with the provided . + /// + /// The genres of the artist. + public void UpdateGenres(IReadOnlyCollection genres) + { + // Replace the contents of the collection in place, preserving the readonly reference invariants of the aggregate. + _genres.Clear(); + _genres.AddRange(genres); + } + + /// + /// Replaces the tags of the artist with the provided . + /// + /// The tags of the artist. + public void UpdateTags(IReadOnlyCollection tags) + { + // Replace the contents of the collection in place, preserving the readonly reference invariants of the aggregate. + _tags.Clear(); + _tags.AddRange(tags); + } + + /// + /// Replaces the ratings of the artist with the provided . + /// + /// The ratings of the artist. + public void UpdateRatings(IReadOnlyCollection ratings) + { + // Replace the contents of the collection in place, preserving the readonly reference invariants of the aggregate. + _ratings.Clear(); + _ratings.AddRange(ratings); + } + + /// + /// Updates the details of the artist, without touching the albums, the contributors, and the media library metadata collections. /// /// The name of the artist. + /// The optional sort name of the artist. + /// The optional disambiguation comment of the artist. + /// The optional type of the artist. + /// The optional gender of the artist. + /// The optional ISO 3166-1 alpha-2 code of the country of the artist. + /// The optional area the artist is primarily identified with. + /// The optional area the artist began in. + /// The optional area the artist ended in. + /// The optional date the artist started existing. + /// The optional date the artist stopped existing. + /// Whether the artist no longer exists. /// The optional website of the artist. /// The optional MusicBrainz identifier of the artist. /// An representing either a successful operation, or an error. public Result UpdateDetails( string name, + Optional sortName, + Optional disambiguation, + Optional type, + Optional gender, + Optional country, + Optional area, + Optional beginArea, + Optional endArea, + Optional lifeSpanBegin, + Optional lifeSpanEnd, + bool isEnded, Optional website, Optional musicBrainzArtistId) { @@ -231,6 +563,17 @@ public sealed class Artist : AggregateRoot 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.Some(DateTime.UtcNow); @@ -247,9 +590,14 @@ public sealed class Artist : AggregateRoot /// /// The album to update. /// The album metadata of the album. + /// The optional disambiguation comment of the album. /// The optional physical or digital medium of the album. + /// The optional outermost physical packaging of the album. + /// The optional script used by the language of the release of the album. /// The optional barcode of the album. - /// The optional catalog number of the album. + /// The catalog numbers of the album. + /// The optional name of the label that issued the album. + /// The optional ASIN of the album. /// The optional MusicBrainz identifier of the release. /// The optional MusicBrainz identifier of the release group. /// The optional MusicBrainz identifier of the release artist. @@ -259,9 +607,14 @@ public sealed class Artist : AggregateRoot public Result UpdateAlbum( Album album, AlbumMetadata metadata, + Optional disambiguation, Optional mediaFormat, + Optional packaging, + Optional script, Optional barcode, - Optional catalogNumber, + List catalogNumbers, + Optional label, + Optional asin, Optional musicBrainzReleaseId, Optional musicBrainzReleaseGroupId, Optional musicBrainzReleaseArtistId, @@ -272,7 +625,7 @@ public sealed class Artist : AggregateRoot 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.Some(DateTime.UtcNow); @@ -296,10 +649,10 @@ public sealed class Artist : AggregateRoot /// The optional script used by the language of the track. /// The optional musical key of the track. /// The optional tempo of the track in beats per minute. - /// The optional title of the work the track is a recording of. + /// Whether the recording of the track is a video recording. + /// The optional work the track is a recording of. /// The optional MusicBrainz identifier of the recording. /// The optional MusicBrainz identifier of the track. - /// The optional MusicBrainz identifier of the work. /// The moods of the track. /// The ISRCs of the track. /// The media contributors of the track. @@ -315,10 +668,10 @@ public sealed class Artist : AggregateRoot Optional script, Optional key, Optional bpm, - Optional work, + bool isVideo, + Optional work, Optional musicBrainzRecordingId, Optional musicBrainzTrackId, - Optional musicBrainzWorkId, IReadOnlyCollection moods, IReadOnlyCollection isrcs, IReadOnlyCollection contributors, @@ -338,10 +691,10 @@ public sealed class Artist : AggregateRoot script, key, bpm, + isVideo, work, musicBrainzRecordingId, - musicBrainzTrackId, - musicBrainzWorkId); + musicBrainzTrackId); track.UpdateMoods(moods); track.UpdateIsrcs(isrcs); track.UpdateContributors(contributors); diff --git a/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/Album.cs b/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/Album.cs index 665f7cfd..2ed88cf1 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/Album.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/Album.cs @@ -21,26 +21,52 @@ public sealed class Album : Entity private readonly List _contributors; private readonly List _ratings; private readonly List _tracks; + private readonly List _catalogNumbers; /// /// Gets the album metadata of the album. /// public AlbumMetadata Metadata { get; private set; } + /// + /// Gets the disambiguation comment of the album, used to distinguish albums with the same title, if applicable. + /// + public Optional Disambiguation { get; private set; } + /// /// Gets the physical or digital medium of the album, if applicable. /// public Optional MediaFormat { get; private set; } + /// + /// Gets the outermost physical packaging of the album, if applicable. + /// + public Optional Packaging { get; private set; } + + /// + /// Gets the script used by the language of the release of the album, if applicable. + /// + public Optional Script { get; private set; } + /// /// Gets the barcode of the album, if applicable. /// public Optional Barcode { get; private set; } /// - /// Gets the catalog number of the album, if applicable. + /// Gets the catalog numbers of the album. /// - public Optional CatalogNumber { get; private set; } + public IReadOnlyCollection CatalogNumbers => _catalogNumbers.AsReadOnly(); + + /// + /// Gets the name of the label that issued the album, if applicable. + /// + public Optional Label { get; private set; } + + /// + /// Gets the ASIN (Amazon Standard Identification Number) of the album, if applicable. + /// + public Optional ASIN { get; private set; } /// /// Gets the MusicBrainz identifier of the release, if applicable. @@ -77,9 +103,14 @@ public sealed class Album : Entity /// /// The object representing the unique identifier of the album. /// The album metadata of the album. + /// The optional disambiguation comment of the album. /// The optional physical or digital medium of the album. + /// The optional outermost physical packaging of the album. + /// The optional script used by the language of the release of the album. /// The optional barcode of the album. - /// The optional catalog number of the album. + /// The catalog numbers of the album. + /// The optional name of the label that issued the album. + /// The optional ASIN of the album. /// The optional MusicBrainz identifier of the release. /// The optional MusicBrainz identifier of the release group. /// The optional MusicBrainz identifier of the release artist. @@ -91,9 +122,14 @@ public sealed class Album : Entity private Album( AlbumId id, AlbumMetadata metadata, + Optional disambiguation, Optional mediaFormat, + Optional packaging, + Optional script, Optional barcode, - Optional catalogNumber, + List catalogNumbers, + Optional label, + Optional asin, Optional musicBrainzReleaseId, Optional musicBrainzReleaseGroupId, Optional musicBrainzReleaseArtistId, @@ -105,9 +141,14 @@ public sealed class Album : Entity { 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 /// Creates a new instance of the class. /// /// The album metadata of the album. + /// The optional disambiguation comment of the album. /// The optional physical or digital medium of the album. + /// The optional outermost physical packaging of the album. + /// The optional script used by the language of the release of the album. /// The optional barcode of the album. - /// The optional catalog number of the album. + /// The catalog numbers of the album. + /// The optional name of the label that issued the album. + /// The optional ASIN of the album. /// The optional MusicBrainz identifier of the release. /// The optional MusicBrainz identifier of the release group. /// The optional MusicBrainz identifier of the release artist. @@ -136,9 +182,14 @@ public sealed class Album : Entity /// public static Result Create( AlbumMetadata metadata, + Optional disambiguation, Optional mediaFormat, + Optional packaging, + Optional script, Optional barcode, - Optional catalogNumber, + List catalogNumbers, + Optional label, + Optional asin, Optional musicBrainzReleaseId, Optional musicBrainzReleaseGroupId, Optional musicBrainzReleaseArtistId, @@ -149,9 +200,14 @@ public sealed class Album : Entity 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 /// /// The object representing the unique identifier of the album. /// The album metadata of the album. + /// The optional disambiguation comment of the album. /// The optional physical or digital medium of the album. + /// The optional outermost physical packaging of the album. + /// The optional script used by the language of the release of the album. /// The optional barcode of the album. - /// The optional catalog number of the album. + /// The catalog numbers of the album. + /// The optional name of the label that issued the album. + /// The optional ASIN of the album. /// The optional MusicBrainz identifier of the release. /// The optional MusicBrainz identifier of the release group. /// The optional MusicBrainz identifier of the release artist. @@ -184,9 +245,14 @@ public sealed class Album : Entity public static Result Create( AlbumId id, AlbumMetadata metadata, + Optional disambiguation, Optional mediaFormat, + Optional packaging, + Optional script, Optional barcode, - Optional catalogNumber, + List catalogNumbers, + Optional label, + Optional asin, Optional musicBrainzReleaseId, Optional musicBrainzReleaseGroupId, Optional musicBrainzReleaseArtistId, @@ -199,9 +265,14 @@ public sealed class Album : Entity 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 /// Updates the details of the album, without touching the ratings, the media contributors, and the tracks. /// /// The album metadata of the album. + /// The optional disambiguation comment of the album. /// The optional physical or digital medium of the album. + /// The optional outermost physical packaging of the album. + /// The optional script used by the language of the release of the album. /// The optional barcode of the album. - /// The optional catalog number of the album. + /// The catalog numbers of the album. + /// The optional name of the label that issued the album. + /// The optional ASIN of the album. /// The optional MusicBrainz identifier of the release. /// The optional MusicBrainz identifier of the release group. /// The optional MusicBrainz identifier of the release artist. /// An representing either a successful operation, or an error. internal Result UpdateDetails( AlbumMetadata metadata, + Optional disambiguation, Optional mediaFormat, + Optional packaging, + Optional script, Optional barcode, - Optional catalogNumber, + List catalogNumbers, + Optional label, + Optional asin, Optional musicBrainzReleaseId, Optional musicBrainzReleaseGroupId, Optional 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; diff --git a/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/Track.cs b/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/Track.cs index d7c418b8..09c42e2c 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/Track.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/Track.cs @@ -34,6 +34,11 @@ public sealed class Track : Entity /// public AudioMetadata Metadata { get; private set; } + /// + /// Gets the disambiguation comment of the track, used to distinguish tracks with the same title, if applicable. + /// + public Optional Disambiguation { get; private set; } + /// /// Gets the number of the track on its disc. /// @@ -60,9 +65,14 @@ public sealed class Track : Entity public Optional Bpm { get; private set; } /// - /// 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. /// - public Optional Work { get; private set; } + public bool IsVideo { get; private set; } + + /// + /// Gets the work the track is a recording of, if applicable. + /// + public Optional Work { get; private set; } /// /// Gets the MusicBrainz identifier of the recording, if applicable. @@ -74,11 +84,6 @@ public sealed class Track : Entity /// public Optional MusicBrainzTrackId { get; private set; } - /// - /// Gets the MusicBrainz identifier of the work, if applicable. - /// - public Optional MusicBrainzWorkId { get; private set; } - /// /// Gets the list of moods of the track. /// @@ -105,36 +110,38 @@ public sealed class Track : Entity /// The object representing the unique identifier of the track. /// The file system path of the track. /// The audio metadata of the track. + /// The optional disambiguation comment of the track. /// The number of the track on its disc. /// The optional number of the disc the track belongs to. /// The list of moods of the track. /// The optional script used by the language of the track. /// The optional musical key of the track. /// The optional tempo of the track in beats per minute. + /// Whether the recording of the track is a video recording. /// The list of ISRC of the track. - /// The optional title of the work the track is a recording of. + /// The optional work the track is a recording of. /// The optional MusicBrainz identifier of the recording. /// The optional MusicBrainz identifier of the track. - /// The optional MusicBrainz identifier of the work. /// The list of the media contributors of the track. - /// The list of ratings for the track. + /// The list of ratings of the track. /// The date and time when the entity was created. /// The date and time when the entity was last updated. private Track( TrackId id, string path, AudioMetadata metadata, + Optional disambiguation, int trackNumber, Optional discNumber, List moods, Optional script, Optional key, Optional bpm, + bool isVideo, List isrcs, - Optional work, + Optional work, Optional musicBrainzRecordingId, Optional musicBrainzTrackId, - Optional musicBrainzWorkId, List contributors, List ratings, DateTime createdOnUtc, @@ -143,6 +150,7 @@ public sealed class Track : Entity Id = id; Path = path; Metadata = metadata; + Disambiguation = disambiguation; TrackNumber = trackNumber; DiscNumber = discNumber; _moods = moods; @@ -150,10 +158,10 @@ public sealed class Track : Entity 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 /// /// The file system path of the track. /// The audio metadata of the track. + /// The optional disambiguation comment of the track. /// The number of the track on its disc. /// The optional number of the disc the track belongs to. /// The list of moods of the track. /// The optional script used by the language of the track. /// The optional musical key of the track. /// The optional tempo of the track in beats per minute. + /// Whether the recording of the track is a video recording. /// The list of ISRC of the track. - /// The optional title of the work the track is a recording of. + /// The optional work the track is a recording of. /// The optional MusicBrainz identifier of the recording. /// The optional MusicBrainz identifier of the track. - /// The optional MusicBrainz identifier of the work. /// The list of the media contributors of the track. - /// The list of ratings for the track. + /// The list of ratings of the track. /// /// An containing either a successfully created , or an error message. /// public static Result Create( string path, AudioMetadata metadata, + Optional disambiguation, int trackNumber, Optional discNumber, List moods, Optional script, Optional key, Optional bpm, + bool isVideo, List isrcs, - Optional work, + Optional work, Optional musicBrainzRecordingId, Optional musicBrainzTrackId, - Optional musicBrainzWorkId, List contributors, List ratings) { @@ -202,17 +212,18 @@ public sealed class Track : Entity 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 /// The object representing the unique identifier of the track. /// The file system path of the track. /// The audio metadata of the track. + /// The optional disambiguation comment of the track. /// The number of the track on its disc. /// The optional number of the disc the track belongs to. /// The list of moods of the track. /// The optional script used by the language of the track. /// The optional musical key of the track. /// The optional tempo of the track in beats per minute. + /// Whether the recording of the track is a video recording. /// The list of ISRC of the track. - /// The optional title of the work the track is a recording of. + /// The optional work the track is a recording of. /// The optional MusicBrainz identifier of the recording. /// The optional MusicBrainz identifier of the track. - /// The optional MusicBrainz identifier of the work. /// The list of the media contributors of the track. - /// The list of ratings for the track. + /// The list of ratings of the track. /// The date and time when the entity was created. /// The date and time when the entity was last updated. /// @@ -247,17 +259,18 @@ public sealed class Track : Entity TrackId id, string path, AudioMetadata metadata, + Optional disambiguation, int trackNumber, Optional discNumber, List moods, Optional script, Optional key, Optional bpm, + bool isVideo, List isrcs, - Optional work, + Optional work, Optional musicBrainzRecordingId, Optional musicBrainzTrackId, - Optional musicBrainzWorkId, List contributors, List ratings, DateTime createdOnUtc, @@ -267,17 +280,18 @@ public sealed class Track : Entity 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 /// The optional script used by the language of the track. /// The optional musical key of the track. /// The optional tempo of the track in beats per minute. - /// The optional title of the work the track is a recording of. + /// Whether the recording of the track is a video recording. + /// The optional work the track is a recording of. /// The optional MusicBrainz identifier of the recording. /// The optional MusicBrainz identifier of the track. - /// The optional MusicBrainz identifier of the work. /// An representing either a successful operation, or an error. internal Result UpdateDetails( string path, @@ -351,10 +365,10 @@ public sealed class Track : Entity Optional script, Optional key, Optional bpm, - Optional work, + bool isVideo, + Optional work, Optional musicBrainzRecordingId, - Optional musicBrainzTrackId, - Optional musicBrainzWorkId) + Optional musicBrainzTrackId) { Path = path; Metadata = metadata; @@ -363,10 +377,10 @@ public sealed class Track : Entity Script = script; Key = key; Bpm = bpm; + IsVideo = isVideo; Work = work; MusicBrainzRecordingId = musicBrainzRecordingId; MusicBrainzTrackId = musicBrainzTrackId; - MusicBrainzWorkId = musicBrainzWorkId; UpdatedOnUtc = Optional.Some(DateTime.UtcNow); return Result.Updated; } diff --git a/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ValueObjects/AlbumMetadata.cs b/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ValueObjects/AlbumMetadata.cs index 80ebc675..055e74bc 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ValueObjects/AlbumMetadata.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ValueObjects/AlbumMetadata.cs @@ -14,10 +14,18 @@ namespace Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLib [DebuggerDisplay("{Title}")] public class AlbumMetadata : BaseMetadata { + private readonly List _releaseTypes; + /// - /// 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. /// - public Optional ReleaseType { get; } + public Optional ReleaseTitle { get; } + + /// + /// 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. + /// + public IReadOnlyCollection ReleaseTypes => _releaseTypes.AsReadOnly(); /// /// Gets the status of the release, if applicable. @@ -39,32 +47,35 @@ public class AlbumMetadata : BaseMetadata /// /// The title of the album. /// The optional original title of the album, if applicable. + /// The optional title of the specific release (edition) of the album. /// The description of the album, if applicable. /// The release information of the album. /// The genres of the album. /// The tags associated with the album. /// The language of the album, if applicable. /// The optional original language of the album, if applicable. - /// The optional type of the release. + /// The set of types of the release, if applicable. /// The optional status of the release. /// The optional number of discs of the release. /// The number of tracks of the release. private AlbumMetadata( string title, Optional originalTitle, + Optional releaseTitle, Optional description, ReleaseInfo releaseInfo, List genres, List tags, Optional language, Optional originalLanguage, - Optional releaseType, + List releaseTypes, Optional releaseStatus, Optional 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 /// /// The title of the album. /// The optional original title of the album, if applicable. + /// The optional title of the specific release (edition) of the album. /// The description of the album, if applicable. /// The release information of the album. /// The genres of the album. /// The tags associated with the album. /// The language of the album, if applicable. /// The optional original language of the album, if applicable. - /// The optional type of the release. + /// The set of types of the release, if applicable. /// The optional status of the release. /// The optional number of discs of the release. /// The number of tracks of the release. @@ -91,13 +103,14 @@ public class AlbumMetadata : BaseMetadata public static Result Create( string title, Optional originalTitle, + Optional releaseTitle, Optional description, ReleaseInfo releaseInfo, List genres, List tags, Optional language, Optional originalLanguage, - Optional releaseType, + List releaseTypes, Optional releaseStatus, Optional 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; diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/Common/ValueObjects/AudioMetadataFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/Common/ValueObjects/AudioMetadataFixture.cs index 3c3e41c1..f8c4be25 100644 --- a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/Common/ValueObjects/AudioMetadataFixture.cs +++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/Common/ValueObjects/AudioMetadataFixture.cs @@ -40,6 +40,11 @@ public class AudioMetadataFixture /// Optional. The bit depth of the audio. /// Optional. The audio codec used. /// Optional. The bitrate of the audio, in kbps. + /// Optional. The AcoustID fingerprint identifier of the audio file. + /// Optional. The ReplayGain track gain, in decibels. + /// Optional. The ReplayGain track peak. + /// Optional. The ReplayGain album gain, in decibels. + /// Optional. The ReplayGain album peak. /// The created . public AudioMetadata Create( string? title = null, @@ -55,7 +60,12 @@ public class AudioMetadataFixture Optional? originalLanguage = null, Optional? bitDepth = null, Optional? audioCodec = null, - Optional? bitrate = null) + Optional? bitrate = null, + Optional? acoustId = null, + Optional? replayGainTrackGain = null, + Optional? replayGainTrackPeak = null, + Optional? replayGainAlbumGain = null, + Optional? replayGainAlbumPeak = null) { return AudioMetadata.Create( title ?? _faker.Music.Genre(), @@ -71,7 +81,12 @@ public class AudioMetadataFixture originalLanguage ?? Optional.None(), bitDepth ?? Optional.Some(_faker.Random.Int(8, 32)), audioCodec ?? Optional.Some("PCM"), - bitrate ?? Optional.Some(_faker.Random.Int(128, 320))).Value; + bitrate ?? Optional.Some(_faker.Random.Int(128, 320)), + acoustId ?? Optional.None(), + replayGainTrackGain ?? Optional.None(), + replayGainTrackPeak ?? Optional.None(), + replayGainAlbumGain ?? Optional.None(), + replayGainAlbumPeak ?? Optional.None()).Value; } /// diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ArtistFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ArtistFixture.cs index 5182b00c..d72a72af 100644 --- a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ArtistFixture.cs +++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ArtistFixture.cs @@ -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(); /// /// Creates a random valid domain aggregate root. /// /// Optional. The Id of the media library this artist belongs to. /// Optional. The name of the artist. + /// Optional. The sort name of the artist. + /// Optional. The disambiguation comment of the artist. + /// Optional. The type of the artist. + /// Optional. The gender of the artist. + /// Optional. The country of the artist. + /// Optional. The area the artist is primarily identified with. + /// Optional. The area the artist began in. + /// Optional. The area the artist ended in. + /// Optional. The date the artist started existing. + /// Optional. The date the artist stopped existing. + /// Optional. Whether the artist no longer exists. /// Optional. The website of the artist. /// Optional. The MusicBrainz identifier of the artist. + /// Optional. The IPI codes of the artist. + /// Optional. The ISNI codes of the artist. + /// Optional. The alternative names of the artist. + /// Optional. The genres associated with the artist. + /// Optional. The tags associated with the artist. + /// Optional. The ratings of the artist. /// Optional. The media contributors that make up the artist. /// Optional. The albums of the artist. Defaults to a single random album, since an artist must have at least one. /// The created domain aggregate root. public Artist Create( LibraryId? libraryId = null, string? name = null, + Optional? sortName = null, + Optional? disambiguation = null, + Optional? type = null, + Optional? gender = null, + Optional? country = null, + Optional? area = null, + Optional? beginArea = null, + Optional? endArea = null, + Optional? lifeSpanBegin = null, + Optional? lifeSpanEnd = null, + bool? isEnded = null, Optional? website = null, Optional? musicBrainzArtistId = null, + List? ipis = null, + List? isnis = null, + List? aliases = null, + List? genres = null, + List? tags = null, + List? ratings = null, List? contributors = null, List? 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 artistResult = Artist.Create( libraryId ?? _libraryIdFixture.Create(), name ?? _faker.Name.FullName(), + sortName ?? Optional.Some(_faker.Name.FullName()), + disambiguation ?? Optional.Some(_faker.Lorem.Sentence()), + type ?? Optional.Some(_faker.PickRandom()), + gender ?? Optional.Some(_faker.PickRandom()), + country ?? Optional.Some(_faker.Address.CountryCode()), + area ?? Optional.Some(_musicAreaFixture.Create()), + beginArea ?? Optional.Some(_musicAreaFixture.Create()), + endArea ?? Optional.Some(_musicAreaFixture.Create()), + lifeSpanBegin ?? Optional.Some(new DateOnly(lifeSpanBeginYear, 1, 1)), + lifeSpanEnd ?? Optional.Some(new DateOnly(lifeSpanEndYear, 1, 1)), + isEnded ?? _faker.Random.Bool(), website ?? Optional.Some(_faker.Internet.Url()), musicBrainzArtistId ?? Optional.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()]); diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/AlbumFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/AlbumFixture.cs index d161f7b0..819cde1e 100644 --- a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/AlbumFixture.cs +++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/AlbumFixture.cs @@ -32,9 +32,14 @@ public class AlbumFixture /// Creates a random valid domain entity. /// /// Optional. The album metadata of the album. + /// Optional. The disambiguation comment of the album. /// Optional. The physical or digital medium of the album. + /// Optional. The outermost physical packaging of the album. + /// Optional. The script used by the language of the release of the album. /// Optional. The barcode of the album. /// Optional. The catalog number of the album. + /// Optional. The name of the label that issued the album. + /// Optional. The ASIN of the album. /// Optional. The MusicBrainz identifier of the release. /// Optional. The MusicBrainz identifier of the release group. /// Optional. The MusicBrainz identifier of the release artist. @@ -44,9 +49,14 @@ public class AlbumFixture /// The created domain entity. public Album Create( AlbumMetadata? metadata = null, + Optional? disambiguation = null, Optional? mediaFormat = null, + Optional? packaging = null, + Optional? script = null, Optional? barcode = null, - Optional? catalogNumber = null, + List? catalogNumbers = null, + Optional? label = null, + Optional? asin = null, Optional? musicBrainzReleaseId = null, Optional? musicBrainzReleaseGroupId = null, Optional? musicBrainzReleaseArtistId = null, @@ -56,9 +66,14 @@ public class AlbumFixture { Result albumResult = Album.Create( metadata ?? _albumMetadataFixture.Create(), + disambiguation ?? Optional.Some(_faker.Lorem.Sentence()), mediaFormat ?? Optional.Some(_faker.PickRandom()), + packaging ?? Optional.Some(_faker.PickRandom()), + script ?? Optional.Some(_faker.Random.String2(4)), barcode ?? Optional.Some(_barcodeFixture.Create()), - catalogNumber ?? Optional.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.Some(_faker.Company.CompanyName()), + asin ?? Optional.Some(_faker.Random.AlphaNumeric(10)), musicBrainzReleaseId ?? Optional.Some(_musicBrainzIdFixture.Create()), musicBrainzReleaseGroupId ?? Optional.Some(_musicBrainzIdFixture.Create()), musicBrainzReleaseArtistId ?? Optional.Some(_musicBrainzIdFixture.Create()), diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/TrackFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/TrackFixture.cs index 6432d8ed..7a4920b7 100644 --- a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/TrackFixture.cs +++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/TrackFixture.cs @@ -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(); /// @@ -36,51 +37,54 @@ public class TrackFixture /// /// Optional. The file system path of the track. /// Optional. The audio metadata of the track. + /// Optional. The disambiguation comment of the track. /// Optional. The number of the track on its disc. /// Optional. The number of the disc the track belongs to. /// Optional. The moods of the track. /// Optional. The script used by the language of the track. /// Optional. The musical key of the track. /// Optional. The tempo of the track in beats per minute. + /// Optional. Whether the recording of the track is a video recording. /// Optional. The ISRCs of the track. - /// Optional. The title of the work the track is a recording of. + /// Optional. The work the track is a recording of. /// Optional. The MusicBrainz identifier of the recording. /// Optional. The MusicBrainz identifier of the track. - /// Optional. The MusicBrainz identifier of the work. /// Optional. The media contributors of the track. /// Optional. The ratings of the track. /// The created domain entity. public Track Create( string? path = null, AudioMetadata? metadata = null, + Optional? disambiguation = null, int? trackNumber = null, Optional? discNumber = null, List? moods = null, Optional? script = null, Optional? key = null, Optional? bpm = null, + bool? isVideo = null, List? isrcs = null, - Optional? work = null, + Optional? work = null, Optional? musicBrainzRecordingId = null, Optional? musicBrainzTrackId = null, - Optional? musicBrainzWorkId = null, List? contributors = null, List? ratings = null) { Result trackResult = Track.Create( path ?? _faker.System.FilePath(), metadata ?? _audioMetadataFixture.Create(), + disambiguation ?? Optional.None(), trackNumber ?? _faker.Random.Int(1, 30), discNumber ?? Optional.Some(_faker.Random.Int(1, 2)), moods ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(_ => _moodFixture.Create())], script ?? Optional.Some(_faker.Lorem.Word()), key ?? Optional.Some(_faker.PickRandom()), bpm ?? Optional.Some(_faker.Random.Int(60, 220)), + isVideo ?? _faker.Random.Bool(), isrcs ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _isrcFixture.Create())], - work ?? Optional.Some(_faker.Lorem.Sentence()), + work ?? Optional.Some(_musicWorkFixture.Create()), musicBrainzRecordingId ?? Optional.Some(_musicBrainzIdFixture.Create()), musicBrainzTrackId ?? Optional.Some(_musicBrainzIdFixture.Create()), - musicBrainzWorkId ?? Optional.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())]); diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ValueObjects/AlbumMetadataFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ValueObjects/AlbumMetadataFixture.cs index b3776200..5a5d8606 100644 --- a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ValueObjects/AlbumMetadataFixture.cs +++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ValueObjects/AlbumMetadataFixture.cs @@ -30,13 +30,14 @@ public class AlbumMetadataFixture /// /// Optional. The title of the album. /// Optional. The original title of the album. + /// Optional. The title of the specific release (edition) of the album. /// Optional. The description of the album. /// Optional. The release information of the album. /// Optional. The genres of the album. /// Optional. The tags associated with the album. /// Optional. The language of the album. /// Optional. The original language of the album. - /// Optional. The type of the release. + /// Optional. The types of the release. /// Optional. The status of the release. /// Optional. The number of discs of the release. /// Optional. The number of tracks of the release. @@ -44,13 +45,14 @@ public class AlbumMetadataFixture public AlbumMetadata Create( string? title = null, Optional? originalTitle = null, + Optional? releaseTitle = null, Optional? description = null, ReleaseInfo? releaseInfo = null, List? genres = null, List? tags = null, Optional? language = null, Optional? originalLanguage = null, - Optional? releaseType = null, + List? releaseTypes = null, Optional? releaseStatus = null, Optional? totalDiscs = null, int? totalTracks = null) @@ -58,13 +60,14 @@ public class AlbumMetadataFixture Result metadataResult = AlbumMetadata.Create( title ?? _faker.Commerce.ProductName(), originalTitle ?? Optional.None(), + releaseTitle ?? Optional.Some(_faker.Commerce.ProductName()), description ?? Optional.Some(_faker.Lorem.Sentence()), releaseInfo ?? _releaseInfoFixture.Create(), genres ?? [_genreFixture.Create(), _genreFixture.Create()], tags ?? [_tagFixture.Create(), _tagFixture.Create()], language ?? Optional.Some(_languageInfoFixture.Create()), originalLanguage ?? Optional.None(), - releaseType ?? Optional.Some(_faker.PickRandom()), + releaseTypes ?? [_faker.PickRandom()], releaseStatus ?? Optional.Some(_faker.PickRandom()), totalDiscs ?? Optional.Some(_faker.Random.Int(1, 4)), totalTracks ?? _faker.Random.Int(1, 50)); diff --git a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/Common/ValueObjects/AudioMetadataTests.cs b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/Common/ValueObjects/AudioMetadataTests.cs index 9dc21ced..94947845 100644 --- a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/Common/ValueObjects/AudioMetadataTests.cs +++ b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/Common/ValueObjects/AudioMetadataTests.cs @@ -41,7 +41,12 @@ public class AudioMetadataTests Optional.None(), Optional.Some(16), Optional.Some("PCM"), - Optional.Some(1411)); + Optional.Some(1411), + Optional.Some("f0e9c1a2-0000-0000-0000-000000000000"), + Optional.Some(-6.53m), + Optional.Some(0.988m), + Optional.Some(-7.01m), + Optional.Some(1.001m)); // Assert Assert.False(result.IsFailure); @@ -75,7 +80,12 @@ public class AudioMetadataTests Optional.None(), Optional.None(), Optional.None(), - Optional.None()); + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None()); // Assert Assert.False(result.IsFailure); @@ -190,7 +200,12 @@ public class AudioMetadataTests Optional.Some(originalLanguage), Optional.Some(16), Optional.Some("PCM"), - Optional.Some(1411)); + Optional.Some(1411), + Optional.Some("f0e9c1a2-0000-0000-0000-000000000000"), + Optional.Some(-6.53m), + Optional.Some(0.988m), + Optional.Some(-7.01m), + Optional.Some(1.001m)); // Assert Assert.False(result.IsFailure); @@ -222,7 +237,12 @@ public class AudioMetadataTests Optional.None(), Optional.None(), Optional.None(), - Optional.None()); + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None()); // Assert Assert.False(result.IsFailure); diff --git a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ArtistTests.cs b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ArtistTests.cs index 82eefad2..bb4608fd 100644 --- a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ArtistTests.cs +++ b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ArtistTests.cs @@ -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 result = Artist.Create( libraryId, "Queen", + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + false, Optional.Some("https://www.queenonline.com"), Optional.Some(musicBrainzArtistId), + [], + [], + [], + [], + [], + [], contributors, [album]); @@ -141,8 +159,25 @@ public class ArtistTests libraryId, "Queen", Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + false, + Optional.None(), Optional.None(), [], + [], + [], + [], + [], + [], + [], [album]); // Assert @@ -165,8 +200,25 @@ public class ArtistTests _libraryIdFixture.Create(), name!, Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + false, + Optional.None(), Optional.None(), [], + [], + [], + [], + [], + [], + [], [_albumFixture.Create()]); // Assert @@ -182,8 +234,25 @@ public class ArtistTests _libraryIdFixture.Create(), "Queen", Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + false, + Optional.None(), Optional.None(), [], + [], + [], + [], + [], + [], + [], []); // Assert @@ -206,9 +275,26 @@ public class ArtistTests artistId, libraryId, "Queen", + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + false, Optional.Some("https://www.queenonline.com"), Optional.None(), [], + [], + [], + [], + [], + [], + [], [album], createdOnUtc, Optional.Some(updatedOnUtc)); @@ -236,8 +322,25 @@ public class ArtistTests _libraryIdFixture.Create(), name!, Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + false, + Optional.None(), Optional.None(), [], + [], + [], + [], + [], + [], + [], [_albumFixture.Create()], DateTime.UtcNow, Optional.None()); @@ -256,9 +359,26 @@ public class ArtistTests _libraryIdFixture.Create(), "Queen", Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + false, + Optional.None(), Optional.None(), [], [], + [], + [], + [], + [], + [], + [], DateTime.UtcNow, Optional.None()); @@ -394,6 +514,17 @@ public class ArtistTests // Act Result result = artist.UpdateDetails( "Queen", + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + false, Optional.Some("https://www.queenonline.com"), Optional.Some(musicBrainzArtistId)); @@ -415,7 +546,21 @@ public class ArtistTests Optional originalUpdatedOnUtc = artist.UpdatedOnUtc; // Act - Result result = artist.UpdateDetails(" ", Optional.None(), Optional.None()); + Result result = artist.UpdateDetails( + " ", + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + Optional.None(), + false, + Optional.None(), + Optional.None()); // Assert Assert.True(result.IsFailure); @@ -433,7 +578,7 @@ public class ArtistTests AlbumMetadata metadata = _albumMetadataFixture.Create(title: "A Night at the Opera"); Optional mediaFormat = Optional.Some(MusicMediaFormat.CD); Optional barcode = Optional.Some(_barcodeFixture.Create()); - Optional catalogNumber = Optional.Some("CAT-123456"); + List catalogNumbers = ["CAT-123456"]; Optional releaseId = Optional.Some(_musicBrainzIdFixture.Create()); Optional releaseGroupId = Optional.Some(_musicBrainzIdFixture.Create()); Optional releaseArtistId = Optional.Some(_musicBrainzIdFixture.Create()); @@ -445,9 +590,14 @@ public class ArtistTests Result result = artist.UpdateAlbum( album, metadata, + Optional.None(), mediaFormat, + Optional.None(), + Optional.None(), barcode, - catalogNumber, + catalogNumbers, + Optional.None(), + Optional.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 result = artist.UpdateAlbum( foreignAlbum, _albumMetadataFixture.Create(), + Optional.None(), Optional.None(), + Optional.None(), + Optional.None(), Optional.None(), + [], + Optional.None(), Optional.None(), Optional.None(), Optional.None(), @@ -512,10 +667,9 @@ public class ArtistTests Optional script = Optional.Some("Latin"); Optional key = Optional.Some(MusicKey.BMajor); Optional bpm = Optional.Some(72); - Optional work = Optional.Some("Bohemian Rhapsody"); + Optional work = Optional.Some(_musicWorkFixture.Create(title: "Bohemian Rhapsody")); Optional recordingId = Optional.Some(_musicBrainzIdFixture.Create()); Optional musicBrainzTrackId = Optional.Some(_musicBrainzIdFixture.Create()); - Optional workId = Optional.Some(_musicBrainzIdFixture.Create()); List moods = [_moodFixture.Create(name: "epic")]; List isrcs = [_isrcFixture.Create(value: "GBUM71029604")]; List 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.None(), Optional.None(), Optional.None(), - Optional.None(), - Optional.None(), + false, + Optional.None(), Optional.None(), Optional.None(), [], @@ -622,8 +776,8 @@ public class ArtistTests Optional.None(), Optional.None(), Optional.None(), - Optional.None(), - Optional.None(), + false, + Optional.None(), Optional.None(), Optional.None(), [], diff --git a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/AlbumTests.cs b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/AlbumTests.cs index 0c563880..8f27b8dc 100644 --- a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/AlbumTests.cs +++ b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/AlbumTests.cs @@ -71,7 +71,7 @@ public class AlbumTests AlbumMetadata metadata = _albumMetadataFixture.Create(title: "A Night at the Opera"); Optional mediaFormat = Optional.Some(MusicMediaFormat.Vinyl); Optional barcode = Optional.Some(_barcodeFixture.Create()); - Optional catalogNumber = Optional.Some("CAT-001"); + List catalogNumbers = ["CAT-001"]; Optional releaseId = Optional.Some(_musicBrainzIdFixture.Create()); Optional releaseGroupId = Optional.Some(_musicBrainzIdFixture.Create()); Optional releaseArtistId = Optional.Some(_musicBrainzIdFixture.Create()); @@ -83,9 +83,14 @@ public class AlbumTests // Act Result result = Album.Create( metadata, + Optional.None(), mediaFormat, + Optional.Some(MusicReleasePackaging.Digipak), + Optional.None(), barcode, - catalogNumber, + catalogNumbers, + Optional.Some("Label"), + Optional.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 result = Album.Create( _albumMetadataFixture.Create(), + Optional.None(), Optional.None(), + Optional.None(), + Optional.None(), Optional.None(), + [], + Optional.None(), Optional.None(), Optional.None(), Optional.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 result = Album.Create( _albumMetadataFixture.Create(), + Optional.None(), Optional.None(), + Optional.None(), + Optional.None(), Optional.None(), + [], + Optional.None(), Optional.None(), Optional.None(), Optional.None(), @@ -174,9 +189,14 @@ public class AlbumTests Result result = Album.Create( albumId, metadata, + Optional.None(), Optional.Some(MusicMediaFormat.CD), + Optional.None(), + Optional.None(), Optional.Some(_barcodeFixture.Create()), - Optional.Some("CAT-002"), + ["CAT-002"], + Optional.None(), + Optional.None(), Optional.None(), Optional.None(), Optional.None(), @@ -299,7 +319,7 @@ public class AlbumTests AlbumMetadata metadata = _albumMetadataFixture.Create(title: "A Day at the Races"); Optional mediaFormat = Optional.Some(MusicMediaFormat.Cassette); Optional barcode = Optional.Some(_barcodeFixture.Create()); - Optional catalogNumber = Optional.Some("CAT-003"); + List catalogNumbers = ["CAT-003"]; Optional releaseId = Optional.Some(_musicBrainzIdFixture.Create()); Optional releaseGroupId = Optional.Some(_musicBrainzIdFixture.Create()); Optional releaseArtistId = Optional.Some(_musicBrainzIdFixture.Create()); @@ -308,9 +328,14 @@ public class AlbumTests // Act Result result = album.UpdateDetails( metadata, + Optional.None(), mediaFormat, + Optional.None(), + Optional.None(), barcode, - catalogNumber, + catalogNumbers, + Optional.None(), + Optional.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 result = album.UpdateDetails( _albumMetadataFixture.Create(), + Optional.None(), Optional.None(), + Optional.None(), + Optional.None(), Optional.None(), + [], + Optional.None(), Optional.None(), Optional.None(), Optional.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); diff --git a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/TrackTests.cs b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/TrackTests.cs index 382cc58f..86fec38c 100644 --- a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/TrackTests.cs +++ b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/TrackTests.cs @@ -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 script = Optional.Some("Latin"); Optional key = Optional.Some(MusicKey.DMajor); Optional bpm = Optional.Some(128); - Optional work = Optional.Some("Symphony No. 5"); + bool isVideo = true; + Optional work = Optional.Some(_musicWorkFixture.Create(title: "Symphony No. 5")); Optional recordingId = Optional.Some(_musicBrainzIdFixture.Create()); Optional trackId = Optional.Some(_musicBrainzIdFixture.Create()); - Optional workId = Optional.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.None(), bpm: Optional.None(), isrcs: [], - work: Optional.None(), + work: Optional.None(), musicBrainzRecordingId: Optional.None(), musicBrainzTrackId: Optional.None(), - musicBrainzWorkId: Optional.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.None(), Optional.None(), Optional.None(), - Optional.None(), - Optional.None(), + false, + Optional.None(), Optional.None(), Optional.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); } } diff --git a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ValueObjects/AlbumMetadataTests.cs b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ValueObjects/AlbumMetadataTests.cs index a66b8e58..0eb101cf 100644 --- a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ValueObjects/AlbumMetadataTests.cs +++ b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ValueObjects/AlbumMetadataTests.cs @@ -37,13 +37,14 @@ public class AlbumMetadataTests Result result = AlbumMetadata.Create( "A Night at the Opera", Optional.Some("A Night at the Opera (original)"), + Optional.Some("A Night at the Opera (2011 remaster)"), Optional.Some("The fourth studio album by the British rock band Queen."), releaseInfo, [genre], [tag], Optional.Some(language), Optional.Some(originalLanguage), - Optional.Some(MusicReleaseType.Album), + [MusicReleaseType.Album], Optional.Some(MusicReleaseStatus.Official), Optional.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.Some("A Night at the Opera (original)"), metadata.OriginalTitle); + Assert.Equal(Optional.Some("A Night at the Opera (2011 remaster)"), metadata.ReleaseTitle); Assert.Equal(Optional.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.Some(language), metadata.Language); Assert.Equal(Optional.Some(originalLanguage), metadata.OriginalLanguage); - Assert.Equal(Optional.Some(MusicReleaseType.Album), metadata.ReleaseType); + Assert.Equal(new[] { MusicReleaseType.Album }, metadata.ReleaseTypes); Assert.Equal(Optional.Some(MusicReleaseStatus.Official), metadata.ReleaseStatus); Assert.Equal(Optional.Some(2), metadata.TotalDiscs); Assert.Equal(12, metadata.TotalTracks); @@ -73,12 +75,13 @@ public class AlbumMetadataTests "A Night at the Opera", Optional.None(), Optional.None(), + Optional.None(), _releaseInfoFixture.Create(), [], [], Optional.None(), Optional.None(), - Optional.None(), + [], Optional.None(), Optional.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.None(), Optional.None(), + Optional.None(), _releaseInfoFixture.Create(), expectedGenres, expectedTags, Optional.None(), Optional.None(), - Optional.None(), + [], Optional.None(), Optional.None(), 12); @@ -139,26 +144,28 @@ public class AlbumMetadataTests AlbumMetadata firstMetadata = _albumMetadataFixture.Create( title: "A Night at the Opera", originalTitle: Optional.None(), + releaseTitle: Optional.Some("A Night at the Opera (2011 remaster)"), description: Optional.None(), releaseInfo: releaseInfo, genres: [_genreFixture.Create(name: "Rock")], tags: [_tagFixture.Create(name: "classic")], language: Optional.None(), originalLanguage: Optional.None(), - releaseType: Optional.Some(MusicReleaseType.Album), + releaseTypes: [MusicReleaseType.Album], releaseStatus: Optional.Some(MusicReleaseStatus.Official), totalDiscs: Optional.Some(2), totalTracks: 12); AlbumMetadata secondMetadata = _albumMetadataFixture.Create( title: "A Night at the Opera", originalTitle: Optional.None(), + releaseTitle: Optional.Some("A Night at the Opera (2011 remaster)"), description: Optional.None(), releaseInfo: releaseInfo, genres: [_genreFixture.Create(name: "Rock")], tags: [_tagFixture.Create(name: "classic")], language: Optional.None(), originalLanguage: Optional.None(), - releaseType: Optional.Some(MusicReleaseType.Album), + releaseTypes: [MusicReleaseType.Album], releaseStatus: Optional.Some(MusicReleaseStatus.Official), totalDiscs: Optional.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.Some(MusicReleaseType.Album)); + releaseTypes: [MusicReleaseType.Album]); AlbumMetadata secondMetadata = _albumMetadataFixture.Create( title: "A Night at the Opera", releaseInfo: releaseInfo, - releaseType: Optional.Some(MusicReleaseType.Single)); + releaseTypes: [MusicReleaseType.Single]); // Assert Assert.NotEqual(firstMetadata, secondMetadata);