From 1fad9316ce6e692a2ba3d90f66a43deed8f3a5c0 Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Fri, 9 Oct 2026 07:34:00 +0300 Subject: [PATCH] Adds the music library commands and their validators --- .../Commands/AddAlbum/AddAlbumCommand.cs | 13 +- .../AddAlbum/AddAlbumCommandValidator.cs | 42 ++-- .../UpdateAlbum/UpdateAlbumCommand.cs | 12 +- .../UpdateAlbumCommandValidator.cs | 21 +- .../Commands/AddArtist/AddArtistCommand.cs | 14 +- .../AddArtist/AddArtistCommandValidator.cs | 189 +++++++++++++++-- .../UpdateArtist/UpdateArtistCommand.cs | 14 +- .../UpdateArtistCommandValidator.cs | 193 ++++++++++++++++-- .../Commands/AddTrack/AddTrackCommand.cs | 9 +- .../AddTrack/AddTrackCommandValidator.cs | 20 +- .../UpdateTrack/UpdateTrackCommand.cs | 8 +- .../UpdateTrackCommandValidator.cs | 20 +- .../AddAlbum/AddAlbumCommandFixture.cs | 29 ++- .../UpdateAlbum/UpdateAlbumCommandFixture.cs | 29 ++- .../AddArtist/AddArtistCommandFixture.cs | 31 ++- .../UpdateArtistCommandFixture.cs | 31 ++- .../AddTrack/AddTrackCommandFixture.cs | 18 +- .../UpdateTrack/UpdateTrackCommandFixture.cs | 18 +- .../AddAlbum/AddAlbumCommandHandlerTests.cs | 2 +- .../AddAlbum/AddAlbumCommandValidatorTests.cs | 47 ++--- .../UpdateAlbumCommandHandlerTests.cs | 2 +- .../UpdateAlbumCommandValidatorTests.cs | 20 +- .../AddArtist/AddArtistCommandHandlerTests.cs | 6 +- .../AddArtistCommandValidatorTests.cs | 54 ++--- .../UpdateArtistCommandHandlerTests.cs | 6 +- .../UpdateArtistCommandValidatorTests.cs | 54 ++--- .../GetArtist/GetArtistQueryHandlerTests.cs | 2 +- .../AddTrack/AddTrackCommandHandlerTests.cs | 2 +- .../AddTrack/AddTrackCommandValidatorTests.cs | 23 ++- .../UpdateTrackCommandValidatorTests.cs | 27 +-- 30 files changed, 700 insertions(+), 256 deletions(-) diff --git a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommand.cs b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommand.cs index 8a0a0f38..bef552ec 100644 --- a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommand.cs +++ b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommand.cs @@ -19,22 +19,29 @@ namespace Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums. /// The Id of the artist the album belongs to, taken from the route. /// The album metadata of the album. /// The physical or digital medium of the album, if applicable. +/// The outermost physical packaging of the album, if applicable. /// The barcode of the album, if applicable. -/// The catalog number of the album, if applicable. +/// The catalog numbers of the album, if applicable. +/// The name of the label that issued the album, if applicable. +/// The ASIN (Amazon Standard Identification Number) of the album, if applicable. /// The MusicBrainz identifier of the release, if applicable. /// The MusicBrainz identifier of the release group, if applicable. /// The MusicBrainz identifier of the release artist, if applicable. /// The list of media contributors that performed on the album. /// The list of ratings for this album. /// The list of tracks of the album. +/// The Id of the album, when the album already exists. [DebuggerDisplay("Title: {Metadata.Title}")] public record AddAlbumCommand( string? LibraryId, string? ArtistId, - AlbumMetadataDto? Metadata, + MusicAlbumMetadataDto? Metadata, MusicMediaFormat? MediaFormat, + MusicReleasePackaging? Packaging, string? Barcode, - string? CatalogNumber, + List? CatalogNumbers, + string? Label, + string? ASIN, Guid? MusicBrainzReleaseId, Guid? MusicBrainzReleaseGroupId, Guid? MusicBrainzReleaseArtistId, diff --git a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommandValidator.cs index 9dc0f385..7f8a4636 100644 --- a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommandValidator.cs +++ b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommandValidator.cs @@ -3,6 +3,7 @@ using Lumina.Application.Common.Infrastructure.Validation; using Lumina.Application.Common.Utilities; using Lumina.Domain.Common.Errors; using System; +using System.Linq; #endregion namespace Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.AddAlbum; @@ -37,7 +38,7 @@ public class AddAlbumCommandValidator : AbstractValidator .When(command => command.ArtistId is not null && command.ArtistId.Length > 0) .WithError(Errors.Music.ArtistIdCannotBeEmpty); - // Validates the metadata of the album: title, lengths, release type and status, disc and track counts, release information, languages, genres and tags. + // Validates the metadata of the album: title, lengths, release types and status, disc and track counts, release information, languages, genres and tags. RuleFor(command => command.Metadata) .NotNull() .WithError(Errors.Metadata.MetadataCannotBeNull) @@ -60,9 +61,13 @@ public class AddAlbumCommandValidator : AbstractValidator .When(m => m!.Description is not null) .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); - metadata.RuleFor(m => m!.ReleaseType) + metadata.RuleFor(m => m!.Disambiguation) + .MaximumLength(255) + .When(m => m!.Disambiguation is not null) + .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); + + metadata.RuleForEach(m => m!.ReleaseTypes) .IsInEnum() - .When(m => m!.ReleaseType is not null) .WithError(Errors.Music.UnknownMusicReleaseType); metadata.RuleFor(m => m!.ReleaseStatus) @@ -196,15 +201,20 @@ public class AddAlbumCommandValidator : AbstractValidator .When(m => m!.OriginalLanguage is not null); }); - // Validates the physical characteristics of the album: format and catalog number. + // Validates the physical characteristics of the album: format, packaging, catalog number and barcode. RuleFor(command => command.MediaFormat) .IsInEnum() .When(command => command.MediaFormat is not null) .WithError(Errors.Music.UnknownMusicMediaFormat); - RuleFor(command => command.CatalogNumber) + RuleFor(command => command.Packaging) + .IsInEnum() + .When(command => command.Packaging is not null) + .WithError(Errors.Music.UnknownMusicReleasePackaging); + + RuleForEach(command => command.CatalogNumbers) .MaximumLength(50) - .When(command => command.CatalogNumber is not null) + .When(command => command.CatalogNumbers is not null) .WithError(Errors.Music.CatalogNumberMustBeMaximum50CharactersLong); RuleFor(command => command.Barcode) @@ -313,6 +323,11 @@ public class AddAlbumCommandValidator : AbstractValidator .When(m => m!.Description is not null) .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); + trackMetadata.RuleFor(m => m!.Disambiguation) + .MaximumLength(255) + .When(m => m!.Disambiguation is not null) + .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); + trackMetadata.RuleFor(m => m!.ReleaseInfo) .NotNull() .WithError(Errors.Metadata.ReleaseInfoCannotBeNull) @@ -440,11 +455,6 @@ public class AddAlbumCommandValidator : AbstractValidator .When(t => t!.MusicBrainzTrackId.HasValue) .WithError(Errors.Music.MusicBrainzIdInvalidFormat); - track.RuleFor(t => t!.MusicBrainzWorkId) - .Must(musicBrainzWorkId => musicBrainzWorkId != Guid.Empty) - .When(t => t!.MusicBrainzWorkId.HasValue) - .WithError(Errors.Music.MusicBrainzIdInvalidFormat); - // Validates the ordering and performance characteristics of the track. track.RuleFor(t => t!.TrackNumber) .NotNull() @@ -475,11 +485,17 @@ public class AddAlbumCommandValidator : AbstractValidator .When(t => t!.Bpm.HasValue) .WithError(Errors.Music.BpmMustBeGreaterThanZero); - track.RuleFor(t => t!.Work) + // Validates the work the track is a recording of. + track.RuleFor(t => t!.Work!.Title) .MaximumLength(255) - .When(t => t!.Work is not null) + .When(t => t!.Work is not null && t.Work.Title is not null) .WithError(Errors.Music.WorkMustBeMaximum255CharactersLong); + track.RuleFor(t => t!.Work!.MusicBrainzWorkId) + .Must(musicBrainzWorkId => musicBrainzWorkId is null || musicBrainzWorkId != Guid.Empty) + .When(t => t!.Work is not null) + .WithError(Errors.Music.MusicBrainzIdInvalidFormat); + // Validates the media contributors that performed on the track. track.RuleFor(t => t!.Contributors) .NotNull() diff --git a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommand.cs b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommand.cs index d31323ff..515bc6ca 100644 --- a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommand.cs +++ b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommand.cs @@ -19,8 +19,11 @@ namespace Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums. /// The unique identifier of the album, taken from the route. /// The album metadata of the album. /// The physical or digital medium of the album, if applicable. +/// The outermost physical packaging of the album, if applicable. /// The barcode of the album, if applicable. -/// The catalog number of the album, if applicable. +/// The catalog numbers of the album, if applicable. +/// The name of the label that issued the album, if applicable. +/// The ASIN (Amazon Standard Identification Number) of the album, if applicable. /// The MusicBrainz identifier of the release, if applicable. /// The MusicBrainz identifier of the release group, if applicable. /// The MusicBrainz identifier of the release artist, if applicable. @@ -31,10 +34,13 @@ public record UpdateAlbumCommand( string? LibraryId, string? ArtistId, string? AlbumId, - AlbumMetadataDto? Metadata, + MusicAlbumMetadataDto? Metadata, MusicMediaFormat? MediaFormat, + MusicReleasePackaging? Packaging, string? Barcode, - string? CatalogNumber, + List? CatalogNumbers, + string? Label, + string? ASIN, Guid? MusicBrainzReleaseId, Guid? MusicBrainzReleaseGroupId, Guid? MusicBrainzReleaseArtistId, diff --git a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommandValidator.cs index 48fa09ff..2247cdc7 100644 --- a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommandValidator.cs +++ b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommandValidator.cs @@ -47,7 +47,7 @@ public class UpdateAlbumCommandValidator : AbstractValidator .When(command => command.AlbumId is not null && command.AlbumId.Length > 0) .WithError(Errors.Music.AlbumIdCannotBeEmpty); - // Validates the metadata of the album: title, lengths, release type and status, disc and track counts, release information, languages, genres and tags. + // Validates the metadata of the album: title, lengths, release types and status, disc and track counts, release information, languages, genres and tags. RuleFor(command => command.Metadata) .NotNull() .WithError(Errors.Metadata.MetadataCannotBeNull) @@ -70,9 +70,13 @@ public class UpdateAlbumCommandValidator : AbstractValidator .When(m => m!.Description is not null) .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); - metadata.RuleFor(m => m!.ReleaseType) + metadata.RuleFor(m => m!.Disambiguation) + .MaximumLength(255) + .When(m => m!.Disambiguation is not null) + .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); + + metadata.RuleForEach(m => m!.ReleaseTypes) .IsInEnum() - .When(m => m!.ReleaseType is not null) .WithError(Errors.Music.UnknownMusicReleaseType); metadata.RuleFor(m => m!.ReleaseStatus) @@ -206,15 +210,20 @@ public class UpdateAlbumCommandValidator : AbstractValidator .When(m => m!.OriginalLanguage is not null); }); - // Validates the physical characteristics of the album: format and catalog number. + // Validates the physical characteristics of the album: format, packaging, catalog number and barcode. RuleFor(command => command.MediaFormat) .IsInEnum() .When(command => command.MediaFormat is not null) .WithError(Errors.Music.UnknownMusicMediaFormat); - RuleFor(command => command.CatalogNumber) + RuleFor(command => command.Packaging) + .IsInEnum() + .When(command => command.Packaging is not null) + .WithError(Errors.Music.UnknownMusicReleasePackaging); + + RuleForEach(command => command.CatalogNumbers) .MaximumLength(50) - .When(command => command.CatalogNumber is not null) + .When(command => command.CatalogNumbers is not null) .WithError(Errors.Music.CatalogNumberMustBeMaximum50CharactersLong); RuleFor(command => command.Barcode) diff --git a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommand.cs b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommand.cs index 7fb265bd..f592e656 100644 --- a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommand.cs +++ b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommand.cs @@ -2,6 +2,8 @@ using Lumina.Application.Common.CQRS; using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.AddAlbum; using Lumina.Contracts.DTO.MediaContributors; +using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary; +using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary; using System; using System.Collections.Generic; using System.Diagnostics; @@ -13,17 +15,23 @@ namespace Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists /// Command for adding an artist, together with the albums of the artist and the tracks of those albums. /// /// The unique identifier of the media library this artist belongs to, taken from the route. -/// The name of the artist. +/// The metadata of the artist. /// The website of the artist, if applicable. /// The MusicBrainz identifier of the artist, if applicable. +/// The list of IPI codes of the artist. +/// The list of ISNI codes of the artist. /// The list of media contributors that make up the artist. +/// The list of ratings for the artist. /// The list of albums of the artist, each with its own list of tracks. -[DebuggerDisplay("Name: {Name}")] +[DebuggerDisplay("Name: {Metadata.Name}")] public record AddArtistCommand( string? LibraryId, - string? Name, + MusicArtistMetadataDto? Metadata, string? Website, Guid? MusicBrainzArtistId, + List? Ipis, + List? Isnis, List? Contributors, + List? Ratings, List? Albums ) : ICommand; diff --git a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommandValidator.cs index 4337ed35..41d69942 100644 --- a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommandValidator.cs +++ b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommandValidator.cs @@ -28,13 +28,115 @@ public class AddArtistCommandValidator : AbstractValidator .WithError(Errors.Library.LibraryIdCannotBeEmpty); // Validates the identifying details of the artist. - RuleFor(command => command.Name) + RuleFor(command => command.Metadata) .NotNull() - .NotEmpty() - .WithError(Errors.Music.ArtistNameCannotBeEmpty) - .MaximumLength(255) - .WithError(Errors.Music.ArtistNameMustBeMaximum255CharactersLong); + .WithError(Errors.Metadata.MetadataCannotBeNull) + .ChildRules(metadata => + { + metadata.RuleFor(m => m!.Name) + .NotNull() + .NotEmpty() + .WithError(Errors.Music.ArtistNameCannotBeEmpty) + .MaximumLength(255) + .WithError(Errors.Music.ArtistNameMustBeMaximum255CharactersLong); + metadata.RuleFor(m => m!.SortName) + .MaximumLength(255) + .When(m => m!.SortName is not null) + .WithError(Errors.Music.ArtistNameMustBeMaximum255CharactersLong); + + metadata.RuleFor(m => m!.Disambiguation) + .MaximumLength(255) + .When(m => m!.Disambiguation is not null) + .WithError(Errors.Music.ArtistNameMustBeMaximum255CharactersLong); + + metadata.RuleFor(m => m!.Type) + .IsInEnum() + .When(m => m!.Type is not null) + .WithError(Errors.Music.UnknownMusicArtistType); + + metadata.RuleFor(m => m!.Gender) + .IsInEnum() + .When(m => m!.Gender is not null) + .WithError(Errors.Music.UnknownMusicArtistGender); + + metadata.RuleFor(m => m!.Country) + .Length(2) + .When(m => m!.Country is not null) + .WithError(Errors.Music.CountryMustBeMaximum2CharactersLong); + + metadata.RuleFor(m => m!.Area!.Name) + .NotEmpty() + .WithError(Errors.Music.AreaNameCannotBeEmpty) + .MaximumLength(255) + .WithError(Errors.Music.AreaNameMustBeMaximum255CharactersLong) + .When(m => m!.Area is not null); + + metadata.RuleFor(m => m!.BeginArea!.Name) + .NotEmpty() + .WithError(Errors.Music.AreaNameCannotBeEmpty) + .MaximumLength(255) + .WithError(Errors.Music.AreaNameMustBeMaximum255CharactersLong) + .When(m => m!.BeginArea is not null); + + metadata.RuleFor(m => m!.EndArea!.Name) + .NotEmpty() + .WithError(Errors.Music.AreaNameCannotBeEmpty) + .MaximumLength(255) + .WithError(Errors.Music.AreaNameMustBeMaximum255CharactersLong) + .When(m => m!.EndArea is not null); + + metadata.RuleForEach(m => m!.Aliases) + .ChildRules(alias => + { + alias.RuleFor(a => a.Name) + .NotEmpty() + .WithError(Errors.Music.ArtistAliasNameCannotBeEmpty) + .MaximumLength(255) + .WithError(Errors.Music.ArtistAliasNameMustBeMaximum255CharactersLong); + + alias.RuleFor(a => a.SortName) + .MaximumLength(255) + .When(a => a.SortName is not null) + .WithError(Errors.Music.ArtistAliasNameMustBeMaximum255CharactersLong); + + alias.RuleFor(a => a.Type) + .MaximumLength(50) + .When(a => a.Type is not null) + .WithError(Errors.Music.ScriptMustBeMaximum50CharactersLong); + + alias.RuleFor(a => a.Locale) + .MaximumLength(20) + .When(a => a.Locale is not null) + .WithError(Errors.Music.ScriptMustBeMaximum50CharactersLong); + }); + + metadata.RuleFor(m => m!.Genres) + .NotNull() + .WithError(Errors.Metadata.GenresListCannotBeNull); + + metadata.RuleForEach(m => m!.Genres) + .ChildRules(genre => + genre.RuleFor(g => g.Name) + .NotEmpty() + .WithError(Errors.Metadata.GenreNameCannotBeEmpty) + .MaximumLength(50) + .WithError(Errors.Metadata.GenreNameMustBeMaximum50CharactersLong)); + + metadata.RuleFor(m => m!.Tags) + .NotNull() + .WithError(Errors.Metadata.TagsListCannotBeNull); + + metadata.RuleForEach(m => m!.Tags) + .ChildRules(tag => + tag.RuleFor(t => t.Name) + .NotEmpty() + .WithError(Errors.Metadata.TagNameCannotBeEmpty) + .MaximumLength(50) + .WithError(Errors.Metadata.TagNameMustBeMaximum50CharactersLong)); + }); + + // Validates the website and the MusicBrainz identifiers of the artist. RuleFor(command => command.Website) .MaximumLength(2048) .When(command => command.Website is not null) @@ -45,6 +147,18 @@ public class AddArtistCommandValidator : AbstractValidator .When(command => command.MusicBrainzArtistId.HasValue) .WithError(Errors.Music.MusicBrainzIdInvalidFormat); + RuleForEach(command => command.Ipis) + .NotEmpty() + .WithError(Errors.Music.IpiValueCannotBeEmpty) + .MaximumLength(20) + .WithError(Errors.Music.IpiValueMustBeMaximum20CharactersLong); + + RuleForEach(command => command.Isnis) + .NotEmpty() + .WithError(Errors.Music.IsniValueCannotBeEmpty) + .MaximumLength(20) + .WithError(Errors.Music.IsniValueMustBeMaximum20CharactersLong); + // Validates the media contributors that make up the artist. RuleFor(command => command.Contributors) .NotNull() @@ -64,6 +178,30 @@ public class AddArtistCommandValidator : AbstractValidator .WithError(Errors.MediaContributor.UnknownMediaContributorRole); }); + // Validates the ratings of the artist. + RuleFor(command => command.Ratings) + .NotNull() + .WithError(Errors.Metadata.RatingsListCannotBeNull); + + RuleForEach(command => command.Ratings) + .ChildRules(rating => + { + rating.RuleFor(r => r.Value) + .GreaterThan(0) + .WithError(Errors.Metadata.RatingValueMustBePositive) + .Must((ratingInstance, value) => value <= ratingInstance.MaxValue) + .WithError(Errors.Metadata.RatingValueCannotBeGreaterThanMaxValue); + + rating.RuleFor(r => r.MaxValue) + .GreaterThan(0) + .WithError(Errors.Metadata.RatingMaxValueMustBePositive); + + rating.RuleFor(r => r.VoteCount) + .GreaterThanOrEqualTo(0) + .When(r => r.VoteCount.HasValue) + .WithError(Errors.Metadata.RatingVoteCountMustBePositive); + }); + // Validates each album created together with the artist, when the request carries albums. RuleFor(command => command.Albums) .NotNull() @@ -72,7 +210,7 @@ public class AddArtistCommandValidator : AbstractValidator RuleForEach(command => command.Albums) .ChildRules(album => { - // Validates the metadata of the album: title, lengths, release type and status, and disc and track counts. + // Validates the metadata of the album: title, lengths, release types and status, and disc and track counts. album.RuleFor(a => a!.Metadata) .NotNull() .WithError(Errors.Metadata.MetadataCannotBeNull) @@ -95,9 +233,13 @@ public class AddArtistCommandValidator : AbstractValidator .When(m => m!.Description is not null) .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); - metadata.RuleFor(m => m!.ReleaseType) + metadata.RuleFor(m => m!.Disambiguation) + .MaximumLength(255) + .When(m => m!.Disambiguation is not null) + .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); + + metadata.RuleForEach(m => m!.ReleaseTypes) .IsInEnum() - .When(m => m!.ReleaseType is not null) .WithError(Errors.Music.UnknownMusicReleaseType); metadata.RuleFor(m => m!.ReleaseStatus) @@ -231,15 +373,20 @@ public class AddArtistCommandValidator : AbstractValidator .When(m => m!.OriginalLanguage is not null); }); - // Validates the physical characteristics of the album: format and catalog number. + // Validates the physical characteristics of the album: format, packaging, catalog number and barcode. album.RuleFor(a => a!.MediaFormat) .IsInEnum() .When(a => a!.MediaFormat is not null) .WithError(Errors.Music.UnknownMusicMediaFormat); - album.RuleFor(a => a!.CatalogNumber) + album.RuleFor(a => a!.Packaging) + .IsInEnum() + .When(a => a!.Packaging is not null) + .WithError(Errors.Music.UnknownMusicReleasePackaging); + + album.RuleForEach(a => a!.CatalogNumbers) .MaximumLength(50) - .When(a => a!.CatalogNumber is not null) + .When(a => a!.CatalogNumbers is not null) .WithError(Errors.Music.CatalogNumberMustBeMaximum50CharactersLong); album.RuleFor(a => a!.Barcode) @@ -349,6 +496,11 @@ public class AddArtistCommandValidator : AbstractValidator .When(m => m!.Description is not null) .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); + trackMetadata.RuleFor(m => m!.Disambiguation) + .MaximumLength(255) + .When(m => m!.Disambiguation is not null) + .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); + trackMetadata.RuleFor(m => m!.ReleaseInfo) .NotNull() .WithError(Errors.Metadata.ReleaseInfoCannotBeNull) @@ -476,11 +628,6 @@ public class AddArtistCommandValidator : AbstractValidator .When(t => t!.MusicBrainzTrackId.HasValue) .WithError(Errors.Music.MusicBrainzIdInvalidFormat); - track.RuleFor(t => t!.MusicBrainzWorkId) - .Must(musicBrainzWorkId => musicBrainzWorkId != Guid.Empty) - .When(t => t!.MusicBrainzWorkId.HasValue) - .WithError(Errors.Music.MusicBrainzIdInvalidFormat); - // Validates the ordering and performance characteristics of the track. track.RuleFor(t => t!.TrackNumber) .NotNull() @@ -511,11 +658,17 @@ public class AddArtistCommandValidator : AbstractValidator .When(t => t!.Bpm.HasValue) .WithError(Errors.Music.BpmMustBeGreaterThanZero); - track.RuleFor(t => t!.Work) + // Validates the work the track is a recording of. + track.RuleFor(t => t!.Work!.Title) .MaximumLength(255) - .When(t => t!.Work is not null) + .When(t => t!.Work is not null && t.Work.Title is not null) .WithError(Errors.Music.WorkMustBeMaximum255CharactersLong); + track.RuleFor(t => t!.Work!.MusicBrainzWorkId) + .Must(musicBrainzWorkId => musicBrainzWorkId is null || musicBrainzWorkId != Guid.Empty) + .When(t => t!.Work is not null) + .WithError(Errors.Music.MusicBrainzIdInvalidFormat); + // Validates the moods and the ISRC codes of the track. track.RuleForEach(t => t!.Moods) .ChildRules(mood => diff --git a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommand.cs b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommand.cs index 12343cfb..10181464 100644 --- a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommand.cs +++ b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommand.cs @@ -2,6 +2,8 @@ using Lumina.Application.Common.CQRS; using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.AddAlbum; using Lumina.Contracts.DTO.MediaContributors; +using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary; +using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary; using System; using System.Collections.Generic; using System.Diagnostics; @@ -14,18 +16,24 @@ namespace Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists /// /// The unique identifier of the media library this artist belongs to, taken from the route. /// The unique identifier of the artist, taken from the route. -/// The name of the artist. +/// The metadata of the artist. /// The website of the artist, if applicable. /// The MusicBrainz identifier of the artist, if applicable. +/// The list of IPI codes of the artist. +/// The list of ISNI codes of the artist. /// The list of media contributors that make up the artist. +/// The list of ratings for the artist. /// The list of albums of the artist, each with its own list of tracks. -[DebuggerDisplay("Name: {Name}")] +[DebuggerDisplay("Name: {Metadata.Name}")] public record UpdateArtistCommand( string? LibraryId, string? ArtistId, - string? Name, + MusicArtistMetadataDto? Metadata, string? Website, Guid? MusicBrainzArtistId, + List? Ipis, + List? Isnis, List? Contributors, + List? Ratings, List? Albums ) : ICommand; diff --git a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommandValidator.cs index 91c44dd3..6c1d80de 100644 --- a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommandValidator.cs +++ b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommandValidator.cs @@ -17,7 +17,7 @@ public class UpdateArtistCommandValidator : AbstractValidator public UpdateArtistCommandValidator() { - // Validates the identifier of the media library that owns the artist, taken from the route. + // Validates the identifier of the media library that will own the artist, taken from the route. RuleFor(command => command.LibraryId) .NotEmpty() .WithError(Errors.Library.LibraryIdCannotBeEmpty); @@ -38,13 +38,115 @@ public class UpdateArtistCommandValidator : AbstractValidator command.Name) + RuleFor(command => command.Metadata) .NotNull() - .NotEmpty() - .WithError(Errors.Music.ArtistNameCannotBeEmpty) - .MaximumLength(255) - .WithError(Errors.Music.ArtistNameMustBeMaximum255CharactersLong); + .WithError(Errors.Metadata.MetadataCannotBeNull) + .ChildRules(metadata => + { + metadata.RuleFor(m => m!.Name) + .NotNull() + .NotEmpty() + .WithError(Errors.Music.ArtistNameCannotBeEmpty) + .MaximumLength(255) + .WithError(Errors.Music.ArtistNameMustBeMaximum255CharactersLong); + metadata.RuleFor(m => m!.SortName) + .MaximumLength(255) + .When(m => m!.SortName is not null) + .WithError(Errors.Music.ArtistNameMustBeMaximum255CharactersLong); + + metadata.RuleFor(m => m!.Disambiguation) + .MaximumLength(255) + .When(m => m!.Disambiguation is not null) + .WithError(Errors.Music.ArtistNameMustBeMaximum255CharactersLong); + + metadata.RuleFor(m => m!.Type) + .IsInEnum() + .When(m => m!.Type is not null) + .WithError(Errors.Music.UnknownMusicArtistType); + + metadata.RuleFor(m => m!.Gender) + .IsInEnum() + .When(m => m!.Gender is not null) + .WithError(Errors.Music.UnknownMusicArtistGender); + + metadata.RuleFor(m => m!.Country) + .Length(2) + .When(m => m!.Country is not null) + .WithError(Errors.Music.CountryMustBeMaximum2CharactersLong); + + metadata.RuleFor(m => m!.Area!.Name) + .NotEmpty() + .WithError(Errors.Music.AreaNameCannotBeEmpty) + .MaximumLength(255) + .WithError(Errors.Music.AreaNameMustBeMaximum255CharactersLong) + .When(m => m!.Area is not null); + + metadata.RuleFor(m => m!.BeginArea!.Name) + .NotEmpty() + .WithError(Errors.Music.AreaNameCannotBeEmpty) + .MaximumLength(255) + .WithError(Errors.Music.AreaNameMustBeMaximum255CharactersLong) + .When(m => m!.BeginArea is not null); + + metadata.RuleFor(m => m!.EndArea!.Name) + .NotEmpty() + .WithError(Errors.Music.AreaNameCannotBeEmpty) + .MaximumLength(255) + .WithError(Errors.Music.AreaNameMustBeMaximum255CharactersLong) + .When(m => m!.EndArea is not null); + + metadata.RuleForEach(m => m!.Aliases) + .ChildRules(alias => + { + alias.RuleFor(a => a.Name) + .NotEmpty() + .WithError(Errors.Music.ArtistAliasNameCannotBeEmpty) + .MaximumLength(255) + .WithError(Errors.Music.ArtistAliasNameMustBeMaximum255CharactersLong); + + alias.RuleFor(a => a.SortName) + .MaximumLength(255) + .When(a => a.SortName is not null) + .WithError(Errors.Music.ArtistAliasNameMustBeMaximum255CharactersLong); + + alias.RuleFor(a => a.Type) + .MaximumLength(50) + .When(a => a.Type is not null) + .WithError(Errors.Music.ScriptMustBeMaximum50CharactersLong); + + alias.RuleFor(a => a.Locale) + .MaximumLength(20) + .When(a => a.Locale is not null) + .WithError(Errors.Music.ScriptMustBeMaximum50CharactersLong); + }); + + metadata.RuleFor(m => m!.Genres) + .NotNull() + .WithError(Errors.Metadata.GenresListCannotBeNull); + + metadata.RuleForEach(m => m!.Genres) + .ChildRules(genre => + genre.RuleFor(g => g.Name) + .NotEmpty() + .WithError(Errors.Metadata.GenreNameCannotBeEmpty) + .MaximumLength(50) + .WithError(Errors.Metadata.GenreNameMustBeMaximum50CharactersLong)); + + metadata.RuleFor(m => m!.Tags) + .NotNull() + .WithError(Errors.Metadata.TagsListCannotBeNull); + + metadata.RuleForEach(m => m!.Tags) + .ChildRules(tag => + tag.RuleFor(t => t.Name) + .NotEmpty() + .WithError(Errors.Metadata.TagNameCannotBeEmpty) + .MaximumLength(50) + .WithError(Errors.Metadata.TagNameMustBeMaximum50CharactersLong)); + }); + + // Validates the website and the MusicBrainz identifiers of the artist. RuleFor(command => command.Website) .MaximumLength(2048) .When(command => command.Website is not null) @@ -55,6 +157,18 @@ public class UpdateArtistCommandValidator : AbstractValidator command.MusicBrainzArtistId.HasValue) .WithError(Errors.Music.MusicBrainzIdInvalidFormat); + RuleForEach(command => command.Ipis) + .NotEmpty() + .WithError(Errors.Music.IpiValueCannotBeEmpty) + .MaximumLength(20) + .WithError(Errors.Music.IpiValueMustBeMaximum20CharactersLong); + + RuleForEach(command => command.Isnis) + .NotEmpty() + .WithError(Errors.Music.IsniValueCannotBeEmpty) + .MaximumLength(20) + .WithError(Errors.Music.IsniValueMustBeMaximum20CharactersLong); + // Validates the media contributors that make up the artist. RuleFor(command => command.Contributors) .NotNull() @@ -74,7 +188,31 @@ public class UpdateArtistCommandValidator : AbstractValidator command.Ratings) + .NotNull() + .WithError(Errors.Metadata.RatingsListCannotBeNull); + + RuleForEach(command => command.Ratings) + .ChildRules(rating => + { + rating.RuleFor(r => r.Value) + .GreaterThan(0) + .WithError(Errors.Metadata.RatingValueMustBePositive) + .Must((ratingInstance, value) => value <= ratingInstance.MaxValue) + .WithError(Errors.Metadata.RatingValueCannotBeGreaterThanMaxValue); + + rating.RuleFor(r => r.MaxValue) + .GreaterThan(0) + .WithError(Errors.Metadata.RatingMaxValueMustBePositive); + + rating.RuleFor(r => r.VoteCount) + .GreaterThanOrEqualTo(0) + .When(r => r.VoteCount.HasValue) + .WithError(Errors.Metadata.RatingVoteCountMustBePositive); + }); + + // Validates each album created together with the artist, when the request carries albums. RuleFor(command => command.Albums) .NotNull() .WithError(Errors.Music.AlbumsListCannotBeNull); @@ -88,7 +226,7 @@ public class UpdateArtistCommandValidator : AbstractValidator a!.AlbumId.HasValue) .WithError(Errors.Music.AlbumIdCannotBeEmpty); - // Validates the metadata of the album: title, lengths, release type and status, and disc and track counts. + // Validates the metadata of the album: title, lengths, release types and status, and disc and track counts. album.RuleFor(a => a!.Metadata) .NotNull() .WithError(Errors.Metadata.MetadataCannotBeNull) @@ -111,9 +249,13 @@ public class UpdateArtistCommandValidator : AbstractValidator m!.Description is not null) .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); - metadata.RuleFor(m => m!.ReleaseType) + metadata.RuleFor(m => m!.Disambiguation) + .MaximumLength(255) + .When(m => m!.Disambiguation is not null) + .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); + + metadata.RuleForEach(m => m!.ReleaseTypes) .IsInEnum() - .When(m => m!.ReleaseType is not null) .WithError(Errors.Music.UnknownMusicReleaseType); metadata.RuleFor(m => m!.ReleaseStatus) @@ -247,15 +389,20 @@ public class UpdateArtistCommandValidator : AbstractValidator m!.OriginalLanguage is not null); }); - // Validates the physical characteristics of the album: format and catalog number. + // Validates the physical characteristics of the album: format, packaging, catalog number and barcode. album.RuleFor(a => a!.MediaFormat) .IsInEnum() .When(a => a!.MediaFormat is not null) .WithError(Errors.Music.UnknownMusicMediaFormat); - album.RuleFor(a => a!.CatalogNumber) + album.RuleFor(a => a!.Packaging) + .IsInEnum() + .When(a => a!.Packaging is not null) + .WithError(Errors.Music.UnknownMusicReleasePackaging); + + album.RuleForEach(a => a!.CatalogNumbers) .MaximumLength(50) - .When(a => a!.CatalogNumber is not null) + .When(a => a!.CatalogNumbers is not null) .WithError(Errors.Music.CatalogNumberMustBeMaximum50CharactersLong); album.RuleFor(a => a!.Barcode) @@ -371,6 +518,11 @@ public class UpdateArtistCommandValidator : AbstractValidator m!.Description is not null) .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); + trackMetadata.RuleFor(m => m!.Disambiguation) + .MaximumLength(255) + .When(m => m!.Disambiguation is not null) + .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); + trackMetadata.RuleFor(m => m!.ReleaseInfo) .NotNull() .WithError(Errors.Metadata.ReleaseInfoCannotBeNull) @@ -498,11 +650,6 @@ public class UpdateArtistCommandValidator : AbstractValidator t!.MusicBrainzTrackId.HasValue) .WithError(Errors.Music.MusicBrainzIdInvalidFormat); - track.RuleFor(t => t!.MusicBrainzWorkId) - .Must(musicBrainzWorkId => musicBrainzWorkId != Guid.Empty) - .When(t => t!.MusicBrainzWorkId.HasValue) - .WithError(Errors.Music.MusicBrainzIdInvalidFormat); - // Validates the ordering and performance characteristics of the track. track.RuleFor(t => t!.TrackNumber) .NotNull() @@ -533,11 +680,17 @@ public class UpdateArtistCommandValidator : AbstractValidator t!.Bpm.HasValue) .WithError(Errors.Music.BpmMustBeGreaterThanZero); - track.RuleFor(t => t!.Work) + // Validates the work the track is a recording of. + track.RuleFor(t => t!.Work!.Title) .MaximumLength(255) - .When(t => t!.Work is not null) + .When(t => t!.Work is not null && t.Work.Title is not null) .WithError(Errors.Music.WorkMustBeMaximum255CharactersLong); + track.RuleFor(t => t!.Work!.MusicBrainzWorkId) + .Must(musicBrainzWorkId => musicBrainzWorkId is null || musicBrainzWorkId != Guid.Empty) + .When(t => t!.Work is not null) + .WithError(Errors.Music.MusicBrainzIdInvalidFormat); + // Validates the moods and the ISRC codes of the track. track.RuleForEach(t => t!.Moods) .ChildRules(mood => diff --git a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommand.cs b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommand.cs index 942f87c4..515c0ae9 100644 --- a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommand.cs +++ b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommand.cs @@ -25,30 +25,29 @@ namespace Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks. /// The script used by the language of the track, if applicable. /// The musical key of the track, if applicable. /// The tempo of the track in beats per minute, if applicable. -/// The title of the work the track is a recording of, if applicable. +/// The work the track is a recording of, if applicable. /// The MusicBrainz identifier of the recording, if applicable. /// The MusicBrainz identifier of the track, if applicable. -/// The MusicBrainz identifier of the work, if applicable. /// The list of moods of the track. /// The list of ISRC of the track. /// The list of media contributors that performed on the track. /// The list of ratings for this track. +/// The Id of the track, when the track already exists. [DebuggerDisplay("Title: {Metadata.Title}")] public record AddTrackCommand( string? LibraryId, string? ArtistId, string? AlbumId, string? Path, - AudioMetadataDto? Metadata, + MusicTrackMetadataDto? Metadata, int? TrackNumber, int? DiscNumber, string? Script, MusicKey? Key, int? Bpm, - string? Work, + MusicWorkDto? Work, Guid? MusicBrainzRecordingId, Guid? MusicBrainzTrackId, - Guid? MusicBrainzWorkId, List? Moods, List? Isrcs, List? Contributors, diff --git a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommandValidator.cs index 265649e1..ed5abad7 100644 --- a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommandValidator.cs +++ b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommandValidator.cs @@ -76,6 +76,11 @@ public class AddTrackCommandValidator : AbstractValidator .When(m => m!.Description is not null) .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); + trackMetadata.RuleFor(m => m!.Disambiguation) + .MaximumLength(255) + .When(m => m!.Disambiguation is not null) + .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); + trackMetadata.RuleFor(m => m!.ReleaseInfo) .NotNull() .WithError(Errors.Metadata.ReleaseInfoCannotBeNull) @@ -203,11 +208,6 @@ public class AddTrackCommandValidator : AbstractValidator .When(command => command.MusicBrainzTrackId.HasValue) .WithError(Errors.Music.MusicBrainzIdInvalidFormat); - RuleFor(command => command.MusicBrainzWorkId) - .Must(musicBrainzWorkId => musicBrainzWorkId != Guid.Empty) - .When(command => command.MusicBrainzWorkId.HasValue) - .WithError(Errors.Music.MusicBrainzIdInvalidFormat); - // Validates the ordering and performance characteristics of the track. RuleFor(command => command.TrackNumber) .NotNull() @@ -238,11 +238,17 @@ public class AddTrackCommandValidator : AbstractValidator .When(command => command.Bpm.HasValue) .WithError(Errors.Music.BpmMustBeGreaterThanZero); - RuleFor(command => command.Work) + // Validates the work the track is a recording of. + RuleFor(command => command.Work!.Title) .MaximumLength(255) - .When(command => command.Work is not null) + .When(command => command.Work is not null && command.Work.Title is not null) .WithError(Errors.Music.WorkMustBeMaximum255CharactersLong); + RuleFor(command => command.Work!.MusicBrainzWorkId) + .Must(musicBrainzWorkId => musicBrainzWorkId is null || musicBrainzWorkId != Guid.Empty) + .When(command => command.Work is not null) + .WithError(Errors.Music.MusicBrainzIdInvalidFormat); + // Validates the moods and the ISRC codes of the track. RuleForEach(command => command.Moods) .ChildRules(mood => diff --git a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommand.cs b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommand.cs index 2f67a920..9f5c15f0 100644 --- a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommand.cs +++ b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommand.cs @@ -26,10 +26,9 @@ namespace Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks. /// The script used by the language of the track, if applicable. /// The musical key of the track, if applicable. /// The tempo of the track in beats per minute, if applicable. -/// The title of the work the track is a recording of, if applicable. +/// The work the track is a recording of, if applicable. /// The MusicBrainz identifier of the recording, if applicable. /// The MusicBrainz identifier of the track, if applicable. -/// The MusicBrainz identifier of the work, if applicable. /// The list of moods of the track. /// The list of ISRC of the track. /// The list of media contributors that performed on the track. @@ -41,16 +40,15 @@ public record UpdateTrackCommand( string? AlbumId, string? TrackId, string? Path, - AudioMetadataDto? Metadata, + MusicTrackMetadataDto? Metadata, int? TrackNumber, int? DiscNumber, string? Script, MusicKey? Key, int? Bpm, - string? Work, + MusicWorkDto? Work, Guid? MusicBrainzRecordingId, Guid? MusicBrainzTrackId, - Guid? MusicBrainzWorkId, List? Moods, List? Isrcs, List? Contributors, diff --git a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandValidator.cs index 0ebf84e5..aee75a3e 100644 --- a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandValidator.cs +++ b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandValidator.cs @@ -86,6 +86,11 @@ public class UpdateTrackCommandValidator : AbstractValidator .When(m => m!.Description is not null) .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); + trackMetadata.RuleFor(m => m!.Disambiguation) + .MaximumLength(255) + .When(m => m!.Disambiguation is not null) + .WithError(Errors.Metadata.DescriptionMustBeMaximum2000CharactersLong); + trackMetadata.RuleFor(m => m!.ReleaseInfo) .NotNull() .WithError(Errors.Metadata.ReleaseInfoCannotBeNull) @@ -213,11 +218,6 @@ public class UpdateTrackCommandValidator : AbstractValidator .When(command => command.MusicBrainzTrackId.HasValue) .WithError(Errors.Music.MusicBrainzIdInvalidFormat); - RuleFor(command => command.MusicBrainzWorkId) - .Must(musicBrainzWorkId => musicBrainzWorkId != Guid.Empty) - .When(command => command.MusicBrainzWorkId.HasValue) - .WithError(Errors.Music.MusicBrainzIdInvalidFormat); - // Validates the ordering and performance characteristics of the track. RuleFor(command => command.TrackNumber) .NotNull() @@ -248,11 +248,17 @@ public class UpdateTrackCommandValidator : AbstractValidator .When(command => command.Bpm.HasValue) .WithError(Errors.Music.BpmMustBeGreaterThanZero); - RuleFor(command => command.Work) + // Validates the work the track is a recording of. + RuleFor(command => command.Work!.Title) .MaximumLength(255) - .When(command => command.Work is not null) + .When(command => command.Work is not null && command.Work.Title is not null) .WithError(Errors.Music.WorkMustBeMaximum255CharactersLong); + RuleFor(command => command.Work!.MusicBrainzWorkId) + .Must(musicBrainzWorkId => musicBrainzWorkId is null || musicBrainzWorkId != Guid.Empty) + .When(command => command.Work is not null) + .WithError(Errors.Music.MusicBrainzIdInvalidFormat); + // Validates the moods and the ISRC codes of the track. RuleForEach(command => command.Moods) .ChildRules(mood => diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommandFixture.cs index 773d80c0..66158351 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommandFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommandFixture.cs @@ -25,7 +25,7 @@ namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrar public class AddAlbumCommandFixture { private readonly Faker _faker = new(); - private readonly AlbumMetadataDtoFixture _albumMetadataDtoFixture = new(); + private readonly MusicAlbumMetadataDtoFixture _musicAlbumMetadataDtoFixture = new(); private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new(); private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new(); private readonly AddTrackCommandFixture _addTrackCommandFixture = new(); @@ -37,8 +37,11 @@ public class AddAlbumCommandFixture /// Optional. The Id of the artist the album belongs to, taken from the route. /// Optional. The album metadata of the album. /// Optional. The physical or digital medium of the album. + /// Optional. The outermost physical packaging 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. @@ -50,8 +53,11 @@ public class AddAlbumCommandFixture /// Whether the artist Id should be included, or forced to . /// Whether the metadata should be included, or forced to . /// Whether the media format should be included, or forced to . + /// Whether the packaging should be included, or forced to . /// Whether the barcode should be included, or forced to . - /// Whether the catalog number should be included, or forced to . + /// Whether the catalog number should be included, or forced to . + /// Whether the label should be included, or forced to . + /// Whether the ASIN should be included, or forced to . /// Whether the MusicBrainz release Id should be included, or forced to . /// Whether the MusicBrainz release group Id should be included, or forced to . /// Whether the MusicBrainz release artist Id should be included, or forced to . @@ -63,10 +69,13 @@ public class AddAlbumCommandFixture public AddAlbumCommand Create( string? libraryId = null, string? artistId = null, - AlbumMetadataDto? metadata = null, + MusicAlbumMetadataDto? metadata = null, MusicMediaFormat? mediaFormat = null, + MusicReleasePackaging? packaging = null, string? barcode = null, - string? catalogNumber = null, + List? catalogNumbers = null, + string? label = null, + string? asin = null, Guid? musicBrainzReleaseId = null, Guid? musicBrainzReleaseGroupId = null, Guid? musicBrainzReleaseArtistId = null, @@ -78,8 +87,11 @@ public class AddAlbumCommandFixture bool includeArtistId = true, bool includeMetadata = true, bool includeMediaFormat = true, + bool includePackaging = true, bool includeBarcode = true, - bool includeCatalogNumber = true, + bool includeCatalogNumbers = true, + bool includeLabel = true, + bool includeAsin = true, bool includeMusicBrainzReleaseId = true, bool includeMusicBrainzReleaseGroupId = true, bool includeMusicBrainzReleaseArtistId = true, @@ -94,10 +106,13 @@ public class AddAlbumCommandFixture return new AddAlbumCommand( resolvedLibraryId, resolvedArtistId, - includeMetadata ? (metadata ?? _albumMetadataDtoFixture.Create()) : null, + includeMetadata ? (metadata ?? _musicAlbumMetadataDtoFixture.Create()) : null, includeMediaFormat ? (mediaFormat ?? _faker.PickRandom()) : null, + includePackaging ? (packaging ?? _faker.PickRandom()) : null, includeBarcode ? (barcode ?? _faker.Random.String2(_faker.Random.Int(12, 13), "0123456789")) : null, - includeCatalogNumber ? (catalogNumber ?? _faker.Random.AlphaNumeric(_faker.Random.Int(1, 50))) : null, + includeCatalogNumbers ? (catalogNumbers ?? [_faker.Random.AlphaNumeric(_faker.Random.Int(1, 50))]) : null, + includeLabel ? (label ?? _faker.Company.CompanyName()) : null, + includeAsin ? (asin ?? _faker.Random.AlphaNumeric(10)) : null, includeMusicBrainzReleaseId ? (musicBrainzReleaseId ?? _faker.Random.Guid()) : null, includeMusicBrainzReleaseGroupId ? (musicBrainzReleaseGroupId ?? _faker.Random.Guid()) : null, includeMusicBrainzReleaseArtistId ? (musicBrainzReleaseArtistId ?? _faker.Random.Guid()) : null, diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommandFixture.cs index 6f158dbc..dfed2b9d 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommandFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommandFixture.cs @@ -23,7 +23,7 @@ namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrar public class UpdateAlbumCommandFixture { private readonly Faker _faker = new(); - private readonly AlbumMetadataDtoFixture _albumMetadataDtoFixture = new(); + private readonly MusicAlbumMetadataDtoFixture _musicAlbumMetadataDtoFixture = new(); private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new(); private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new(); @@ -35,8 +35,11 @@ public class UpdateAlbumCommandFixture /// Optional. The Id of the album to update, taken from the route. /// Optional. The album metadata of the album. /// Optional. The physical or digital medium of the album. + /// Optional. The outermost physical packaging 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. @@ -47,8 +50,11 @@ public class UpdateAlbumCommandFixture /// Whether the album Id should be included, or forced to . /// Whether the metadata should be included, or forced to . /// Whether the media format should be included, or forced to . + /// Whether the packaging should be included, or forced to . /// Whether the barcode should be included, or forced to . - /// Whether the catalog number should be included, or forced to . + /// Whether the catalog number should be included, or forced to . + /// Whether the label should be included, or forced to . + /// Whether the ASIN should be included, or forced to . /// Whether the MusicBrainz release Id should be included, or forced to . /// Whether the MusicBrainz release group Id should be included, or forced to . /// Whether the MusicBrainz release artist Id should be included, or forced to . @@ -59,10 +65,13 @@ public class UpdateAlbumCommandFixture string? libraryId = null, string? artistId = null, string? albumId = null, - AlbumMetadataDto? metadata = null, + MusicAlbumMetadataDto? metadata = null, MusicMediaFormat? mediaFormat = null, + MusicReleasePackaging? packaging = null, string? barcode = null, - string? catalogNumber = null, + List? catalogNumbers = null, + string? label = null, + string? asin = null, Guid? musicBrainzReleaseId = null, Guid? musicBrainzReleaseGroupId = null, Guid? musicBrainzReleaseArtistId = null, @@ -73,8 +82,11 @@ public class UpdateAlbumCommandFixture bool includeAlbumId = true, bool includeMetadata = true, bool includeMediaFormat = true, + bool includePackaging = true, bool includeBarcode = true, - bool includeCatalogNumber = true, + bool includeCatalogNumbers = true, + bool includeLabel = true, + bool includeAsin = true, bool includeMusicBrainzReleaseId = true, bool includeMusicBrainzReleaseGroupId = true, bool includeMusicBrainzReleaseArtistId = true, @@ -85,10 +97,13 @@ public class UpdateAlbumCommandFixture includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null, includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null, includeAlbumId ? (albumId ?? Guid.NewGuid().ToString()) : null, - includeMetadata ? (metadata ?? _albumMetadataDtoFixture.Create()) : null, + includeMetadata ? (metadata ?? _musicAlbumMetadataDtoFixture.Create()) : null, includeMediaFormat ? (mediaFormat ?? _faker.PickRandom()) : null, + includePackaging ? (packaging ?? _faker.PickRandom()) : null, includeBarcode ? (barcode ?? _faker.Random.String2(_faker.Random.Int(12, 13), "0123456789")) : null, - includeCatalogNumber ? (catalogNumber ?? _faker.Random.AlphaNumeric(_faker.Random.Int(1, 50))) : null, + includeCatalogNumbers ? (catalogNumbers ?? [_faker.Random.AlphaNumeric(_faker.Random.Int(1, 50))]) : null, + includeLabel ? (label ?? _faker.Company.CompanyName()) : null, + includeAsin ? (asin ?? _faker.Random.AlphaNumeric(10)) : null, includeMusicBrainzReleaseId ? (musicBrainzReleaseId ?? _faker.Random.Guid()) : null, includeMusicBrainzReleaseGroupId ? (musicBrainzReleaseGroupId ?? _faker.Random.Guid()) : null, includeMusicBrainzReleaseArtistId ? (musicBrainzReleaseArtistId ?? _faker.Random.Guid()) : null, diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommandFixture.cs index 39e59696..4a90ad85 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommandFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommandFixture.cs @@ -4,7 +4,11 @@ using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Comm using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.AddArtist; using Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.AddAlbum; using Lumina.Contracts.DTO.MediaContributors; +using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary; +using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary; using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors; +using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary; +using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -20,47 +24,64 @@ namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrar public class AddArtistCommandFixture { private readonly Faker _faker = new(); + private readonly MusicArtistMetadataDtoFixture _musicArtistMetadataDtoFixture = new(); private readonly AddAlbumCommandFixture _addAlbumCommandFixture = new(); private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new(); + private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new(); /// /// Creates a random valid command to add an artist. /// /// Optional. The Id of the media library the artist belongs to, taken from the route. - /// Optional. The name of the artist. + /// Optional. The metadata of the artist. /// 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 media contributors that make up the artist. + /// Optional. The ratings of the artist. /// Optional. The albums of the artist, each with its own tracks. /// Whether the library Id should be included, or forced to . - /// Whether the name should be included, or forced to . + /// Whether the metadata should be included, or forced to . /// Whether the website should be included, or forced to . /// Whether the MusicBrainz identifier should be included, or forced to . + /// Whether the IPI codes should be included, or forced to . + /// Whether the ISNI codes should be included, or forced to . /// Whether the contributors should be included, or forced to . + /// Whether the ratings should be included, or forced to . /// Whether the albums should be included, or forced to . /// The created command to add an artist. public AddArtistCommand Create( string? libraryId = null, - string? name = null, + MusicArtistMetadataDto? metadata = null, string? website = null, Guid? musicBrainzArtistId = null, + List? ipis = null, + List? isnis = null, List? contributors = null, + List? ratings = null, List? albums = null, bool includeLibraryId = true, - bool includeName = true, + bool includeMetadata = true, bool includeWebsite = true, bool includeMusicBrainzArtistId = true, + bool includeIpis = true, + bool includeIsnis = true, bool includeContributors = true, + bool includeRatings = true, bool includeAlbums = true) { string? resolvedLibraryId = includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null; return new AddArtistCommand( resolvedLibraryId, - includeName ? (name ?? _faker.Name.FullName()) : null, + includeMetadata ? (metadata ?? _musicArtistMetadataDtoFixture.Create()) : null, includeWebsite ? (website ?? _faker.Internet.Url()) : null, includeMusicBrainzArtistId ? (musicBrainzArtistId ?? _faker.Random.Guid()) : null, + includeIpis ? (ipis ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.AlphaNumeric(9))]) : null, + includeIsnis ? (isnis ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.AlphaNumeric(16))]) : null, includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null, + includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null, includeAlbums ? (albums ?? GenerateAlbums(resolvedLibraryId)) : null); } diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommandFixture.cs index 43137c90..cc87ed9a 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommandFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommandFixture.cs @@ -4,7 +4,11 @@ using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Comm using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.UpdateArtist; using Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.AddAlbum; using Lumina.Contracts.DTO.MediaContributors; +using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary; +using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary; using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors; +using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary; +using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -20,41 +24,55 @@ namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrar public class UpdateArtistCommandFixture { private readonly Faker _faker = new(); + private readonly MusicArtistMetadataDtoFixture _musicArtistMetadataDtoFixture = new(); private readonly AddAlbumCommandFixture _addAlbumCommandFixture = new(); private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new(); + private readonly AudioRatingDtoFixture _audioRatingDtoFixture = new(); /// /// Creates a random valid command to update an artist. /// /// Optional. The Id of the media library the artist belongs to, taken from the route. /// Optional. The Id of the artist, taken from the route. - /// Optional. The name of the artist. + /// Optional. The metadata of the artist. /// 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 media contributors that make up the artist. + /// Optional. The ratings of the artist. /// Optional. The albums of the artist, each with its own tracks. /// Whether the library Id should be included, or forced to . /// Whether the artist Id should be included, or forced to . - /// Whether the name should be included, or forced to . + /// Whether the metadata should be included, or forced to . /// Whether the website should be included, or forced to . /// Whether the MusicBrainz identifier should be included, or forced to . + /// Whether the IPI codes should be included, or forced to . + /// Whether the ISNI codes should be included, or forced to . /// Whether the contributors should be included, or forced to . + /// Whether the ratings should be included, or forced to . /// Whether the albums should be included, or forced to . /// The created command to update an artist. public UpdateArtistCommand Create( string? libraryId = null, string? artistId = null, - string? name = null, + MusicArtistMetadataDto? metadata = null, string? website = null, Guid? musicBrainzArtistId = null, + List? ipis = null, + List? isnis = null, List? contributors = null, + List? ratings = null, List? albums = null, bool includeLibraryId = true, bool includeArtistId = true, - bool includeName = true, + bool includeMetadata = true, bool includeWebsite = true, bool includeMusicBrainzArtistId = true, + bool includeIpis = true, + bool includeIsnis = true, bool includeContributors = true, + bool includeRatings = true, bool includeAlbums = true) { string? resolvedLibraryId = includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null; @@ -62,10 +80,13 @@ public class UpdateArtistCommandFixture return new UpdateArtistCommand( resolvedLibraryId, includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null, - includeName ? (name ?? _faker.Name.FullName()) : null, + includeMetadata ? (metadata ?? _musicArtistMetadataDtoFixture.Create()) : null, includeWebsite ? (website ?? _faker.Internet.Url()) : null, includeMusicBrainzArtistId ? (musicBrainzArtistId ?? _faker.Random.Guid()) : null, + includeIpis ? (ipis ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.AlphaNumeric(9))]) : null, + includeIsnis ? (isnis ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.AlphaNumeric(16))]) : null, includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null, + includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null, includeAlbums ? (albums ?? GenerateAlbums(resolvedLibraryId)) : null); } diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommandFixture.cs index 8bee2fae..8d3567e3 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommandFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommandFixture.cs @@ -26,7 +26,8 @@ namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrar public class AddTrackCommandFixture { private readonly Faker _faker = new(); - private readonly AudioMetadataDtoFixture _audioMetadataDtoFixture = new(); + private readonly MusicTrackMetadataDtoFixture _musicTrackMetadataDtoFixture = new(); + private readonly MusicWorkDtoFixture _musicWorkDtoFixture = new(); private readonly MoodDtoFixture _moodDtoFixture = new(); private readonly IsrcDtoFixture _isrcDtoFixture = new(); private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new(); @@ -45,10 +46,9 @@ public class AddTrackCommandFixture /// 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. 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 list of moods of the track. /// Optional. The list of ISRC of the track. /// Optional. The list of media contributors that performed on the track. @@ -67,7 +67,6 @@ public class AddTrackCommandFixture /// Whether the work should be included, or forced to . /// Whether the MusicBrainz recording Id should be included, or forced to . /// Whether the MusicBrainz track Id should be included, or forced to . - /// Whether the MusicBrainz work Id should be included, or forced to . /// Whether the moods should be included, or forced to . /// Whether the ISRC codes should be included, or forced to . /// Whether the contributors should be included, or forced to . @@ -78,16 +77,15 @@ public class AddTrackCommandFixture string? artistId = null, string? albumId = null, string? path = null, - AudioMetadataDto? metadata = null, + MusicTrackMetadataDto? metadata = null, int? trackNumber = null, int? discNumber = null, string? script = null, MusicKey? key = null, int? bpm = null, - string? work = null, + MusicWorkDto? work = null, Guid? musicBrainzRecordingId = null, Guid? musicBrainzTrackId = null, - Guid? musicBrainzWorkId = null, List? moods = null, List? isrcs = null, List? contributors = null, @@ -106,7 +104,6 @@ public class AddTrackCommandFixture bool includeWork = true, bool includeMusicBrainzRecordingId = true, bool includeMusicBrainzTrackId = true, - bool includeMusicBrainzWorkId = true, bool includeMoods = true, bool includeIsrcs = true, bool includeContributors = true, @@ -117,16 +114,15 @@ public class AddTrackCommandFixture includeArtistId ? artistId ?? Guid.NewGuid().ToString() : null, includeAlbumId ? albumId ?? Guid.NewGuid().ToString() : null, includePath ? path ?? Path.Combine(Path.GetTempPath(), "lumina-tracks", _faker.System.FileName()) : null, - includeMetadata ? metadata ?? _audioMetadataDtoFixture.Create() : null, + includeMetadata ? metadata ?? _musicTrackMetadataDtoFixture.Create() : null, includeTrackNumber ? trackNumber ?? _faker.Random.Int(1, 30) : null, includeDiscNumber ? discNumber ?? _faker.Random.Int(1, 3) : null, includeScript ? script ?? _faker.Random.AlphaNumeric(4) : null, includeKey ? key ?? _faker.PickRandom() : null, includeBpm ? bpm ?? _faker.Random.Int(40, 220) : null, - includeWork ? work ?? _faker.Lorem.Sentence() : null, + includeWork ? work ?? _musicWorkDtoFixture.Create() : null, includeMusicBrainzRecordingId ? musicBrainzRecordingId ?? _faker.Random.Guid() : null, includeMusicBrainzTrackId ? musicBrainzTrackId ?? _faker.Random.Guid() : null, - includeMusicBrainzWorkId ? musicBrainzWorkId ?? _faker.Random.Guid() : null, includeMoods ? moods ?? _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null, includeIsrcs ? isrcs ?? _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null, includeContributors ? contributors ?? _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null, diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandFixture.cs index 54bcd79b..2638718d 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandFixture.cs @@ -25,7 +25,8 @@ namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrar public class UpdateTrackCommandFixture { private readonly Faker _faker = new(); - private readonly AudioMetadataDtoFixture _audioMetadataDtoFixture = new(); + private readonly MusicTrackMetadataDtoFixture _musicTrackMetadataDtoFixture = new(); + private readonly MusicWorkDtoFixture _musicWorkDtoFixture = new(); private readonly MoodDtoFixture _moodDtoFixture = new(); private readonly IsrcDtoFixture _isrcDtoFixture = new(); private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new(); @@ -45,10 +46,9 @@ public class UpdateTrackCommandFixture /// 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. 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 moods of the track. /// Optional. The ISRC codes of the track. /// Optional. The media contributors that performed on the track. @@ -60,7 +60,6 @@ public class UpdateTrackCommandFixture /// Whether the work should be included, or forced to . /// Whether the MusicBrainz recording Id should be included, or forced to . /// Whether the MusicBrainz track Id should be included, or forced to . - /// Whether the MusicBrainz work Id should be included, or forced to . /// Whether the moods should be included, or forced to . /// Whether the ISRC codes should be included, or forced to . /// Whether the metadata should be included, or forced to . @@ -79,16 +78,15 @@ public class UpdateTrackCommandFixture string? albumId = null, string? trackId = null, string? path = null, - AudioMetadataDto? metadata = null, + MusicTrackMetadataDto? metadata = null, int? trackNumber = null, int? discNumber = null, string? script = null, MusicKey? key = null, int? bpm = null, - string? work = null, + MusicWorkDto? work = null, Guid? musicBrainzRecordingId = null, Guid? musicBrainzTrackId = null, - Guid? musicBrainzWorkId = null, List? moods = null, List? isrcs = null, List? contributors = null, @@ -100,7 +98,6 @@ public class UpdateTrackCommandFixture bool includeWork = true, bool includeMusicBrainzRecordingId = true, bool includeMusicBrainzTrackId = true, - bool includeMusicBrainzWorkId = true, bool includeMoods = true, bool includeIsrcs = true, bool includeMetadata = true, @@ -119,16 +116,15 @@ public class UpdateTrackCommandFixture includeAlbumId ? (albumId ?? _faker.Random.Guid().ToString()) : null, includeTrackId ? (trackId ?? _faker.Random.Guid().ToString()) : null, includePath ? (path ?? _faker.System.FilePath()) : null, - includeMetadata ? (metadata ?? _audioMetadataDtoFixture.Create()) : null, + includeMetadata ? (metadata ?? _musicTrackMetadataDtoFixture.Create()) : null, includeTrackNumber ? (trackNumber ?? _faker.Random.Int(1, 20)) : null, includeDiscNumber ? (discNumber ?? _faker.Random.Int(1, 3)) : null, includeScript ? (script ?? _faker.Random.String2(_faker.Random.Number(1, 50))) : null, includeKey ? (key ?? _faker.PickRandom()) : null, includeBpm ? (bpm ?? _faker.Random.Int(40, 240)) : null, - includeWork ? (work ?? _faker.Music.Genre()) : null, + includeWork ? (work ?? _musicWorkDtoFixture.Create()) : null, includeMusicBrainzRecordingId ? (musicBrainzRecordingId ?? _faker.Random.Guid()) : null, includeMusicBrainzTrackId ? (musicBrainzTrackId ?? _faker.Random.Guid()) : null, - includeMusicBrainzWorkId ? (musicBrainzWorkId ?? _faker.Random.Guid()) : null, includeMoods ? (moods ?? [.. _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null, includeIsrcs ? (isrcs ?? [.. _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null, includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null, diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommandHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommandHandlerTests.cs index 75b29816..b8c6c05d 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommandHandlerTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommandHandlerTests.cs @@ -59,7 +59,7 @@ public class AddAlbumCommandHandlerTests private readonly AlbumEntityFixture _albumEntityFixture = new(); private readonly LibraryEntityFixture _libraryEntityFixture = new(); private readonly MediaContributorEntityFixture _mediaContributorEntityFixture = new(); - private readonly AlbumMetadataDtoFixture _albumMetadataDtoFixture = new(); + private readonly MusicAlbumMetadataDtoFixture _albumMetadataDtoFixture = new(); private readonly GenreDtoFixture _genreDtoFixture = new(); private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new(); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommandValidatorTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommandValidatorTests.cs index e95bc068..48d1b755 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommandValidatorTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/AddAlbum/AddAlbumCommandValidatorTests.cs @@ -30,8 +30,9 @@ public class AddAlbumCommandValidatorTests { private readonly AddAlbumCommandFixture _addAlbumCommandFixture = new(); private readonly AddAlbumCommandValidator _validator = new(); - private readonly AlbumMetadataDtoFixture _albumMetadataDtoFixture = new(); - private readonly AudioMetadataDtoFixture _audioMetadataDtoFixture = new(); + private readonly MusicAlbumMetadataDtoFixture _albumMetadataDtoFixture = new(); + private readonly MusicTrackMetadataDtoFixture _audioMetadataDtoFixture = new(); + private readonly MusicWorkDtoFixture _musicWorkDtoFixture = new(); private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new(); private readonly GenreDtoFixture _genreDtoFixture = new(); private readonly TagDtoFixture _tagDtoFixture = new(); @@ -228,7 +229,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenReleaseTypeIsNotDefined_ShouldHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(releaseType: (MusicReleaseType)999)); + AddAlbumCommand command = _addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(releaseTypes: [(MusicReleaseType)999])); // Act List result = _validator.TestValidate(command); @@ -241,7 +242,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenReleaseTypeIsNull_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(includeReleaseType: false)); + AddAlbumCommand command = _addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(includeReleaseTypes: false)); // Act List result = _validator.TestValidate(command); @@ -254,7 +255,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenReleaseTypeIsDefined_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(releaseType: MusicReleaseType.Album)); + AddAlbumCommand command = _addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(releaseTypes: [MusicReleaseType.Album])); // Act List result = _validator.TestValidate(command); @@ -925,7 +926,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenMediaFormatIsNull_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumber: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false); + AddAlbumCommand command = _addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumbers: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false); // Act List result = _validator.TestValidate(command); @@ -951,7 +952,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenCatalogNumberExceeds50Characters_ShouldHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(catalogNumber: new Faker().Random.String2(51)); + AddAlbumCommand command = _addAlbumCommandFixture.Create(catalogNumbers: [new Faker().Random.String2(51)]); // Act List result = _validator.TestValidate(command); @@ -964,7 +965,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenCatalogNumberIsNull_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumber: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false); + AddAlbumCommand command = _addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumbers: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false); // Act List result = _validator.TestValidate(command); @@ -977,7 +978,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenCatalogNumberIsValid_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(catalogNumber: new Faker().Random.String2(50)); + AddAlbumCommand command = _addAlbumCommandFixture.Create(catalogNumbers: [new Faker().Random.String2(50)]); // Act List result = _validator.TestValidate(command); @@ -1035,7 +1036,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenBarcodeIsNull_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumber: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false); + AddAlbumCommand command = _addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumbers: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false); // Act List result = _validator.TestValidate(command); @@ -1087,7 +1088,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenMusicBrainzIdsAreNull_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumber: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false); + AddAlbumCommand command = _addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumbers: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false); // Act List result = _validator.TestValidate(command); @@ -1780,7 +1781,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenTrackMusicBrainzWorkIdIsEmptyGuid_ShouldHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(musicBrainzWorkId: Guid.Empty)]); + AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(work: _musicWorkDtoFixture.Create(musicBrainzWorkId: Guid.Empty))]); // Act List result = _validator.TestValidate(command); @@ -1793,7 +1794,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenTrackMusicBrainzIdsAreNull_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)]); + AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)]); // Act List result = _validator.TestValidate(command); @@ -1862,7 +1863,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenDiscNumberIsNull_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)]); + AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)]); // Act List result = _validator.TestValidate(command); @@ -1901,7 +1902,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenScriptIsNull_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)]); + AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)]); // Act List result = _validator.TestValidate(command); @@ -1940,7 +1941,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenKeyIsNull_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)]); + AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)]); // Act List result = _validator.TestValidate(command); @@ -1981,7 +1982,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenBpmIsNull_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)]); + AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)]); // Act List result = _validator.TestValidate(command); @@ -2007,7 +2008,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenWorkExceeds255Characters_ShouldHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(work: new Faker().Random.String2(256))]); + AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(work: _musicWorkDtoFixture.Create(title: new Faker().Random.String2(256)))]); // Act List result = _validator.TestValidate(command); @@ -2020,7 +2021,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenWorkIsNull_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)]); + AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)]); // Act List result = _validator.TestValidate(command); @@ -2033,7 +2034,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenWorkIsValid_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(work: new Faker().Random.String2(255))]); + AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(work: _musicWorkDtoFixture.Create(title: new Faker().Random.String2(255)))]); // Act List result = _validator.TestValidate(command); @@ -2413,7 +2414,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenTrackMusicBrainzIdsAreValid_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(musicBrainzRecordingId: Guid.NewGuid(), musicBrainzTrackId: Guid.NewGuid(), musicBrainzWorkId: Guid.NewGuid())]); + AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(musicBrainzRecordingId: Guid.NewGuid(), musicBrainzTrackId: Guid.NewGuid(), work: _musicWorkDtoFixture.Create(musicBrainzWorkId: Guid.NewGuid()))]); // Act List result = _validator.TestValidate(command); @@ -2690,7 +2691,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenMoodsIsNull_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)]); + AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)]); // Act List result = _validator.TestValidate(command); @@ -2703,7 +2704,7 @@ public class AddAlbumCommandValidatorTests public void Validate_WhenIsrcsIsNull_ShouldNotHaveValidationError() { // Arrange - AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)]); + AddAlbumCommand command = _addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)]); // Act List result = _validator.TestValidate(command); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommandHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommandHandlerTests.cs index 8b335b56..64cbda32 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommandHandlerTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommandHandlerTests.cs @@ -54,7 +54,7 @@ public class UpdateAlbumCommandHandlerTests private readonly AlbumEntityFixture _albumEntityFixture = new(); private readonly LibraryEntityFixture _libraryEntityFixture = new(); private readonly MediaContributorEntityFixture _mediaContributorEntityFixture = new(); - private readonly AlbumMetadataDtoFixture _albumMetadataDtoFixture = new(); + private readonly MusicAlbumMetadataDtoFixture _albumMetadataDtoFixture = new(); private readonly GenreDtoFixture _genreDtoFixture = new(); /// diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommandValidatorTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommandValidatorTests.cs index 490c05bc..1d627aac 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommandValidatorTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Albums/Commands/UpdateAlbum/UpdateAlbumCommandValidatorTests.cs @@ -28,7 +28,7 @@ public class UpdateAlbumCommandValidatorTests { private readonly UpdateAlbumCommandFixture _updateAlbumCommandFixture = new(); private readonly UpdateAlbumCommandValidator _validator = new(); - private readonly AlbumMetadataDtoFixture _albumMetadataDtoFixture = new(); + private readonly MusicAlbumMetadataDtoFixture _albumMetadataDtoFixture = new(); private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new(); private readonly GenreDtoFixture _genreDtoFixture = new(); private readonly TagDtoFixture _tagDtoFixture = new(); @@ -240,7 +240,7 @@ public class UpdateAlbumCommandValidatorTests public void Validate_WhenReleaseTypeIsNotDefined_ShouldHaveValidationError() { // Arrange - UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(releaseType: (MusicReleaseType)999)); + UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(releaseTypes: [(MusicReleaseType)999])); // Act List result = _validator.TestValidate(command); @@ -253,7 +253,7 @@ public class UpdateAlbumCommandValidatorTests public void Validate_WhenReleaseTypeIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(includeReleaseType: false)); + UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(includeReleaseTypes: false)); // Act List result = _validator.TestValidate(command); @@ -266,7 +266,7 @@ public class UpdateAlbumCommandValidatorTests public void Validate_WhenReleaseTypeIsDefined_ShouldNotHaveValidationError() { // Arrange - UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(releaseType: MusicReleaseType.Album)); + UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(releaseTypes: [MusicReleaseType.Album])); // Act List result = _validator.TestValidate(command); @@ -937,7 +937,7 @@ public class UpdateAlbumCommandValidatorTests public void Validate_WhenMediaFormatIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumber: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false); + UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumbers: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false); // Act List result = _validator.TestValidate(command); @@ -963,7 +963,7 @@ public class UpdateAlbumCommandValidatorTests public void Validate_WhenCatalogNumberExceeds50Characters_ShouldHaveValidationError() { // Arrange - UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(catalogNumber: new Faker().Random.String2(51)); + UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(catalogNumbers: [new Faker().Random.String2(51)]); // Act List result = _validator.TestValidate(command); @@ -976,7 +976,7 @@ public class UpdateAlbumCommandValidatorTests public void Validate_WhenCatalogNumberIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumber: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false); + UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumbers: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false); // Act List result = _validator.TestValidate(command); @@ -989,7 +989,7 @@ public class UpdateAlbumCommandValidatorTests public void Validate_WhenCatalogNumberIsValid_ShouldNotHaveValidationError() { // Arrange - UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(catalogNumber: new Faker().Random.String2(50)); + UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(catalogNumbers: [new Faker().Random.String2(50)]); // Act List result = _validator.TestValidate(command); @@ -1047,7 +1047,7 @@ public class UpdateAlbumCommandValidatorTests public void Validate_WhenBarcodeIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumber: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false); + UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumbers: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false); // Act List result = _validator.TestValidate(command); @@ -1099,7 +1099,7 @@ public class UpdateAlbumCommandValidatorTests public void Validate_WhenMusicBrainzIdsAreNull_ShouldNotHaveValidationError() { // Arrange - UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumber: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false); + UpdateAlbumCommand command = _updateAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumbers: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false); // Act List result = _validator.TestValidate(command); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommandHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommandHandlerTests.cs index 3d13c57e..7ee1169b 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommandHandlerTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommandHandlerTests.cs @@ -20,6 +20,7 @@ using Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Al using Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.AddArtist; using Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.AddTrack; using Lumina.Contracts.Fixtures.Core.DTO.MediaContributors; +using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary; using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Artists; using Lumina.Domain.Common.Errors; using Lumina.Domain.Common.Primitives; @@ -53,6 +54,7 @@ public class AddArtistCommandHandlerTests private readonly AddArtistCommandHandler _sut; private readonly Guid _userId; private readonly AddArtistCommandFixture _addArtistCommandFixture = new(); + private readonly MusicArtistMetadataDtoFixture _musicArtistMetadataDtoFixture = new(); private readonly AddAlbumCommandFixture _addAlbumCommandFixture = new(); private readonly AddTrackCommandFixture _addTrackCommandFixture = new(); private readonly ArtistEntityFixture _artistEntityFixture = new(); @@ -275,7 +277,7 @@ public class AddArtistCommandHandlerTests public async Task HandleAsync_WhenCommandDomainConversionFails_ShouldReturnFailureResultWithoutPersisting() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(name: string.Empty); + AddArtistCommand command = _addArtistCommandFixture.Create(metadata: _musicArtistMetadataDtoFixture.Create(name: string.Empty)); // Act Result result = await _sut.HandleAsync(command, CancellationToken.None); @@ -384,7 +386,7 @@ public class AddArtistCommandHandlerTests Assert.NotNull(persistedArtist); Assert.Equal(insertedArtist!.Id, persistedArtist!.Id); Assert.Equal(persistedArtist.Id, result.Value.Id); - Assert.Equal(persistedArtist.Name, result.Value.Name); + Assert.Equal(persistedArtist.Name, result.Value.Metadata.Name); await _mockArtistRepository.Received(1).InsertAsync(Arg.Any(), Arg.Any()); await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any()); } diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommandValidatorTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommandValidatorTests.cs index b81d44b5..c2a12525 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommandValidatorTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/AddArtist/AddArtistCommandValidatorTests.cs @@ -31,8 +31,10 @@ public class AddArtistCommandValidatorTests private readonly AddArtistCommandFixture _addArtistCommandFixture = new(); private readonly AddArtistCommandValidator _validator = new(); private readonly AddAlbumCommandFixture _addAlbumCommandFixture = new(); - private readonly AlbumMetadataDtoFixture _albumMetadataDtoFixture = new(); - private readonly AudioMetadataDtoFixture _audioMetadataDtoFixture = new(); + private readonly MusicAlbumMetadataDtoFixture _albumMetadataDtoFixture = new(); + private readonly MusicTrackMetadataDtoFixture _audioMetadataDtoFixture = new(); + private readonly MusicWorkDtoFixture _musicWorkDtoFixture = new(); + private readonly MusicArtistMetadataDtoFixture _musicArtistMetadataDtoFixture = new(); private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new(); private readonly GenreDtoFixture _genreDtoFixture = new(); private readonly TagDtoFixture _tagDtoFixture = new(); @@ -65,7 +67,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenNameIsNull_ShouldHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(includeName: false); + AddArtistCommand command = _addArtistCommandFixture.Create(metadata: _musicArtistMetadataDtoFixture.Create(includeName: false)); // Act List result = _validator.TestValidate(command); @@ -80,7 +82,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenNameIsEmpty_ShouldHaveValidationError(string name) { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(name: name); + AddArtistCommand command = _addArtistCommandFixture.Create(metadata: _musicArtistMetadataDtoFixture.Create(name: name)); // Act List result = _validator.TestValidate(command); @@ -93,7 +95,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenNameExceeds255Characters_ShouldHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(name: new Faker().Random.String2(256)); + AddArtistCommand command = _addArtistCommandFixture.Create(metadata: _musicArtistMetadataDtoFixture.Create(name: new Faker().Random.String2(256))); // Act List result = _validator.TestValidate(command); @@ -106,7 +108,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenNameIsValid_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(name: new Faker().Random.String2(255)); + AddArtistCommand command = _addArtistCommandFixture.Create(metadata: _musicArtistMetadataDtoFixture.Create(name: new Faker().Random.String2(255))); // Act List result = _validator.TestValidate(command); @@ -359,7 +361,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenAlbumReleaseTypeIsNotDefined_ShouldHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(releaseType: (MusicReleaseType)999))]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(releaseTypes: [(MusicReleaseType)999]))]); // Act List result = _validator.TestValidate(command); @@ -372,7 +374,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenAlbumReleaseTypeIsNull_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(includeReleaseType: false))]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(includeReleaseTypes: false))]); // Act List result = _validator.TestValidate(command); @@ -385,7 +387,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenAlbumReleaseTypeIsDefined_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(releaseType: MusicReleaseType.Album))]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(releaseTypes: [MusicReleaseType.Album]))]); // Act List result = _validator.TestValidate(command); @@ -857,7 +859,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenAlbumMediaFormatIsNull_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumber: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false)]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumbers: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false)]); // Act List result = _validator.TestValidate(command); @@ -883,7 +885,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenAlbumCatalogNumberExceeds50Characters_ShouldHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(catalogNumber: new Faker().Random.String2(51))]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(catalogNumbers: [new Faker().Random.String2(51)])]); // Act List result = _validator.TestValidate(command); @@ -896,7 +898,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenAlbumCatalogNumberIsNull_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumber: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false)]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumbers: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false)]); // Act List result = _validator.TestValidate(command); @@ -954,7 +956,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenAlbumBarcodeIsNull_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumber: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false)]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumbers: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false)]); // Act List result = _validator.TestValidate(command); @@ -1006,7 +1008,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenAlbumMusicBrainzIdsAreNull_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumber: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false)]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumbers: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false)]); // Act List result = _validator.TestValidate(command); @@ -1651,7 +1653,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenTrackMusicBrainzWorkIdIsEmptyGuid_ShouldHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(musicBrainzWorkId: Guid.Empty)])]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(work: _musicWorkDtoFixture.Create(musicBrainzWorkId: Guid.Empty))])]); // Act List result = _validator.TestValidate(command); @@ -1748,7 +1750,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenTrackWorkExceeds255Characters_ShouldHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(work: new Faker().Random.String2(256))])]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(work: _musicWorkDtoFixture.Create(title: new Faker().Random.String2(256)))])]); // Act List result = _validator.TestValidate(command); @@ -2187,7 +2189,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenAlbumCatalogNumberIsValid_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(catalogNumber: new Faker().Random.String2(50))]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(catalogNumbers: [new Faker().Random.String2(50)])]); // Act List result = _validator.TestValidate(command); @@ -2550,7 +2552,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenTrackMusicBrainzIdsAreValid_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(musicBrainzRecordingId: Guid.NewGuid(), musicBrainzTrackId: Guid.NewGuid(), musicBrainzWorkId: Guid.NewGuid())])]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(musicBrainzRecordingId: Guid.NewGuid(), musicBrainzTrackId: Guid.NewGuid(), work: _musicWorkDtoFixture.Create(musicBrainzWorkId: Guid.NewGuid()))])]); // Act List result = _validator.TestValidate(command); @@ -2576,7 +2578,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenDiscNumberIsNull_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)])]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)])]); // Act List result = _validator.TestValidate(command); @@ -2602,7 +2604,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenTrackScriptIsNull_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)])]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)])]); // Act List result = _validator.TestValidate(command); @@ -2628,7 +2630,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenTrackKeyIsNull_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)])]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)])]); // Act List result = _validator.TestValidate(command); @@ -2654,7 +2656,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenTrackBpmIsNull_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)])]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)])]); // Act List result = _validator.TestValidate(command); @@ -2680,7 +2682,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenTrackWorkIsNull_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)])]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)])]); // Act List result = _validator.TestValidate(command); @@ -2693,7 +2695,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenTrackWorkIsValid_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(work: new Faker().Random.String2(255))])]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(work: _musicWorkDtoFixture.Create(title: new Faker().Random.String2(255)))])]); // Act List result = _validator.TestValidate(command); @@ -2719,7 +2721,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenTrackMoodsIsNull_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)])]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)])]); // Act List result = _validator.TestValidate(command); @@ -2745,7 +2747,7 @@ public class AddArtistCommandValidatorTests public void Validate_WhenTrackIsrcsIsNull_ShouldNotHaveValidationError() { // Arrange - AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)])]); + AddArtistCommand command = _addArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)])]); // Act List result = _validator.TestValidate(command); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommandHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommandHandlerTests.cs index 35ab36e6..c082ec4d 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommandHandlerTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommandHandlerTests.cs @@ -19,6 +19,7 @@ using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Manage using Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.AddAlbum; using Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.UpdateArtist; using Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.AddTrack; +using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary; using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Artists; using Lumina.Domain.Common.Errors; using Lumina.Domain.Common.Primitives; @@ -52,6 +53,7 @@ public class UpdateArtistCommandHandlerTests private readonly UpdateArtistCommandHandler _sut; private readonly Guid _userId; private readonly UpdateArtistCommandFixture _updateArtistCommandFixture = new(); + private readonly MusicArtistMetadataDtoFixture _musicArtistMetadataDtoFixture = new(); private readonly AddAlbumCommandFixture _addAlbumCommandFixture = new(); private readonly AddTrackCommandFixture _addTrackCommandFixture = new(); private readonly ArtistEntityFixture _artistEntityFixture = new(); @@ -383,7 +385,7 @@ public class UpdateArtistCommandHandlerTests Guid artistId = Guid.NewGuid(); Guid albumId = Guid.NewGuid(); ArtistEntity existingArtist = CreateExistingArtist(libraryId, artistId, albumId); - UpdateArtistCommand command = _updateArtistCommandFixture.Create(libraryId: libraryId.ToString(), artistId: artistId.ToString(), name: string.Empty); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(libraryId: libraryId.ToString(), artistId: artistId.ToString(), metadata: _musicArtistMetadataDtoFixture.Create(name: string.Empty)); StubArtistReads(existingArtist); // Act @@ -530,7 +532,7 @@ public class UpdateArtistCommandHandlerTests Assert.False(result.IsFailure); Assert.NotNull(updatedArtist); Assert.Equal(artistId, result.Value.Id); - Assert.Equal(persistedArtist.Name, result.Value.Name); + Assert.Equal(persistedArtist.Name, result.Value.Metadata.Name); await _mockArtistRepository.Received(1).UpdateAsync(Arg.Any(), Arg.Any()); await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any()); } diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommandValidatorTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommandValidatorTests.cs index 6db619ee..c5d1376e 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommandValidatorTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Commands/UpdateArtist/UpdateArtistCommandValidatorTests.cs @@ -31,8 +31,10 @@ public class UpdateArtistCommandValidatorTests private readonly UpdateArtistCommandFixture _updateArtistCommandFixture = new(); private readonly UpdateArtistCommandValidator _validator = new(); private readonly AddAlbumCommandFixture _addAlbumCommandFixture = new(); - private readonly AlbumMetadataDtoFixture _albumMetadataDtoFixture = new(); - private readonly AudioMetadataDtoFixture _audioMetadataDtoFixture = new(); + private readonly MusicAlbumMetadataDtoFixture _albumMetadataDtoFixture = new(); + private readonly MusicTrackMetadataDtoFixture _audioMetadataDtoFixture = new(); + private readonly MusicWorkDtoFixture _musicWorkDtoFixture = new(); + private readonly MusicArtistMetadataDtoFixture _musicArtistMetadataDtoFixture = new(); private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new(); private readonly GenreDtoFixture _genreDtoFixture = new(); private readonly TagDtoFixture _tagDtoFixture = new(); @@ -83,7 +85,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenNameIsNull_ShouldHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(includeName: false); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(metadata: _musicArtistMetadataDtoFixture.Create(includeName: false)); // Act List result = _validator.TestValidate(command); @@ -98,7 +100,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenNameIsEmpty_ShouldHaveValidationError(string name) { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(name: name); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(metadata: _musicArtistMetadataDtoFixture.Create(name: name)); // Act List result = _validator.TestValidate(command); @@ -111,7 +113,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenNameExceeds255Characters_ShouldHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(name: new Faker().Random.String2(256)); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(metadata: _musicArtistMetadataDtoFixture.Create(name: new Faker().Random.String2(256))); // Act List result = _validator.TestValidate(command); @@ -124,7 +126,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenNameIsValid_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(name: new Faker().Random.String2(255)); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(metadata: _musicArtistMetadataDtoFixture.Create(name: new Faker().Random.String2(255))); // Act List result = _validator.TestValidate(command); @@ -442,7 +444,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenAlbumReleaseTypeIsNotDefined_ShouldHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(releaseType: (MusicReleaseType)999))]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(releaseTypes: [(MusicReleaseType)999]))]); // Act List result = _validator.TestValidate(command); @@ -455,7 +457,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenAlbumReleaseTypeIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(includeReleaseType: false))]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(includeReleaseTypes: false))]); // Act List result = _validator.TestValidate(command); @@ -468,7 +470,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenAlbumReleaseTypeIsDefined_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(releaseType: MusicReleaseType.Album))]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(metadata: _albumMetadataDtoFixture.Create(releaseTypes: [MusicReleaseType.Album]))]); // Act List result = _validator.TestValidate(command); @@ -1074,7 +1076,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenAlbumMediaFormatIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumber: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false)]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumbers: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false)]); // Act List result = _validator.TestValidate(command); @@ -1100,7 +1102,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenAlbumCatalogNumberExceeds50Characters_ShouldHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(catalogNumber: new Faker().Random.String2(51))]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(catalogNumbers: [new Faker().Random.String2(51)])]); // Act List result = _validator.TestValidate(command); @@ -1113,7 +1115,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenAlbumCatalogNumberIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumber: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false)]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumbers: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false)]); // Act List result = _validator.TestValidate(command); @@ -1171,7 +1173,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenAlbumBarcodeIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumber: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false)]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumbers: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false)]); // Act List result = _validator.TestValidate(command); @@ -1223,7 +1225,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenAlbumMusicBrainzIdsAreNull_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumber: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false)]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(includeMediaFormat: false, includeBarcode: false, includeCatalogNumbers: false, includeMusicBrainzReleaseId: false, includeMusicBrainzReleaseGroupId: false, includeMusicBrainzReleaseArtistId: false)]); // Act List result = _validator.TestValidate(command); @@ -1938,7 +1940,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenTrackMusicBrainzWorkIdIsEmptyGuid_ShouldHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(musicBrainzWorkId: Guid.Empty)])]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(work: _musicWorkDtoFixture.Create(musicBrainzWorkId: Guid.Empty))])]); // Act List result = _validator.TestValidate(command); @@ -2035,7 +2037,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenTrackWorkExceeds255Characters_ShouldHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(work: new Faker().Random.String2(256))])]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(work: _musicWorkDtoFixture.Create(title: new Faker().Random.String2(256)))])]); // Act List result = _validator.TestValidate(command); @@ -2314,7 +2316,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenAlbumCatalogNumberIsValid_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(catalogNumber: new Faker().Random.String2(50))]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(catalogNumbers: [new Faker().Random.String2(50)])]); // Act List result = _validator.TestValidate(command); @@ -2632,7 +2634,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenTrackMusicBrainzIdsAreValid_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(musicBrainzRecordingId: Guid.NewGuid(), musicBrainzTrackId: Guid.NewGuid(), musicBrainzWorkId: Guid.NewGuid())])]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(musicBrainzRecordingId: Guid.NewGuid(), musicBrainzTrackId: Guid.NewGuid(), work: _musicWorkDtoFixture.Create(musicBrainzWorkId: Guid.NewGuid()))])]); // Act List result = _validator.TestValidate(command); @@ -2658,7 +2660,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenDiscNumberIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)])]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)])]); // Act List result = _validator.TestValidate(command); @@ -2684,7 +2686,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenTrackScriptIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)])]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)])]); // Act List result = _validator.TestValidate(command); @@ -2710,7 +2712,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenTrackKeyIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)])]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)])]); // Act List result = _validator.TestValidate(command); @@ -2736,7 +2738,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenTrackBpmIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)])]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)])]); // Act List result = _validator.TestValidate(command); @@ -2762,7 +2764,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenTrackWorkIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)])]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)])]); // Act List result = _validator.TestValidate(command); @@ -2775,7 +2777,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenTrackWorkIsValid_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(work: new Faker().Random.String2(255))])]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(work: _musicWorkDtoFixture.Create(title: new Faker().Random.String2(255)))])]); // Act List result = _validator.TestValidate(command); @@ -2801,7 +2803,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenTrackMoodsIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)])]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)])]); // Act List result = _validator.TestValidate(command); @@ -2827,7 +2829,7 @@ public class UpdateArtistCommandValidatorTests public void Validate_WhenTrackIsrcsIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false)])]); + UpdateArtistCommand command = _updateArtistCommandFixture.Create(albums: [_addAlbumCommandFixture.Create(tracks: [_addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false)])]); // Act List result = _validator.TestValidate(command); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Queries/GetArtist/GetArtistQueryHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Queries/GetArtist/GetArtistQueryHandlerTests.cs index 51d67bb7..bde4ff41 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Queries/GetArtist/GetArtistQueryHandlerTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Artists/Queries/GetArtist/GetArtistQueryHandlerTests.cs @@ -78,7 +78,7 @@ public class GetArtistQueryHandlerTests Assert.False(result.IsFailure); Assert.Equal(artistId, result.Value.Id); Assert.Equal(libraryId, result.Value.LibraryId); - Assert.Equal(artist.Name, result.Value.Name); + Assert.Equal(artist.Name, result.Value.Metadata.Name); Assert.Equal(artist.Website, result.Value.Website); Assert.NotNull(result.Value.Albums); Assert.Equal(artist.Albums.Count, result.Value.Albums!.Count); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommandHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommandHandlerTests.cs index 1d398a19..1458069b 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommandHandlerTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommandHandlerTests.cs @@ -59,7 +59,7 @@ public class AddTrackCommandHandlerTests private readonly TrackEntityFixture _trackEntityFixture = new(); private readonly LibraryEntityFixture _libraryEntityFixture = new(); private readonly MediaContributorEntityFixture _mediaContributorEntityFixture = new(); - private readonly AudioMetadataDtoFixture _audioMetadataDtoFixture = new(); + private readonly MusicTrackMetadataDtoFixture _audioMetadataDtoFixture = new(); private readonly GenreDtoFixture _genreDtoFixture = new(); private readonly MediaContributorReferenceDtoFixture _mediaContributorReferenceDtoFixture = new(); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommandValidatorTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommandValidatorTests.cs index 0c14b1e1..a172a99d 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommandValidatorTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/AddTrack/AddTrackCommandValidatorTests.cs @@ -27,7 +27,8 @@ public class AddTrackCommandValidatorTests { private readonly AddTrackCommandFixture _addTrackCommandFixture = new(); private readonly AddTrackCommandValidator _validator = new(); - private readonly AudioMetadataDtoFixture _audioMetadataDtoFixture = new(); + private readonly MusicTrackMetadataDtoFixture _audioMetadataDtoFixture = new(); + private readonly MusicWorkDtoFixture _musicWorkDtoFixture = new(); private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new(); private readonly GenreDtoFixture _genreDtoFixture = new(); private readonly TagDtoFixture _tagDtoFixture = new(); @@ -943,7 +944,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenMusicBrainzRecordingIdIsNull_ShouldNotHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); + AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -969,7 +970,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenMusicBrainzWorkIdIsEmptyGuid_ShouldHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(musicBrainzWorkId: Guid.Empty); + AddTrackCommand command = _addTrackCommandFixture.Create(work: _musicWorkDtoFixture.Create(musicBrainzWorkId: Guid.Empty)); // Act List result = _validator.TestValidate(command); @@ -985,7 +986,7 @@ public class AddTrackCommandValidatorTests AddTrackCommand command = _addTrackCommandFixture.Create( musicBrainzRecordingId: Guid.NewGuid(), musicBrainzTrackId: Guid.NewGuid(), - musicBrainzWorkId: Guid.NewGuid()); + work: _musicWorkDtoFixture.Create(musicBrainzWorkId: Guid.NewGuid())); // Act List result = _validator.TestValidate(command); @@ -1054,7 +1055,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenDiscNumberIsNull_ShouldNotHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); + AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1093,7 +1094,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenScriptIsNull_ShouldNotHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); + AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1132,7 +1133,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenKeyIsNull_ShouldNotHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); + AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1173,7 +1174,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenBpmIsNull_ShouldNotHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); + AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1199,7 +1200,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenWorkExceeds255Characters_ShouldHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(work: new Faker().Random.String2(256)); + AddTrackCommand command = _addTrackCommandFixture.Create(work: _musicWorkDtoFixture.Create(title: new Faker().Random.String2(256))); // Act List result = _validator.TestValidate(command); @@ -1212,7 +1213,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenWorkIsNull_ShouldNotHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); + AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1225,7 +1226,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenWorkIsValid_ShouldNotHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(work: new Faker().Random.String2(255)); + AddTrackCommand command = _addTrackCommandFixture.Create(work: _musicWorkDtoFixture.Create(title: new Faker().Random.String2(255))); // Act List result = _validator.TestValidate(command); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandValidatorTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandValidatorTests.cs index 5af646ad..e24f00ff 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandValidatorTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandValidatorTests.cs @@ -30,7 +30,8 @@ public class UpdateTrackCommandValidatorTests { private readonly UpdateTrackCommandFixture _updateTrackCommandFixture = new(); private readonly UpdateTrackCommandValidator _validator = new(); - private readonly AudioMetadataDtoFixture _audioMetadataDtoFixture = new(); + private readonly MusicTrackMetadataDtoFixture _audioMetadataDtoFixture = new(); + private readonly MusicWorkDtoFixture _musicWorkDtoFixture = new(); private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new(); private readonly GenreDtoFixture _genreDtoFixture = new(); private readonly TagDtoFixture _tagDtoFixture = new(); @@ -1175,7 +1176,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenMusicBrainzRecordingIdIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1214,7 +1215,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenMusicBrainzTrackIdIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1227,7 +1228,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenMusicBrainzWorkIdIsEmptyGuid_ShouldHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(musicBrainzWorkId: Guid.Empty); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(work: _musicWorkDtoFixture.Create(musicBrainzWorkId: Guid.Empty)); // Act List result = _validator.TestValidate(command); @@ -1240,7 +1241,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenMusicBrainzWorkIdIsValid_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(musicBrainzWorkId: Guid.NewGuid()); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(work: _musicWorkDtoFixture.Create(musicBrainzWorkId: Guid.NewGuid())); // Act List result = _validator.TestValidate(command); @@ -1253,7 +1254,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenMusicBrainzWorkIdIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1357,7 +1358,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenDiscNumberIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1396,7 +1397,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenScriptIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1435,7 +1436,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenKeyIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1487,7 +1488,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenBpmIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1500,7 +1501,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenWorkExceeds255Characters_ShouldHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(work: new Faker().Random.String2(256)); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(work: _musicWorkDtoFixture.Create(title: new Faker().Random.String2(256))); // Act List result = _validator.TestValidate(command); @@ -1513,7 +1514,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenWorkIs255Characters_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(work: new Faker().Random.String2(255)); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(work: _musicWorkDtoFixture.Create(title: new Faker().Random.String2(255))); // Act List result = _validator.TestValidate(command); @@ -1526,7 +1527,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenWorkIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command);