diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/RoleEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/RoleEntityFixture.cs index 234cc401..1404aeeb 100644 --- a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/RoleEntityFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/RoleEntityFixture.cs @@ -23,17 +23,17 @@ public class RoleEntityFixture /// Optional. The Id of the role. /// Optional. The name of the role. /// Optional. The role permission associations of the role. - /// Whether the role permission associations should be included, or forced to an empty collection. /// Optional. The Id of the user that created the role. /// Optional. The time and date when the role was added. + /// Whether the role permission associations should be included, or forced to an empty collection. /// The created . public RoleEntity Create( Guid? id = null, string? roleName = null, IEnumerable? rolePermissions = null, - bool includeRolePermissions = false, Guid? createdBy = null, - DateTime? createdOnUtc = null) + DateTime? createdOnUtc = null, + bool includeRolePermissions = false) { return new Faker() .CustomInstantiator(faker => new RoleEntity diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/MediaLibrary/AudioLibrary/MusicLibrary/TrackEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/MediaLibrary/AudioLibrary/MusicLibrary/TrackEntityFixture.cs index ea928114..3b039dc2 100644 --- a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/MediaLibrary/AudioLibrary/MusicLibrary/TrackEntityFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/MediaLibrary/AudioLibrary/MusicLibrary/TrackEntityFixture.cs @@ -20,7 +20,6 @@ namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Au [ExcludeFromCodeCoverage] public class TrackEntityFixture { - private readonly Random _random = new(); private readonly Faker _faker = new(); private readonly TagEntityFixture _tagEntityFixture = new(); private readonly GenreEntityFixture _genreEntityFixture = new(); @@ -38,11 +37,11 @@ public class TrackEntityFixture /// Optional. The file system path of the track. /// Optional. The title of the track. /// Optional. The number of the track on its disc. - /// Whether the owned metadata collections (Tags, Genres, Moods, ISRCs, Contributors, Ratings) should be included, or forced to empty collections. /// Optional. The original release date of the track. /// Optional. The original release year of the track. /// Optional. The re-release date of the track. /// Optional. The re-release year of the track. + /// Whether the owned metadata collections (Tags, Genres, Moods, ISRCs, Contributors, Ratings) should be included, or forced to empty collections. /// Whether the original release date should be included, or forced to . /// Whether the original release year should be included, or forced to . /// Whether the re-release date should be included, or forced to . @@ -55,11 +54,11 @@ public class TrackEntityFixture string? path = null, string? title = null, int? trackNumber = null, - bool includeMetadata = true, DateOnly? originalReleaseDate = null, int? originalReleaseYear = null, DateOnly? reReleaseDate = null, int? reReleaseYear = null, + bool includeMetadata = true, bool includeOriginalReleaseDate = true, bool includeOriginalReleaseYear = true, bool includeReReleaseDate = true, @@ -69,9 +68,9 @@ public class TrackEntityFixture Guid resolvedAlbumId = albumId ?? Guid.NewGuid(); Guid resolvedLibraryId = libraryId ?? Guid.NewGuid(); const int MAXIMUM_RELEASE_YEAR = 2026; - int resolvedOriginalReleaseYear = originalReleaseYear ?? _random.Next(1900, MAXIMUM_RELEASE_YEAR); + int resolvedOriginalReleaseYear = originalReleaseYear ?? Random.Shared.Next(1900, MAXIMUM_RELEASE_YEAR); int resolvedReReleaseYearUpperBound = Math.Max(resolvedOriginalReleaseYear + 1, MAXIMUM_RELEASE_YEAR); - int resolvedReReleaseYear = reReleaseYear ?? _random.Next(resolvedOriginalReleaseYear, resolvedReReleaseYearUpperBound); + int resolvedReReleaseYear = reReleaseYear ?? Random.Shared.Next(resolvedOriginalReleaseYear, resolvedReReleaseYearUpperBound); DateOnly resolvedOriginalReleaseDate = originalReleaseDate ?? _faker.DateOnlyBetween(new DateOnly(resolvedOriginalReleaseYear, 1, 1), new DateOnly(resolvedOriginalReleaseYear, 12, 31)); DateOnly resolvedReReleaseDate = reReleaseDate ?? _faker.DateOnlyBetween(resolvedReReleaseYear == resolvedOriginalReleaseYear ? resolvedOriginalReleaseDate : new DateOnly(resolvedReReleaseYear, 1, 1), new DateOnly(resolvedReReleaseYear, 12, 31)); @@ -103,17 +102,17 @@ public class TrackEntityFixture .RuleFor(x => x.OriginalLanguageCode, f => f.Random.String2(2)) .RuleFor(x => x.OriginalLanguageName, f => f.Random.String2(f.Random.Number(1, 50))) .RuleFor(x => x.OriginalLanguageNativeName, f => f.Random.String2(f.Random.Number(1, 50))) - .RuleFor(x => x.DurationInSeconds, _random.Next(60, 7200)) + .RuleFor(x => x.DurationInSeconds, Random.Shared.Next(60, 7200)) .RuleFor(x => x.SampleRate, f => f.PickRandom(44100, 48000, 96000)) .RuleFor(x => x.Channels, f => f.PickRandom(1, 2, 6)) - .RuleFor(x => x.BitDepth, _random.Next(8, 32)) + .RuleFor(x => x.BitDepth, Random.Shared.Next(8, 32)) .RuleFor(x => x.AudioCodec, f => f.PickRandom("FLAC", "MP3", "AAC", "ALAC")) - .RuleFor(x => x.Bitrate, _random.Next(96, 1411)) + .RuleFor(x => x.Bitrate, Random.Shared.Next(96, 1411)) .RuleFor(x => x.TrackNumber, f => trackNumber ?? f.Random.Int(1, 20)) - .RuleFor(x => x.DiscNumber, _random.Next(1, 3)) + .RuleFor(x => x.DiscNumber, Random.Shared.Next(1, 3)) .RuleFor(x => x.Script, f => f.Random.String2(f.Random.Number(1, 50))) .RuleFor(x => x.Key, f => f.PickRandom()) - .RuleFor(x => x.Bpm, _random.Next(40, 240)) + .RuleFor(x => x.Bpm, Random.Shared.Next(40, 240)) .RuleFor(x => x.Work, f => f.Music.Genre()) .RuleFor(x => x.MusicBrainzRecordingId, f => f.Random.Guid()) .RuleFor(x => x.MusicBrainzTrackId, f => f.Random.Guid()) diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Themes/ThemeEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Themes/ThemeEntityFixture.cs index 6208cb12..8a23f5fc 100644 --- a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Themes/ThemeEntityFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Themes/ThemeEntityFixture.cs @@ -26,17 +26,17 @@ public class ThemeEntityFixture /// Optional author of the theme. /// Optional version of the theme. /// Optional preview image path of the theme, or when the theme has no preview. - /// Whether the preview path should be included, or forced to . /// Optional source the theme was installed from. /// Optional value indicating whether the theme is the currently active one. - /// Whether the currently active flag should be included, or forced to . /// Optional value indicating whether the theme was soft deleted. /// Optional UTC timestamp when the theme was installed. /// Optional UTC timestamp when the entity was created. /// Optional Id of the user that created the entity. /// Optional UTC timestamp when the entity was updated. - /// Whether the updated-on timestamp should be included, or forced to . /// Optional Id of the user that updated the entity. + /// Whether the preview path should be included, or forced to . + /// Whether the currently active flag should be included, or forced to . + /// Whether the updated-on timestamp should be included, or forced to . /// Whether the updated-by user Id should be included, or forced to . /// A configured instance. public ThemeEntity Create( @@ -47,17 +47,17 @@ public class ThemeEntityFixture string? author = null, string? version = null, string? previewPath = null, - bool includePreviewPath = false, ThemeInstallSource? installSource = null, bool? isCurrent = null, - bool includeIsCurrent = false, bool? isDeleted = null, DateTime? installedAtUtc = null, DateTime? createdOnUtc = null, Guid? createdBy = null, DateTime? updatedOnUtc = null, - bool includeUpdatedOnUtc = false, Guid? updatedBy = null, + bool includePreviewPath = false, + bool includeIsCurrent = false, + bool includeUpdatedOnUtc = false, bool includeUpdatedBy = false) { Guid resolvedCreatedBy = createdBy ?? Guid.NewGuid(); diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/UsersManagement/UserEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/UsersManagement/UserEntityFixture.cs index 61710769..f6432ad8 100644 --- a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/UsersManagement/UserEntityFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/UsersManagement/UserEntityFixture.cs @@ -29,9 +29,9 @@ public class UserEntityFixture /// Optional Id to pin, or to generate a random one. /// Optional user role association to pin when including it. /// Optional user permission associations to pin when including them. + /// Optional collection of libraries to pin for the user, or to generate them based on . /// Whether the user role association should be included, or forced to . /// Whether the user permission associations should be included, or forced to an empty collection. - /// Optional collection of libraries to pin for the user, or to generate them based on . /// The created user entity. public UserEntity Create( int libraryCount = 0, @@ -40,9 +40,9 @@ public class UserEntityFixture Guid? id = null, UserRoleEntity? userRole = null, IEnumerable? userPermissions = null, + ICollection? libraries = null, bool includeUserRole = false, - bool includeUserPermissions = false, - ICollection? libraries = null) + bool includeUserPermissions = false) { Guid userId = id ?? Guid.NewGuid(); ICollection resolvedLibraries = libraries ?? (libraryCount > 0 diff --git a/tests/Common/Lumina.Application.Fixtures/Common/Infrastructure/Models/DTO/Themes/ThemeManifestDtoFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/Infrastructure/Models/DTO/Themes/ThemeManifestDtoFixture.cs index 2e912ee2..2ba93d7b 100644 --- a/tests/Common/Lumina.Application.Fixtures/Common/Infrastructure/Models/DTO/Themes/ThemeManifestDtoFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Common/Infrastructure/Models/DTO/Themes/ThemeManifestDtoFixture.cs @@ -25,8 +25,8 @@ public class ThemeManifestDtoFixture /// Optional author of the theme. /// Optional version of the theme. /// Optional preview image path of the theme, or when the theme has no preview. - /// Whether the preview path should be included, or forced to . /// Optional template mappings of the theme. + /// Whether the preview path should be included, or forced to . /// A configured instance. public ThemeManifestDto Create( int? schemaVersion = null, @@ -36,8 +36,8 @@ public class ThemeManifestDtoFixture string? author = null, string? version = null, string? preview = null, - bool includePreview = false, - Dictionary? templates = null) + Dictionary? templates = null, + bool includePreview = false) { return new Faker() .CustomInstantiator(f => new ThemeManifestDto 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 038fc6e7..8bee2fae 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 @@ -60,7 +60,16 @@ public class AddTrackCommandFixture /// Whether the path should be included, or forced to . /// Whether the metadata should be included, or forced to . /// Whether the track number should be included, or forced to . - /// Whether the properties that are not explicitly provided should be randomized, or forced to . + /// Whether the disc number should be included, or forced to . + /// Whether the script should be included, or forced to . + /// Whether the musical key should be included, or forced to . + /// Whether the tempo should be included, or forced to . + /// 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 . /// Whether the ratings should be included, or forced to . /// The created command to add a track. @@ -90,7 +99,16 @@ public class AddTrackCommandFixture bool includePath = true, bool includeMetadata = true, bool includeTrackNumber = true, - bool includeOptionalProperties = true, + bool includeDiscNumber = true, + bool includeScript = true, + bool includeKey = true, + bool includeBpm = true, + bool includeWork = true, + bool includeMusicBrainzRecordingId = true, + bool includeMusicBrainzTrackId = true, + bool includeMusicBrainzWorkId = true, + bool includeMoods = true, + bool includeIsrcs = true, bool includeContributors = true, bool includeRatings = true) { @@ -101,16 +119,16 @@ public class AddTrackCommandFixture includePath ? path ?? Path.Combine(Path.GetTempPath(), "lumina-tracks", _faker.System.FileName()) : null, includeMetadata ? metadata ?? _audioMetadataDtoFixture.Create() : null, includeTrackNumber ? trackNumber ?? _faker.Random.Int(1, 30) : null, - includeOptionalProperties ? discNumber ?? _faker.Random.Int(1, 3) : null, - includeOptionalProperties ? script ?? _faker.Random.AlphaNumeric(4) : null, - includeOptionalProperties ? key ?? _faker.PickRandom() : null, - includeOptionalProperties ? bpm ?? _faker.Random.Int(40, 220) : null, - includeOptionalProperties ? work ?? _faker.Lorem.Sentence() : null, - includeOptionalProperties ? musicBrainzRecordingId ?? _faker.Random.Guid() : null, - includeOptionalProperties ? musicBrainzTrackId ?? _faker.Random.Guid() : null, - includeOptionalProperties ? musicBrainzWorkId ?? _faker.Random.Guid() : null, - includeOptionalProperties ? moods ?? _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null, - includeOptionalProperties ? isrcs ?? _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : 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, + 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, includeRatings ? ratings ?? _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null, trackId); 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 284e3b1b..54bcd79b 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 @@ -53,7 +53,16 @@ public class UpdateTrackCommandFixture /// Optional. The ISRC codes of the track. /// Optional. The media contributors that performed on the track. /// Optional. The ratings of the track. - /// Whether the optional properties that are not explicitly provided should be randomized, or forced to . + /// Whether the disc number should be included, or forced to . + /// Whether the script should be included, or forced to . + /// Whether the musical key should be included, or forced to . + /// Whether the tempo should be included, or forced to . + /// 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 . /// Whether the contributors list should be included, or forced to . /// Whether the ratings list should be included, or forced to . @@ -84,7 +93,16 @@ public class UpdateTrackCommandFixture List? isrcs = null, List? contributors = null, List? ratings = null, - bool includeOptionalProperties = true, + bool includeDiscNumber = true, + bool includeScript = true, + bool includeKey = true, + bool includeBpm = true, + bool includeWork = true, + bool includeMusicBrainzRecordingId = true, + bool includeMusicBrainzTrackId = true, + bool includeMusicBrainzWorkId = true, + bool includeMoods = true, + bool includeIsrcs = true, bool includeMetadata = true, bool includeContributors = true, bool includeRatings = true, @@ -103,16 +121,16 @@ public class UpdateTrackCommandFixture includePath ? (path ?? _faker.System.FilePath()) : null, includeMetadata ? (metadata ?? _audioMetadataDtoFixture.Create()) : null, includeTrackNumber ? (trackNumber ?? _faker.Random.Int(1, 20)) : null, - includeOptionalProperties ? (discNumber ?? _faker.Random.Int(1, 3)) : null, - includeOptionalProperties ? (script ?? _faker.Random.String2(_faker.Random.Number(1, 50))) : null, - includeOptionalProperties ? (key ?? _faker.PickRandom()) : null, - includeOptionalProperties ? (bpm ?? _faker.Random.Int(40, 240)) : null, - includeOptionalProperties ? (work ?? _faker.Music.Genre()) : null, - includeOptionalProperties ? (musicBrainzRecordingId ?? _faker.Random.Guid()) : null, - includeOptionalProperties ? (musicBrainzTrackId ?? _faker.Random.Guid()) : null, - includeOptionalProperties ? (musicBrainzWorkId ?? _faker.Random.Guid()) : null, - includeOptionalProperties ? (moods ?? [.. _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null, - includeOptionalProperties ? (isrcs ?? [.. _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : 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, + 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, includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null); } diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/AddBook/AddBookCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/AddBook/AddBookCommandFixture.cs index e9318d45..c38bc3c0 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/AddBook/AddBookCommandFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/AddBook/AddBookCommandFixture.cs @@ -51,7 +51,21 @@ public class AddBookCommandFixture /// Optional. The contributors of the book. /// Optional. The ratings of the book. /// Whether the metadata should be included, or forced to . - /// Whether the properties that are not explicitly provided should be randomized, or forced to . + /// Whether the format should be included, or forced to . + /// Whether the edition should be included, or forced to . + /// Whether the volume number should be included, or forced to . + /// Whether the ASIN should be included, or forced to . + /// Whether the Goodreads Id should be included, or forced to . + /// Whether the LCCN should be included, or forced to . + /// Whether the OCLC number should be included, or forced to . + /// Whether the Open Library Id should be included, or forced to . + /// Whether the LibraryThing Id should be included, or forced to . + /// Whether the Google Books Id should be included, or forced to . + /// Whether the Barnes and Noble Id should be included, or forced to . + /// Whether the Apple Books Id should be included, or forced to . + /// Whether the ISBNs should be included, or forced to . + /// Whether the ratings should be included, or forced to . + /// Whether the contributors should be included, or forced to . /// The created command to add a book. public AddBookCommand Create( string? libraryId = null, @@ -74,7 +88,21 @@ public class AddBookCommandFixture List? contributors = null, List? ratings = null, bool includeMetadata = true, - bool includeOptionalProperties = true) + bool includeFormat = true, + bool includeEdition = true, + bool includeVolumeNumber = true, + bool includeAsin = true, + bool includeGoodreadsId = true, + bool includeLccn = true, + bool includeOclcNumber = true, + bool includeOpenLibraryId = true, + bool includeLibraryThingId = true, + bool includeGoogleBooksId = true, + bool includeBarnesAndNobleId = true, + bool includeAppleBooksId = true, + bool includeIsbns = true, + bool includeRatings = true, + bool includeContributors = true) { return new Faker() .CustomInstantiator(f => new AddBookCommand( @@ -101,22 +129,22 @@ public class AddBookCommandFixture .RuleFor(x => x.LibraryId, libraryId ?? Guid.NewGuid().ToString()) .RuleFor(x => x.Path, f => path ?? Path.Combine(Path.GetTempPath(), "lumina-books", f.System.FileName())) .RuleFor(x => x.Metadata, includeMetadata ? (metadata ?? _writtenContentMetadataDtoFixture.Create()) : null) - .RuleFor(x => x.Format, f => format ?? (includeOptionalProperties ? f.PickRandom() : null)) - .RuleFor(x => x.Edition, f => edition ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null)) - .RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeOptionalProperties ? (float?)f.Random.Number(1, 3) : null)) + .RuleFor(x => x.Format, f => format ?? (includeFormat ? f.PickRandom() : null)) + .RuleFor(x => x.Edition, f => edition ?? (includeEdition ? f.Random.String2(f.Random.Number(1, 50)) : null)) + .RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeVolumeNumber ? (float?)f.Random.Number(1, 3) : null)) .RuleFor(x => x.Series, series) - .RuleFor(x => x.ASIN, f => asin ?? (includeOptionalProperties ? f.Random.String2(10) : null)) - .RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeOptionalProperties ? f.Random.Number(100000, 500000).ToString() : null)) - .RuleFor(x => x.LCCN, f => lccn ?? (includeOptionalProperties ? CreateLccn(f) : null)) - .RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOptionalProperties ? CreateOclcNumber(f) : null)) - .RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOptionalProperties ? CreateOpenLibraryId(f) : null)) - .RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null)) - .RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeOptionalProperties ? CreateGoogleBooksId(f) : null)) - .RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeOptionalProperties ? f.Random.String2(10, "0123456789") : null)) - .RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeOptionalProperties ? $"id{f.Random.Number(1, 999999)}" : null)) - .RuleFor(p => p.ISBNs, f => isbns ?? (includeOptionalProperties ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)) - .RuleFor(p => p.Ratings, f => ratings ?? (includeOptionalProperties ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)) - .RuleFor(x => x.Contributors, f => contributors ?? (includeOptionalProperties ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)); + .RuleFor(x => x.ASIN, f => asin ?? (includeAsin ? f.Random.String2(10) : null)) + .RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeGoodreadsId ? f.Random.Number(100000, 500000).ToString() : null)) + .RuleFor(x => x.LCCN, f => lccn ?? (includeLccn ? CreateLccn(f) : null)) + .RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOclcNumber ? CreateOclcNumber(f) : null)) + .RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOpenLibraryId ? CreateOpenLibraryId(f) : null)) + .RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeLibraryThingId ? f.Random.String2(f.Random.Number(1, 50)) : null)) + .RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeGoogleBooksId ? CreateGoogleBooksId(f) : null)) + .RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeBarnesAndNobleId ? f.Random.String2(10, "0123456789") : null)) + .RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeAppleBooksId ? $"id{f.Random.Number(1, 999999)}" : null)) + .RuleFor(p => p.ISBNs, f => isbns ?? (includeIsbns ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)) + .RuleFor(p => p.Ratings, f => ratings ?? (includeRatings ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)) + .RuleFor(x => x.Contributors, f => contributors ?? (includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)); } /// diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/UpdateBook/UpdateBookCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/UpdateBook/UpdateBookCommandFixture.cs index 8c643188..e5738e1f 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/UpdateBook/UpdateBookCommandFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/UpdateBook/UpdateBookCommandFixture.cs @@ -51,7 +51,21 @@ public class UpdateBookCommandFixture /// Optional. The contributors of the book. /// Optional. The ratings of the book. /// Whether the metadata should be included, or forced to . - /// Whether the properties that are not explicitly provided should be randomized, or forced to . + /// Whether the format should be included, or forced to . + /// Whether the edition should be included, or forced to . + /// Whether the volume number should be included, or forced to . + /// Whether the ASIN should be included, or forced to . + /// Whether the Goodreads Id should be included, or forced to . + /// Whether the LCCN should be included, or forced to . + /// Whether the OCLC number should be included, or forced to . + /// Whether the Open Library Id should be included, or forced to . + /// Whether the LibraryThing Id should be included, or forced to . + /// Whether the Google Books Id should be included, or forced to . + /// Whether the Barnes and Noble Id should be included, or forced to . + /// Whether the Apple Books Id should be included, or forced to . + /// Whether the ISBNs should be included, or forced to . + /// Whether the ratings should be included, or forced to . + /// Whether the contributors should be included, or forced to . /// The created command to update a book. public UpdateBookCommand Create( string? libraryId = null, @@ -74,7 +88,21 @@ public class UpdateBookCommandFixture List? contributors = null, List? ratings = null, bool includeMetadata = true, - bool includeOptionalProperties = true) + bool includeFormat = true, + bool includeEdition = true, + bool includeVolumeNumber = true, + bool includeAsin = true, + bool includeGoodreadsId = true, + bool includeLccn = true, + bool includeOclcNumber = true, + bool includeOpenLibraryId = true, + bool includeLibraryThingId = true, + bool includeGoogleBooksId = true, + bool includeBarnesAndNobleId = true, + bool includeAppleBooksId = true, + bool includeIsbns = true, + bool includeRatings = true, + bool includeContributors = true) { return new Faker() .CustomInstantiator(f => new UpdateBookCommand( @@ -101,22 +129,22 @@ public class UpdateBookCommandFixture .RuleFor(x => x.LibraryId, libraryId ?? Guid.NewGuid().ToString()) .RuleFor(x => x.BookId, bookId ?? Guid.NewGuid().ToString()) .RuleFor(x => x.Metadata, includeMetadata ? (metadata ?? _writtenContentMetadataDtoFixture.Create()) : null) - .RuleFor(x => x.Format, f => format ?? (includeOptionalProperties ? f.PickRandom() : null)) - .RuleFor(x => x.Edition, f => edition ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null)) - .RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeOptionalProperties ? (float?)f.Random.Number(1, 3) : null)) + .RuleFor(x => x.Format, f => format ?? (includeFormat ? f.PickRandom() : null)) + .RuleFor(x => x.Edition, f => edition ?? (includeEdition ? f.Random.String2(f.Random.Number(1, 50)) : null)) + .RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeVolumeNumber ? (float?)f.Random.Number(1, 3) : null)) .RuleFor(x => x.Series, series) - .RuleFor(x => x.ASIN, f => asin ?? (includeOptionalProperties ? f.Random.String2(10) : null)) - .RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeOptionalProperties ? f.Random.Number(100000, 500000).ToString() : null)) - .RuleFor(x => x.LCCN, f => lccn ?? (includeOptionalProperties ? CreateLccn(f) : null)) - .RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOptionalProperties ? CreateOclcNumber(f) : null)) - .RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOptionalProperties ? CreateOpenLibraryId(f) : null)) - .RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null)) - .RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeOptionalProperties ? CreateGoogleBooksId(f) : null)) - .RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeOptionalProperties ? f.Random.String2(10, "0123456789") : null)) - .RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeOptionalProperties ? $"id{f.Random.Number(1, 999999)}" : null)) - .RuleFor(p => p.ISBNs, f => isbns ?? (includeOptionalProperties ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)) - .RuleFor(p => p.Ratings, f => ratings ?? (includeOptionalProperties ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)) - .RuleFor(x => x.Contributors, f => contributors ?? (includeOptionalProperties ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)); + .RuleFor(x => x.ASIN, f => asin ?? (includeAsin ? f.Random.String2(10) : null)) + .RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeGoodreadsId ? f.Random.Number(100000, 500000).ToString() : null)) + .RuleFor(x => x.LCCN, f => lccn ?? (includeLccn ? CreateLccn(f) : null)) + .RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOclcNumber ? CreateOclcNumber(f) : null)) + .RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOpenLibraryId ? CreateOpenLibraryId(f) : null)) + .RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeLibraryThingId ? f.Random.String2(f.Random.Number(1, 50)) : null)) + .RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeGoogleBooksId ? CreateGoogleBooksId(f) : null)) + .RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeBarnesAndNobleId ? f.Random.String2(10, "0123456789") : null)) + .RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeAppleBooksId ? $"id{f.Random.Number(1, 999999)}" : null)) + .RuleFor(p => p.ISBNs, f => isbns ?? (includeIsbns ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)) + .RuleFor(p => p.Ratings, f => ratings ?? (includeRatings ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)) + .RuleFor(x => x.Contributors, f => contributors ?? (includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)); } /// diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/AudioLibrary/AudioRatingDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/AudioLibrary/AudioRatingDtoFixture.cs index 68a8028c..6db08376 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/AudioLibrary/AudioRatingDtoFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/AudioLibrary/AudioRatingDtoFixture.cs @@ -17,7 +17,6 @@ namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary; public class AudioRatingDtoFixture { private readonly Fixture _fixture = new(); - private readonly Random _random = new(); /// /// Creates a random valid . @@ -26,6 +25,8 @@ public class AudioRatingDtoFixture /// Optional. The maximum possible rating value. /// Optional. The rating source. /// Optional. The number of votes. + /// Whether the rating value should be included, or forced to . + /// Whether the maximum possible rating value should be included, or forced to . /// Whether the rating source should be included, or forced to . /// Whether the number of votes should be included, or forced to . /// The created . @@ -34,14 +35,16 @@ public class AudioRatingDtoFixture decimal? maxValue = null, AudioRatingSource? source = null, int? voteCount = null, + bool includeValue = true, + bool includeMaxValue = true, bool includeSource = true, bool includeVoteCount = true) { return new AudioRatingDto( - value ?? _random.Next(1, 5), - maxValue ?? 5, + includeValue ? (value ?? Random.Shared.Next(1, 5)) : null, + includeMaxValue ? (maxValue ?? 5) : null, includeSource ? (source ?? _fixture.Create()) : null, - includeVoteCount ? (voteCount ?? _random.Next(1, 1000)) : null + includeVoteCount ? (voteCount ?? Random.Shared.Next(1, 1000)) : null ); } diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookMetadataDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookMetadataDtoFixture.cs index e0861e5d..44157872 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookMetadataDtoFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookMetadataDtoFixture.cs @@ -57,7 +57,12 @@ public class BookMetadataDtoFixture /// Optional. The ratings of the book. /// Optional. The path of the cover image of the book. /// Whether the title should be included, or forced to . - /// Whether the properties that are not explicitly provided should be randomized, or forced to . + /// Whether the release info should be included, or forced to . + /// Whether the genres should be included, or forced to . + /// Whether the tags should be included, or forced to . + /// Whether the language should be included, or forced to . + /// Whether the format should be included, or forced to . + /// Whether the volume number should be included, or forced to . /// The created . public BookMetadataDto Create( string? title = null, @@ -88,26 +93,31 @@ public class BookMetadataDtoFixture List? ratings = null, string? coverImagePath = null, bool includeTitle = true, - bool includeOptionalProperties = true) + bool includeReleaseInfo = true, + bool includeGenres = true, + bool includeTags = true, + bool includeLanguage = true, + bool includeFormat = true, + bool includeVolumeNumber = true) { int releaseYear = _faker.Random.Int(1900, 2024); return new BookMetadataDto( - includeTitle ? title ?? (includeOptionalProperties ? _faker.Lorem.Sentence(3) : null) : null, + includeTitle ? title ?? _faker.Lorem.Sentence(3) : null, originalTitle, description, - releaseInfo ?? (includeOptionalProperties ? _releaseInfoDtoFixture.Create( + includeReleaseInfo ? (releaseInfo ?? _releaseInfoDtoFixture.Create( originalReleaseDate: new DateOnly(releaseYear, 1, 1), originalReleaseYear: releaseYear, - releaseCountry: _faker.PickRandom()) : null), - genres ?? (includeOptionalProperties ? [_genreDtoFixture.Create()] : null), - tags ?? (includeOptionalProperties ? [_tagDtoFixture.Create()] : null), - language ?? (includeOptionalProperties ? _languageInfoDtoFixture.Create() : null), + releaseCountry: _faker.PickRandom())) : null, + includeGenres ? (genres ?? [_genreDtoFixture.Create()]) : null, + includeTags ? (tags ?? [_tagDtoFixture.Create()]) : null, + includeLanguage ? (language ?? _languageInfoDtoFixture.Create()) : null, originalLanguage, publisher, pageCount, - format ?? (includeOptionalProperties ? _faker.PickRandom() : null), + includeFormat ? (format ?? _faker.PickRandom()) : null, edition, - volumeNumber ?? (includeOptionalProperties ? _faker.Random.Int(1, 10) : null), + includeVolumeNumber ? (volumeNumber ?? _faker.Random.Int(1, 10)) : null, series, asin, goodreadsId, diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingDtoFixture.cs index cd594450..1ff90d12 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingDtoFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingDtoFixture.cs @@ -17,7 +17,6 @@ namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary. public class BookRatingDtoFixture { private readonly Fixture _fixture = new(); - private readonly Random _random = new(); /// /// Creates a . @@ -26,20 +25,22 @@ public class BookRatingDtoFixture /// Optional. The maximum possible rating value. /// Optional. The rating source. /// Optional. The number of votes. - /// Whether the optional source and vote count should be randomized, or forced to . + /// Whether the source should be included, or forced to . + /// Whether the vote count should be included, or forced to . /// The created . public BookRatingDto Create( decimal? value = null, decimal? maxValue = null, BookRatingSource? source = null, int? voteCount = null, - bool includeOptionalProperties = true) + bool includeSource = true, + bool includeVoteCount = true) { return new BookRatingDto( - value ?? _random.Next(1, 5), + value ?? Random.Shared.Next(1, 5), maxValue ?? 5, - source ?? (includeOptionalProperties ? _fixture.Create() : null), - voteCount ?? (includeOptionalProperties ? _random.Next(1, 1000) : null) + includeSource ? (source ?? _fixture.Create()) : null, + includeVoteCount ? (voteCount ?? Random.Shared.Next(1, 1000)) : null ); } diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/AddTrackRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/AddTrackRequestFixture.cs index 7aa37d24..c45bcafb 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/AddTrackRequestFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/AddTrackRequestFixture.cs @@ -53,7 +53,16 @@ public class AddTrackRequestFixture /// Whether the path should be included, or forced to . /// Whether the metadata should be included, or forced to . /// Whether the track number should be included, or forced to . - /// Whether the properties that are not explicitly provided should be randomized, or forced to . + /// Whether the disc number should be included, or forced to . + /// Whether the script should be included, or forced to . + /// Whether the musical key should be included, or forced to . + /// Whether the tempo should be included, or forced to . + /// 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 . /// Whether the ratings should be included, or forced to . /// The created request to add a track. @@ -76,7 +85,16 @@ public class AddTrackRequestFixture bool includePath = true, bool includeMetadata = true, bool includeTrackNumber = true, - bool includeOptionalProperties = true, + bool includeDiscNumber = true, + bool includeScript = true, + bool includeKey = true, + bool includeBpm = true, + bool includeWork = true, + bool includeMusicBrainzRecordingId = true, + bool includeMusicBrainzTrackId = true, + bool includeMusicBrainzWorkId = true, + bool includeMoods = true, + bool includeIsrcs = true, bool includeContributors = true, bool includeRatings = true) { @@ -84,16 +102,16 @@ public class AddTrackRequestFixture includePath ? path ?? Path.Combine(Path.GetTempPath(), "lumina-tracks", _faker.System.FileName()) : null, includeMetadata ? metadata ?? _audioMetadataDtoFixture.Create() : null, includeTrackNumber ? trackNumber ?? _faker.Random.Int(1, 30) : null, - includeOptionalProperties ? discNumber ?? _faker.Random.Int(1, 3) : null, - includeOptionalProperties ? script ?? _faker.Random.AlphaNumeric(4) : null, - includeOptionalProperties ? key ?? _faker.PickRandom() : null, - includeOptionalProperties ? bpm ?? _faker.Random.Int(40, 220) : null, - includeOptionalProperties ? work ?? _faker.Lorem.Sentence() : null, - includeOptionalProperties ? musicBrainzRecordingId ?? _faker.Random.Guid() : null, - includeOptionalProperties ? musicBrainzTrackId ?? _faker.Random.Guid() : null, - includeOptionalProperties ? musicBrainzWorkId ?? _faker.Random.Guid() : null, - includeOptionalProperties ? moods ?? _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null, - includeOptionalProperties ? isrcs ?? _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : 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, + 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, includeRatings ? ratings ?? _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null); } diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestFixture.cs index 8a37b112..f73927dd 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestFixture.cs @@ -49,7 +49,16 @@ public class UpdateTrackRequestFixture /// Optional. The ISRC codes of the track. /// Optional. The media contributors that performed on the track. /// Optional. The ratings of the track. - /// Whether the optional properties that are not explicitly provided should be randomized, or forced to . + /// Whether the disc number should be included, or forced to . + /// Whether the script should be included, or forced to . + /// Whether the musical key should be included, or forced to . + /// Whether the tempo should be included, or forced to . + /// 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 list should be included, or forced to . /// Whether the ratings list should be included, or forced to . /// Whether the path should be included, or forced to . @@ -72,7 +81,16 @@ public class UpdateTrackRequestFixture List? isrcs = null, List? contributors = null, List? ratings = null, - bool includeOptionalProperties = true, + bool includeDiscNumber = true, + bool includeScript = true, + bool includeKey = true, + bool includeBpm = true, + bool includeWork = true, + bool includeMusicBrainzRecordingId = true, + bool includeMusicBrainzTrackId = true, + bool includeMusicBrainzWorkId = true, + bool includeMoods = true, + bool includeIsrcs = true, bool includeContributors = true, bool includeRatings = true, bool includePath = true, @@ -83,16 +101,16 @@ public class UpdateTrackRequestFixture includePath ? (path ?? _faker.System.FilePath()) : null, includeMetadata ? (metadata ?? _audioMetadataDtoFixture.Create()) : null, includeTrackNumber ? (trackNumber ?? _faker.Random.Int(1, 20)) : null, - includeOptionalProperties ? (discNumber ?? _faker.Random.Int(1, 3)) : null, - includeOptionalProperties ? (script ?? _faker.Random.String2(_faker.Random.Number(1, 50))) : null, - includeOptionalProperties ? (key ?? _faker.PickRandom()) : null, - includeOptionalProperties ? (bpm ?? _faker.Random.Int(40, 240)) : null, - includeOptionalProperties ? (work ?? _faker.Music.Genre()) : null, - includeOptionalProperties ? (musicBrainzRecordingId ?? _faker.Random.Guid()) : null, - includeOptionalProperties ? (musicBrainzTrackId ?? _faker.Random.Guid()) : null, - includeOptionalProperties ? (musicBrainzWorkId ?? _faker.Random.Guid()) : null, - includeOptionalProperties ? (moods ?? [.. _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null, - includeOptionalProperties ? (isrcs ?? [.. _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : 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, + 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, includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null); } diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestFixture.cs index a7799e10..6b632386 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestFixture.cs @@ -49,7 +49,21 @@ public class AddBookRequestFixture /// Optional. The ISBNs of the book. /// Optional. The contributors of the book. /// Optional. The ratings of the book. - /// Whether the properties that are not explicitly provided should be randomized, or forced to . + /// Whether the format should be included, or forced to . + /// Whether the edition should be included, or forced to . + /// Whether the volume number should be included, or forced to . + /// Whether the ASIN should be included, or forced to . + /// Whether the Goodreads Id should be included, or forced to . + /// Whether the LCCN should be included, or forced to . + /// Whether the OCLC number should be included, or forced to . + /// Whether the Open Library Id should be included, or forced to . + /// Whether the LibraryThing Id should be included, or forced to . + /// Whether the Google Books Id should be included, or forced to . + /// Whether the Barnes and Noble Id should be included, or forced to . + /// Whether the Apple Books Id should be included, or forced to . + /// Whether the ISBNs should be included, or forced to . + /// Whether the ratings should be included, or forced to . + /// Whether the contributors should be included, or forced to . /// The created request to add a book. public AddBookRequest Create( string? path = null, @@ -70,7 +84,21 @@ public class AddBookRequestFixture List? isbns = null, List? contributors = null, List? ratings = null, - bool includeOptionalProperties = true) + bool includeFormat = true, + bool includeEdition = true, + bool includeVolumeNumber = true, + bool includeAsin = true, + bool includeGoodreadsId = true, + bool includeLccn = true, + bool includeOclcNumber = true, + bool includeOpenLibraryId = true, + bool includeLibraryThingId = true, + bool includeGoogleBooksId = true, + bool includeBarnesAndNobleId = true, + bool includeAppleBooksId = true, + bool includeIsbns = true, + bool includeRatings = true, + bool includeContributors = true) { return new Faker() .CustomInstantiator(f => new AddBookRequest( @@ -95,22 +123,22 @@ public class AddBookRequestFixture )) .RuleFor(x => x.Path, f => path ?? Path.Combine(Path.GetTempPath(), "lumina-books", f.System.FileName())) .RuleFor(x => x.Metadata, metadata ?? _writtenContentMetadataDtoFixture.Create()) - .RuleFor(x => x.Format, f => format ?? (includeOptionalProperties ? f.PickRandom() : null)) - .RuleFor(x => x.Edition, f => edition ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null)) - .RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeOptionalProperties ? (float?)f.Random.Number(1, 3) : null)) + .RuleFor(x => x.Format, f => format ?? (includeFormat ? f.PickRandom() : null)) + .RuleFor(x => x.Edition, f => edition ?? (includeEdition ? f.Random.String2(f.Random.Number(1, 50)) : null)) + .RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeVolumeNumber ? (float?)f.Random.Number(1, 3) : null)) .RuleFor(x => x.Series, series) - .RuleFor(x => x.ASIN, f => asin ?? (includeOptionalProperties ? f.Random.String2(10) : null)) - .RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeOptionalProperties ? f.Random.Number(100000, 500000).ToString() : null)) - .RuleFor(x => x.LCCN, f => lccn ?? (includeOptionalProperties ? CreateLccn(f) : null)) - .RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOptionalProperties ? CreateOclcNumber(f) : null)) - .RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOptionalProperties ? CreateOpenLibraryId(f) : null)) - .RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null)) - .RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeOptionalProperties ? CreateGoogleBooksId(f) : null)) - .RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeOptionalProperties ? f.Random.String2(10, "0123456789") : null)) - .RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeOptionalProperties ? $"id{f.Random.Number(1, 999999)}" : null)) - .RuleFor(p => p.ISBNs, f => isbns ?? (includeOptionalProperties ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)) - .RuleFor(p => p.Ratings, f => ratings ?? (includeOptionalProperties ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)) - .RuleFor(x => x.Contributors, f => contributors ?? (includeOptionalProperties ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)); + .RuleFor(x => x.ASIN, f => asin ?? (includeAsin ? f.Random.String2(10) : null)) + .RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeGoodreadsId ? f.Random.Number(100000, 500000).ToString() : null)) + .RuleFor(x => x.LCCN, f => lccn ?? (includeLccn ? CreateLccn(f) : null)) + .RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOclcNumber ? CreateOclcNumber(f) : null)) + .RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOpenLibraryId ? CreateOpenLibraryId(f) : null)) + .RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeLibraryThingId ? f.Random.String2(f.Random.Number(1, 50)) : null)) + .RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeGoogleBooksId ? CreateGoogleBooksId(f) : null)) + .RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeBarnesAndNobleId ? f.Random.String2(10, "0123456789") : null)) + .RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeAppleBooksId ? $"id{f.Random.Number(1, 999999)}" : null)) + .RuleFor(p => p.ISBNs, f => isbns ?? (includeIsbns ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)) + .RuleFor(p => p.Ratings, f => ratings ?? (includeRatings ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)) + .RuleFor(x => x.Contributors, f => contributors ?? (includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)); } /// diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/UpdateBookRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/UpdateBookRequestFixture.cs index 637549a0..9b5047d0 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/UpdateBookRequestFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/UpdateBookRequestFixture.cs @@ -47,7 +47,21 @@ public class UpdateBookRequestFixture /// Optional. The ISBNs of the book. /// Optional. The contributors of the book. /// Optional. The ratings of the book. - /// Whether the properties that are not explicitly provided should be randomized, or forced to . + /// Whether the format should be included, or forced to . + /// Whether the edition should be included, or forced to . + /// Whether the volume number should be included, or forced to . + /// Whether the ASIN should be included, or forced to . + /// Whether the Goodreads Id should be included, or forced to . + /// Whether the LCCN should be included, or forced to . + /// Whether the OCLC number should be included, or forced to . + /// Whether the Open Library Id should be included, or forced to . + /// Whether the LibraryThing Id should be included, or forced to . + /// Whether the Google Books Id should be included, or forced to . + /// Whether the Barnes and Noble Id should be included, or forced to . + /// Whether the Apple Books Id should be included, or forced to . + /// Whether the ISBNs should be included, or forced to . + /// Whether the ratings should be included, or forced to . + /// Whether the contributors should be included, or forced to . /// The created request to update a book. public UpdateBookRequest Create( WrittenContentMetadataDto? metadata = null, @@ -67,7 +81,21 @@ public class UpdateBookRequestFixture List? isbns = null, List? contributors = null, List? ratings = null, - bool includeOptionalProperties = true) + bool includeFormat = true, + bool includeEdition = true, + bool includeVolumeNumber = true, + bool includeAsin = true, + bool includeGoodreadsId = true, + bool includeLccn = true, + bool includeOclcNumber = true, + bool includeOpenLibraryId = true, + bool includeLibraryThingId = true, + bool includeGoogleBooksId = true, + bool includeBarnesAndNobleId = true, + bool includeAppleBooksId = true, + bool includeIsbns = true, + bool includeRatings = true, + bool includeContributors = true) { return new Faker() .CustomInstantiator(f => new UpdateBookRequest( @@ -90,22 +118,22 @@ public class UpdateBookRequestFixture default! )) .RuleFor(x => x.Metadata, metadata ?? _writtenContentMetadataDtoFixture.Create()) - .RuleFor(x => x.Format, f => format ?? (includeOptionalProperties ? f.PickRandom() : null)) - .RuleFor(x => x.Edition, f => edition ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null)) - .RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeOptionalProperties ? (float?)f.Random.Number(1, 3) : null)) + .RuleFor(x => x.Format, f => format ?? (includeFormat ? f.PickRandom() : null)) + .RuleFor(x => x.Edition, f => edition ?? (includeEdition ? f.Random.String2(f.Random.Number(1, 50)) : null)) + .RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeVolumeNumber ? (float?)f.Random.Number(1, 3) : null)) .RuleFor(x => x.Series, series) - .RuleFor(x => x.ASIN, f => asin ?? (includeOptionalProperties ? f.Random.String2(10) : null)) - .RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeOptionalProperties ? f.Random.Number(100000, 500000).ToString() : null)) - .RuleFor(x => x.LCCN, f => lccn ?? (includeOptionalProperties ? CreateLccn(f) : null)) - .RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOptionalProperties ? CreateOclcNumber(f) : null)) - .RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOptionalProperties ? CreateOpenLibraryId(f) : null)) - .RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null)) - .RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeOptionalProperties ? CreateGoogleBooksId(f) : null)) - .RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeOptionalProperties ? f.Random.String2(10, "0123456789") : null)) - .RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeOptionalProperties ? $"id{f.Random.Number(1, 999999)}" : null)) - .RuleFor(p => p.ISBNs, f => isbns ?? (includeOptionalProperties ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)) - .RuleFor(p => p.Ratings, f => ratings ?? (includeOptionalProperties ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)) - .RuleFor(x => x.Contributors, f => contributors ?? (includeOptionalProperties ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)); + .RuleFor(x => x.ASIN, f => asin ?? (includeAsin ? f.Random.String2(10) : null)) + .RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeGoodreadsId ? f.Random.Number(100000, 500000).ToString() : null)) + .RuleFor(x => x.LCCN, f => lccn ?? (includeLccn ? CreateLccn(f) : null)) + .RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOclcNumber ? CreateOclcNumber(f) : null)) + .RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOpenLibraryId ? CreateOpenLibraryId(f) : null)) + .RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeLibraryThingId ? f.Random.String2(f.Random.Number(1, 50)) : null)) + .RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeGoogleBooksId ? CreateGoogleBooksId(f) : null)) + .RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeBarnesAndNobleId ? f.Random.String2(10, "0123456789") : null)) + .RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeAppleBooksId ? $"id{f.Random.Number(1, 999999)}" : null)) + .RuleFor(p => p.ISBNs, f => isbns ?? (includeIsbns ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)) + .RuleFor(p => p.Ratings, f => ratings ?? (includeRatings ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)) + .RuleFor(x => x.Contributors, f => contributors ?? (includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)); } /// diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Themes/ThemeResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Themes/ThemeResponseFixture.cs index 5913454b..dddf632f 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Themes/ThemeResponseFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Themes/ThemeResponseFixture.cs @@ -28,12 +28,12 @@ public class ThemeResponseFixture /// Optional. The author of the theme. /// Optional. The version of the theme. /// Optional. The preview image path of the theme, or when the theme has no preview. - /// Whether the preview path should be included, or forced to . /// Optional. The source the theme was installed from. /// Optional. Whether the theme is the currently active one. - /// Whether the currently active flag should be included, or forced to . /// Optional. The UTC timestamp when the theme was installed. /// Optional. Whether the theme was deleted by the user. + /// Whether the preview path should be included, or forced to . + /// Whether the currently active flag should be included, or forced to . /// The created . public ThemeResponse Create( Guid? id = null, @@ -43,12 +43,12 @@ public class ThemeResponseFixture string? author = null, string? version = null, string? previewPath = null, - bool includePreviewPath = false, ThemeInstallSource? installSource = null, bool? isCurrent = null, - bool includeIsCurrent = false, DateTime? installedAtUtc = null, - bool? isDeleted = null) + bool? isDeleted = null, + bool includePreviewPath = false, + bool includeIsCurrent = false) { return new ThemeResponse( id ?? Guid.NewGuid(), diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/LibraryFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/LibraryFixture.cs index 851203db..9dfa2bee 100644 --- a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/LibraryFixture.cs +++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/LibraryFixture.cs @@ -23,7 +23,6 @@ namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedCo public class LibraryFixture { private readonly Faker _faker = new(); - private readonly Random _random = new(); private readonly LibraryIdFixture _libraryIdFixture = new(); private readonly UserIdFixture _userIdFixture = new(); private readonly ScanIdFixture _scanIdFixture = new(); @@ -37,13 +36,13 @@ public class LibraryFixture /// Optional. The library type. /// Optional. The content locations of the library. /// Optional. The cover image of the library. - /// Whether the cover image should be included, or left unset, meaning the library has no cover. /// Whether the library is enabled. /// Whether the library is locked. /// Whether metadata download from the web is enabled. /// Whether metadata should be saved in the media directories. /// Whether unchanged directories should be skipped during scan. /// Optional. The scan Ids associated with the library. + /// Whether the cover image should be included, or left unset, meaning the library has no cover. /// The created . public Library Create( Guid? id = null, @@ -52,13 +51,13 @@ public class LibraryFixture LibraryType? libraryType = null, IEnumerable? contentLocations = null, string? coverImage = null, - bool includeCoverImage = true, bool isEnabled = true, bool isLocked = false, bool canDownloadMetadataFromWeb = true, bool shouldSaveMetadataInMediaDirectories = false, bool shouldSkipUnchangedDirectoriesDuringScan = false, - IEnumerable? scanIds = null) + IEnumerable? scanIds = null, + bool includeCoverImage = true) { List validPaths = [ @@ -77,7 +76,7 @@ public class LibraryFixture resolvedUserId, title ?? _faker.Random.String2(_faker.Random.Number(1, 50)), libraryType ?? _faker.PickRandom(), - contentLocations ?? validPaths.Take(_random.Next(1, validPaths.Count)), + contentLocations ?? validPaths.Take(Random.Shared.Next(1, validPaths.Count)), Optional.FromNullable(resolvedCoverImage), isEnabled, isLocked, @@ -91,7 +90,7 @@ public class LibraryFixture resolvedUserId, title ?? _faker.Random.String2(_faker.Random.Number(1, 50)), libraryType ?? _faker.PickRandom(), - contentLocations ?? validPaths.Take(_random.Next(1, validPaths.Count)), + contentLocations ?? validPaths.Take(Random.Shared.Next(1, validPaths.Count)), Optional.FromNullable(resolvedCoverImage), isEnabled, isLocked, diff --git a/tests/Common/Lumina.Infrastructure.Fixtures/Core/Themes/ThemePackFixture.cs b/tests/Common/Lumina.Infrastructure.Fixtures/Core/Themes/ThemePackFixture.cs index 9347f4b9..a4002f41 100644 --- a/tests/Common/Lumina.Infrastructure.Fixtures/Core/Themes/ThemePackFixture.cs +++ b/tests/Common/Lumina.Infrastructure.Fixtures/Core/Themes/ThemePackFixture.cs @@ -28,8 +28,8 @@ public sealed class ThemePackFixture /// Optional template mappings written to the manifest. /// Optional preview path written to the manifest, or to omit the preview. /// Optional content for the default template file. - /// Whether to include the preview asset file in the archive or not. /// Optional additional files written into the archive. + /// Whether to include the preview asset file in the archive or not. /// The created theme pack ZIP archive. public byte[] Create( string themeId = "test-theme", @@ -41,8 +41,8 @@ public sealed class ThemePackFixture Dictionary? templates = null, string? preview = "assets/preview.png", string? defaultTemplateContent = null, - bool includePreviewAsset = true, - IReadOnlyDictionary? additionalFiles = null) + IReadOnlyDictionary? additionalFiles = null, + bool includePreviewAsset = true) { Dictionary manifestTemplates = templates ?? new Dictionary(StringComparer.OrdinalIgnoreCase) { diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeNavEntryDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeNavEntryDtoFixture.cs index bf3edb3c..662a3cec 100644 --- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeNavEntryDtoFixture.cs +++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeNavEntryDtoFixture.cs @@ -21,18 +21,18 @@ public class ThemeNavEntryDtoFixture /// /// Optional label of the entry. /// Optional URL of the link, or for a submenu. - /// Whether the URL should be included, or forced to . /// Optional CSS classes of the link. - /// Whether the CSS class should be included, or forced to . /// Optional child links of a submenu. + /// Whether the URL should be included, or forced to . + /// Whether the CSS class should be included, or forced to . /// The created . public ThemeNavEntryDto Create( string? label = null, string? url = null, - bool includeUrl = false, string? cssClass = null, - bool includeCssClass = false, - IReadOnlyList? children = null) + IReadOnlyList? children = null, + bool includeUrl = false, + bool includeCssClass = false) { return new ThemeNavEntryDto( Label: label ?? _faker.Lorem.Word(), diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeResponseDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeResponseDtoFixture.cs index 14ec2131..8cf8b0bb 100644 --- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeResponseDtoFixture.cs +++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeResponseDtoFixture.cs @@ -28,12 +28,12 @@ public class ThemeResponseDtoFixture /// Optional author of the theme. /// Optional semantic version of the theme. /// Optional preview image path of the theme, or when the theme has no preview. - /// Whether the preview path should be included, or forced to . /// Optional source the theme was installed from. /// Optional value indicating whether the theme is the active one. - /// Whether the currently active flag should be included, or forced to . /// Optional UTC timestamp at which the theme was installed. /// Optional value indicating whether the theme was deleted by the user. + /// Whether the preview path should be included, or forced to . + /// Whether the currently active flag should be included, or forced to . /// A configured instance. public ThemeResponseDto Create( Guid? id = null, @@ -43,12 +43,12 @@ public class ThemeResponseDtoFixture string? author = null, string? version = null, string? previewPath = null, - bool includePreviewPath = false, ThemeInstallSource? installSource = null, bool? isCurrent = null, - bool includeIsCurrent = false, DateTime? installedAtUtc = null, - bool? isDeleted = null) + bool? isDeleted = null, + bool includePreviewPath = false, + bool includeIsCurrent = false) { return new ThemeResponseDto( Id: id ?? Guid.NewGuid(), diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Library/WrittenContentLibrary/BookLibrary/Books/UpdateBookRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Library/WrittenContentLibrary/BookLibrary/Books/UpdateBookRequestFixture.cs index ba22b06e..7e0dac00 100644 --- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Library/WrittenContentLibrary/BookLibrary/Books/UpdateBookRequestFixture.cs +++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Library/WrittenContentLibrary/BookLibrary/Books/UpdateBookRequestFixture.cs @@ -33,35 +33,67 @@ public class UpdateBookRequestFixture /// Optional Id of the book to update. /// Optional Id of the media library the book belongs to. /// Optional written content metadata of the book. - /// Whether the properties that are not explicitly provided should be randomized, or forced to . + /// Whether the metadata should be included, or forced to . + /// Whether the format should be included, or forced to . + /// Whether the edition should be included, or forced to . + /// Whether the volume number should be included, or forced to . + /// Whether the series should be included, or forced to . + /// Whether the ASIN should be included, or forced to . + /// Whether the Goodreads Id should be included, or forced to . + /// Whether the LCCN should be included, or forced to . + /// Whether the OCLC number should be included, or forced to . + /// Whether the Open Library Id should be included, or forced to . + /// Whether the LibraryThing Id should be included, or forced to . + /// Whether the Google Books Id should be included, or forced to . + /// Whether the Barnes and Noble Id should be included, or forced to . + /// Whether the Apple Books Id should be included, or forced to . + /// Whether the ISBNs should be included, or forced to . + /// Whether the contributors should be included, or forced to . + /// Whether the ratings should be included, or forced to . /// A configured instance. public UpdateBookRequest Create( Guid? id = null, Guid? libraryId = null, WrittenContentMetadataDto? metadata = null, - bool includeOptionalProperties = true) + bool includeMetadata = true, + bool includeFormat = true, + bool includeEdition = true, + bool includeVolumeNumber = true, + bool includeSeries = true, + bool includeAsin = true, + bool includeGoodreadsId = true, + bool includeLccn = true, + bool includeOclcNumber = true, + bool includeOpenLibraryId = true, + bool includeLibraryThingId = true, + bool includeGoogleBooksId = true, + bool includeBarnesAndNobleId = true, + bool includeAppleBooksId = true, + bool includeIsbns = true, + bool includeContributors = true, + bool includeRatings = true) { return new UpdateBookRequest { BookId = id?.ToString() ?? Guid.NewGuid().ToString(), LibraryId = libraryId ?? Guid.NewGuid(), - Metadata = metadata ?? (includeOptionalProperties ? _writtenContentMetadataDtoFixture.Create() : null), - Format = includeOptionalProperties ? _faker.PickRandom() : null, - Edition = includeOptionalProperties ? _faker.Random.String2(_faker.Random.Number(1, 50)) : null, - VolumeNumber = includeOptionalProperties ? _faker.Random.Number(1, 3) : null, - Series = includeOptionalProperties ? _bookSeriesDtoFixture.Create() : null, - ASIN = includeOptionalProperties ? _faker.Random.String2(10) : null, - GoodreadsId = includeOptionalProperties ? _faker.Random.Number(100000, 500000).ToString() : null, - LCCN = includeOptionalProperties ? "n78890351" : null, - OCLCNumber = includeOptionalProperties ? "ocm12345678" : null, - OpenLibraryId = includeOptionalProperties ? "OL123456M" : null, - LibraryThingId = includeOptionalProperties ? _faker.Random.String2(_faker.Random.Number(1, 50)) : null, - GoogleBooksId = includeOptionalProperties ? CreateGoogleBooksId() : null, - BarnesAndNobleId = includeOptionalProperties ? _faker.Random.String2(10, "0123456789") : null, - AppleBooksId = includeOptionalProperties ? $"id{_faker.Random.Number(1, 999999)}" : null, - ISBNs = includeOptionalProperties ? [.. _isbnDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null, - Contributors = includeOptionalProperties ? [.. _mediaContributorDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null, - Ratings = includeOptionalProperties ? [.. _bookRatingDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null + Metadata = includeMetadata ? (metadata ?? _writtenContentMetadataDtoFixture.Create()) : null, + Format = includeFormat ? _faker.PickRandom() : null, + Edition = includeEdition ? _faker.Random.String2(_faker.Random.Number(1, 50)) : null, + VolumeNumber = includeVolumeNumber ? _faker.Random.Number(1, 3) : null, + Series = includeSeries ? _bookSeriesDtoFixture.Create() : null, + ASIN = includeAsin ? _faker.Random.String2(10) : null, + GoodreadsId = includeGoodreadsId ? _faker.Random.Number(100000, 500000).ToString() : null, + LCCN = includeLccn ? "n78890351" : null, + OCLCNumber = includeOclcNumber ? "ocm12345678" : null, + OpenLibraryId = includeOpenLibraryId ? "OL123456M" : null, + LibraryThingId = includeLibraryThingId ? _faker.Random.String2(_faker.Random.Number(1, 50)) : null, + GoogleBooksId = includeGoogleBooksId ? CreateGoogleBooksId() : null, + BarnesAndNobleId = includeBarnesAndNobleId ? _faker.Random.String2(10, "0123456789") : null, + AppleBooksId = includeAppleBooksId ? $"id{_faker.Random.Number(1, 999999)}" : null, + ISBNs = includeIsbns ? [.. _isbnDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null, + Contributors = includeContributors ? [.. _mediaContributorDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null, + Ratings = includeRatings ? [.. _bookRatingDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null }; } diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointTests.cs index 8b9f479d..2d3cff6f 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointTests.cs @@ -121,7 +121,14 @@ public class UpdateTrackEndpointTests : IClassFixture? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); Assert.NotNull(problemDetails); - Assert.Equal(422, problemDetails!["status"].GetInt32()); + Assert.Equal((int)HttpStatusCode.UnprocessableEntity, problemDetails!["status"].GetInt32()); Assert.Equal("General.Validation", problemDetails["title"].GetString()); Assert.Equal("OneOrMoreValidationErrorsOccurred", problemDetails["detail"].GetString()); diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpointTests.cs index c26b1b1e..5b2b614f 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpointTests.cs @@ -702,7 +702,7 @@ public class AddBookEndpointTests : IClassFixture public async Task AddBook_WhenCalledWithEmptyFormat_ShouldAddBook() { // Arrange - AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); + AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false); // Act & Assert await AssertCreated(bookRequest); @@ -725,7 +725,7 @@ public class AddBookEndpointTests : IClassFixture public async Task AddBook_WhenCalledWithEmptyEdition_ShouldAddBook() { // Arrange - AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); + AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false); // Act & Assert await AssertCreated(bookRequest); @@ -748,7 +748,7 @@ public class AddBookEndpointTests : IClassFixture public async Task AddBook_WhenCalledWithEmptyVolumeNumber_ShouldAddBook() { // Arrange - AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); + AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false); // Act & Assert await AssertCreated(bookRequest); @@ -812,7 +812,7 @@ public class AddBookEndpointTests : IClassFixture public async Task AddBook_WhenCalledWithEmptyAsin_ShouldAddBook() { // Arrange - AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); + AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false); // Act & Assert await AssertCreated(bookRequest); @@ -835,7 +835,7 @@ public class AddBookEndpointTests : IClassFixture public async Task AddBook_WhenCalledWithEmptyGoodreadsId_ShouldAddBook() { // Arrange - AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); + AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false); // Act & Assert await AssertCreated(bookRequest); @@ -858,7 +858,7 @@ public class AddBookEndpointTests : IClassFixture public async Task AddBook_WhenCalledWithEmptyLccn_ShouldAddBook() { // Arrange - AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); + AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false); // Act & Assert await AssertCreated(bookRequest); @@ -881,7 +881,7 @@ public class AddBookEndpointTests : IClassFixture public async Task AddBook_WhenCalledWithEmptyOclcNumber_ShouldAddBook() { // Arrange - AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); + AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false); // Act & Assert await AssertCreated(bookRequest); @@ -904,7 +904,7 @@ public class AddBookEndpointTests : IClassFixture public async Task AddBook_WhenCalledWithEmptyOpenLibraryId_ShouldAddBook() { // Arrange - AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); + AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false); // Act & Assert await AssertCreated(bookRequest); @@ -927,7 +927,7 @@ public class AddBookEndpointTests : IClassFixture public async Task AddBook_WhenCalledWithEmptyLibraryThingId_ShouldAddBook() { // Arrange - AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); + AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false); // Act & Assert await AssertCreated(bookRequest); @@ -950,7 +950,7 @@ public class AddBookEndpointTests : IClassFixture public async Task AddBook_WhenCalledWithEmptyGoogleBooksId_ShouldAddBook() { // Arrange - AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); + AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false); // Act & Assert await AssertCreated(bookRequest); @@ -986,7 +986,7 @@ public class AddBookEndpointTests : IClassFixture public async Task AddBook_WhenCalledWithEmptyBarnesAndNobleId_ShouldAddBook() { // Arrange - AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); + AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false); // Act & Assert await AssertCreated(bookRequest); @@ -1022,7 +1022,7 @@ public class AddBookEndpointTests : IClassFixture public async Task AddBook_WhenCalledWithEmptyAppleBooksId_ShouldAddBook() { // Arrange - AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); + AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false); // Act & Assert await AssertCreated(bookRequest); @@ -1045,7 +1045,7 @@ public class AddBookEndpointTests : IClassFixture public async Task AddBook_WhenCalledWithNullIsbns_ShouldReturnUnprocessableEntity() { // Arrange - AddBookRequest bookRequest = _requestBookFixture.Create(includeOptionalProperties: false); + AddBookRequest bookRequest = _requestBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act HttpResponseMessage response = await PostBookAsync(bookRequest); @@ -1148,7 +1148,7 @@ public class AddBookEndpointTests : IClassFixture public async Task AddBook_WhenCalledWithNullRatings_ShouldReturnUnprocessableEntity() { // Arrange - AddBookRequest bookRequest = _requestBookFixture.Create(includeOptionalProperties: false); + AddBookRequest bookRequest = _requestBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act HttpResponseMessage response = await PostBookAsync(bookRequest); @@ -1197,7 +1197,7 @@ public class AddBookEndpointTests : IClassFixture public async Task AddBook_WhenCalledWithEmptyRatingVoteCount_ShouldAddBook() { // Arrange - AddBookRequest bookRequest = _requestBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(source: BookRatingSource.Goodreads, includeOptionalProperties: false)]); + AddBookRequest bookRequest = _requestBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(source: BookRatingSource.Goodreads, includeVoteCount: false)]); // Act & Assert await AssertCreated(bookRequest); } @@ -1838,7 +1838,7 @@ public class AddBookEndpointTests : IClassFixture private async Task AssertUnprocessableEntityWithValidationErrors(HttpResponseMessage response, params string[] expectedErrorCodes) { - Assert.Equal(HttpStatusCode.UnprocessableContent, response.StatusCode); + Assert.Equal(HttpStatusCode.UnprocessableEntity, response.StatusCode); Assert.Equal("application/problem+json", response.Content.Headers.ContentType?.MediaType); string content = await response.Content.ReadAsStringAsync(); diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/UpdateBook/UpdateBookEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/UpdateBook/UpdateBookEndpointTests.cs index 93692ab9..41887801 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/UpdateBook/UpdateBookEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/UpdateBook/UpdateBookEndpointTests.cs @@ -92,7 +92,7 @@ public class UpdateBookEndpointTests : IClassFixture(); - List links = dbContext.Books + List links = [.. dbContext.Books .Include(book => book.Contributors) .Single(book => book.Id == bookId) - .Contributors - .ToList(); + .Contributors]; Assert.Equal(2, links.Count); Assert.All(links, link => Assert.Equal(contributorId, link.MediaContributorId)); Assert.Contains(links, link => link.Role == MediaContributorRole.Author); @@ -1563,7 +1562,7 @@ public class UpdateBookEndpointTests : IClassFixture? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); Assert.NotNull(problemDetails); - Assert.Equal(422, problemDetails!["status"].GetInt32()); + Assert.Equal((int)HttpStatusCode.UnprocessableEntity, problemDetails!["status"].GetInt32()); Assert.Equal("General.Validation", problemDetails["title"].GetString()); Assert.Equal("OneOrMoreValidationErrorsOccurred", problemDetails["detail"].GetString()); @@ -1937,4 +1936,4 @@ public class UpdateBookEndpointTests : IClassFixture result = command.ToDomainEntity(artist); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestMappingTests.cs index 3eef412f..22308dc6 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestMappingTests.cs @@ -63,7 +63,19 @@ public class UpdateTrackRequestMappingTests Guid artistId = Guid.NewGuid(); Guid albumId = Guid.NewGuid(); Guid trackId = Guid.NewGuid(); - UpdateTrackRequest request = _updateTrackRequestFixture.Create(includeOptionalProperties: false, contributors: [], ratings: []); + UpdateTrackRequest request = _updateTrackRequestFixture.Create( + includeDiscNumber: false, + includeScript: false, + includeKey: false, + includeBpm: false, + includeWork: false, + includeMusicBrainzRecordingId: false, + includeMusicBrainzTrackId: false, + includeMusicBrainzWorkId: false, + includeMoods: false, + includeIsrcs: false, + contributors: [], + ratings: []); // Act UpdateTrackCommand result = request.ToCommand(libraryId.ToString(), artistId.ToString(), albumId.ToString(), trackId.ToString()); @@ -103,7 +115,14 @@ public class UpdateTrackRequestMappingTests isrcs: [new("GBUM71029604")], contributors: [new(Guid.NewGuid(), MediaContributorRole.Vocals)], ratings: [new(4.5m, 5m, AudioRatingSource.MusicBrainz, 1000)], - includeOptionalProperties: false); + includeDiscNumber: false, + includeScript: false, + includeKey: false, + includeBpm: false, + includeWork: false, + includeMusicBrainzRecordingId: false, + includeMusicBrainzTrackId: false, + includeMusicBrainzWorkId: false); // Act UpdateTrackCommand result = request.ToCommand(libraryId.ToString(), artistId.ToString(), albumId.ToString(), trackId.ToString()); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookCommandMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookCommandMappingTests.cs index 9488c229..6c82f2ca 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookCommandMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookCommandMappingTests.cs @@ -62,7 +62,18 @@ public class AddBookCommandMappingTests isbns: [], contributors: [], ratings: [], - includeOptionalProperties: false); + includeFormat: false, + includeEdition: false, + includeVolumeNumber: false, + includeAsin: false, + includeGoodreadsId: false, + includeLccn: false, + includeOclcNumber: false, + includeOpenLibraryId: false, + includeLibraryThingId: false, + includeGoogleBooksId: false, + includeBarnesAndNobleId: false, + includeAppleBooksId: false); // Act Result result = command.ToDomainEntity(libraryId); @@ -92,7 +103,7 @@ public class AddBookCommandMappingTests public void ToDomainEntity_WhenRatingCreationFails_ShouldReturnError() { // Arrange - AddBookCommand command = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeOptionalProperties: false)]); + AddBookCommand command = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeSource: false, includeVoteCount: false)]); // Act Result result = command.ToDomainEntity(Guid.NewGuid()); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestMappingTests.cs index d16264e3..09d0264e 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestMappingTests.cs @@ -64,7 +64,21 @@ public class AddBookRequestMappingTests AddBookRequest request = _requestFixture.Create( path: "/books/test.epub", metadata: _writtenContentMetadataDtoFixture.Create(title: "Test Book"), - includeOptionalProperties: false + includeFormat: false, + includeEdition: false, + includeVolumeNumber: false, + includeAsin: false, + includeGoodreadsId: false, + includeLccn: false, + includeOclcNumber: false, + includeOpenLibraryId: false, + includeLibraryThingId: false, + includeGoogleBooksId: false, + includeBarnesAndNobleId: false, + includeAppleBooksId: false, + includeIsbns: false, + includeRatings: false, + includeContributors: false ); // Act @@ -105,7 +119,18 @@ public class AddBookRequestMappingTests _mediaContributorReferenceDtoFixture.Create(role: MediaContributorRole.Author) ], ratings: [new(4.5m, 5m, BookRatingSource.Goodreads, 1000)], - includeOptionalProperties: false + includeFormat: false, + includeEdition: false, + includeVolumeNumber: false, + includeAsin: false, + includeGoodreadsId: false, + includeLccn: false, + includeOclcNumber: false, + includeOpenLibraryId: false, + includeLibraryThingId: false, + includeGoogleBooksId: false, + includeBarnesAndNobleId: false, + includeAppleBooksId: false ); // Act diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMetadataDtoMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMetadataDtoMappingTests.cs index 060a79dd..40e5383a 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMetadataDtoMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMetadataDtoMappingTests.cs @@ -24,6 +24,7 @@ public class BookMetadataDtoMappingTests private readonly BookFixture _bookFixture = new(); private readonly BookMetadataDtoFixture _bookMetadataDtoFixture = new(); private readonly GenreDtoFixture _genreDtoFixture = new(); + private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new(); [Fact] public void ApplyMetadata_WhenCalledWithValidMetadata_ShouldApplyItToTheBook() @@ -76,7 +77,7 @@ public class BookMetadataDtoMappingTests { // Arrange Book book = _bookFixture.Create(); - BookMetadataDto metadata = _bookMetadataDtoFixture.Create(title: title, includeOptionalProperties: false); + BookMetadataDto metadata = _bookMetadataDtoFixture.Create(includeTitle: title is not null, title: title, includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false); // Act Result result = book.ApplyMetadata(metadata); @@ -91,7 +92,7 @@ public class BookMetadataDtoMappingTests { // Arrange Book book = _bookFixture.Create(); - BookMetadataDto metadata = _bookMetadataDtoFixture.Create(title: "A valid title", includeOptionalProperties: false); + BookMetadataDto metadata = _bookMetadataDtoFixture.Create(title: "A valid title", includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false); // Act Result result = book.ApplyMetadata(metadata); @@ -108,7 +109,7 @@ public class BookMetadataDtoMappingTests Book book = _bookFixture.Create(); BookMetadataDto metadata = _bookMetadataDtoFixture.Create( title: "A valid title", - releaseInfo: new ReleaseInfoDto(new DateOnly(2000, 1, 1), 1999, null, null, null, null)); + releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseDate: new DateOnly(2000, 1, 1), originalReleaseYear: 1999)); // Act Result result = book.ApplyMetadata(metadata); @@ -173,8 +174,12 @@ public class BookMetadataDtoMappingTests Book book = _bookFixture.Create(); BookMetadataDto metadata = _bookMetadataDtoFixture.Create( title: "A valid title", - releaseInfo: new ReleaseInfoDto(new DateOnly(2000, 1, 1), 2000, null, null, null, null), - includeOptionalProperties: false); + releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseDate: new DateOnly(2000, 1, 1), originalReleaseYear: 2000), + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false); // Act Result result = book.ApplyMetadata(metadata); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/UpdateBookCommandMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/UpdateBookCommandMappingTests.cs index 645c70f1..c89839e2 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/UpdateBookCommandMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/UpdateBookCommandMappingTests.cs @@ -72,7 +72,18 @@ public class UpdateBookCommandMappingTests isbns: [], contributors: [], ratings: [], - includeOptionalProperties: false); + includeFormat: false, + includeEdition: false, + includeVolumeNumber: false, + includeAsin: false, + includeGoodreadsId: false, + includeLccn: false, + includeOclcNumber: false, + includeOpenLibraryId: false, + includeLibraryThingId: false, + includeGoogleBooksId: false, + includeBarnesAndNobleId: false, + includeAppleBooksId: false); BookEntity existingBook = _bookEntityFixture.Create(id: bookId, libraryId: libraryId, path: "/books/the-book.epub"); // Act @@ -104,7 +115,7 @@ public class UpdateBookCommandMappingTests public void ToDomainEntity_WhenRatingCreationFails_ShouldReturnError() { // Arrange - UpdateBookCommand command = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeOptionalProperties: false)]); + UpdateBookCommand command = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeSource: false, includeVoteCount: false)]); BookEntity existingBook = _bookEntityFixture.Create(); // Act diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/UpdateBookRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/UpdateBookRequestMappingTests.cs index 11bd4200..0b3a9bf8 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/UpdateBookRequestMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/UpdateBookRequestMappingTests.cs @@ -61,7 +61,7 @@ public class UpdateBookRequestMappingTests // Arrange Guid libraryId = Guid.NewGuid(); Guid bookId = Guid.NewGuid(); - UpdateBookRequest request = _requestFixture.Create(includeOptionalProperties: false); + UpdateBookRequest request = _requestFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act UpdateBookCommand result = request.ToCommand(libraryId.ToString(), bookId.ToString()); @@ -102,7 +102,18 @@ public class UpdateBookRequestMappingTests _mediaContributorReferenceDtoFixture.Create(role: MediaContributorRole.Author) ], ratings: [new(4.5m, 5m, BookRatingSource.Goodreads, 1000)], - includeOptionalProperties: false + includeFormat: false, + includeEdition: false, + includeVolumeNumber: false, + includeAsin: false, + includeGoodreadsId: false, + includeLccn: false, + includeOclcNumber: false, + includeOpenLibraryId: false, + includeLibraryThingId: false, + includeGoogleBooksId: false, + includeBarnesAndNobleId: false, + includeAppleBooksId: false ); // Act @@ -119,7 +130,7 @@ public class UpdateBookRequestMappingTests public void ToCommand_WhenRouteValuesAreNotParseable_ShouldMapThemAsIs() { // Arrange - UpdateBookRequest request = _requestFixture.Create(includeOptionalProperties: false); + UpdateBookRequest request = _requestFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act UpdateBookCommand result = request.ToCommand("not-a-library-guid", "not-a-guid"); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingDtoMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingDtoMappingTests.cs index fe558119..d859ed13 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingDtoMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingDtoMappingTests.cs @@ -56,7 +56,7 @@ public class BookRatingDtoMappingTests public void ToDomainEntity_WhenMappingMinimalBookRatingDto_ShouldMapRequiredPropertiesCorrectly() { // Arrange - BookRatingDto dto = _bookRatingDtoFixture.Create(includeOptionalProperties: false); + BookRatingDto dto = _bookRatingDtoFixture.Create(includeSource: false, includeVoteCount: false); // Act Result result = dto.ToDomainEntity(); @@ -90,7 +90,7 @@ public class BookRatingDtoMappingTests List dtos = [ _bookRatingDtoFixture.Create(), - _bookRatingDtoFixture.Create(includeOptionalProperties: false) + _bookRatingDtoFixture.Create(includeSource: false, includeVoteCount: false) ]; // Act @@ -125,7 +125,7 @@ public class BookRatingDtoMappingTests [ _bookRatingDtoFixture.Create(), _bookRatingDtoFixture.Create(value: 10, maxValue: 5), - _bookRatingDtoFixture.Create(includeOptionalProperties: false) + _bookRatingDtoFixture.Create(includeSource: false, includeVoteCount: false) ]; // Act 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 1cf77f2d..0c14b1e1 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 @@ -419,7 +419,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenOriginalReleaseYearIsLessThan1_ShouldHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(metadata: _audioMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, 0, null, null, null, null))); + AddTrackCommand command = _addTrackCommandFixture.Create(metadata: _audioMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseYear: 0))); // Act List result = _validator.TestValidate(command); @@ -432,7 +432,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenOriginalReleaseYearIsGreaterThan9999_ShouldHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(metadata: _audioMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, 10000, null, null, null, null))); + AddTrackCommand command = _addTrackCommandFixture.Create(metadata: _audioMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseYear: 10000))); // Act List result = _validator.TestValidate(command); @@ -458,7 +458,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenReReleaseYearIsLessThan1_ShouldHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(metadata: _audioMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, null, null, 0, null, null))); + AddTrackCommand command = _addTrackCommandFixture.Create(metadata: _audioMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(reReleaseYear: 0))); // Act List result = _validator.TestValidate(command); @@ -471,7 +471,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenReReleaseYearIsGreaterThan9999_ShouldHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(metadata: _audioMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, null, null, 10000, null, null))); + AddTrackCommand command = _addTrackCommandFixture.Create(metadata: _audioMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(reReleaseYear: 10000))); // Act List result = _validator.TestValidate(command); @@ -943,7 +943,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenMusicBrainzRecordingIdIsNull_ShouldNotHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(includeOptionalProperties: false); + AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1054,7 +1054,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenDiscNumberIsNull_ShouldNotHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(includeOptionalProperties: false); + AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1093,7 +1093,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenScriptIsNull_ShouldNotHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(includeOptionalProperties: false); + AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1132,7 +1132,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenKeyIsNull_ShouldNotHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(includeOptionalProperties: false); + AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1173,7 +1173,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenBpmIsNull_ShouldNotHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(includeOptionalProperties: false); + AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1212,7 +1212,7 @@ public class AddTrackCommandValidatorTests public void Validate_WhenWorkIsNull_ShouldNotHaveValidationError() { // Arrange - AddTrackCommand command = _addTrackCommandFixture.Create(includeOptionalProperties: false); + AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); // 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 af6d0392..5af646ad 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 @@ -1175,7 +1175,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenMusicBrainzRecordingIdIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeOptionalProperties: false); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1214,7 +1214,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenMusicBrainzTrackIdIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeOptionalProperties: false); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1253,7 +1253,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenMusicBrainzWorkIdIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeOptionalProperties: false); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1357,7 +1357,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenDiscNumberIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeOptionalProperties: false); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1396,7 +1396,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenScriptIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeOptionalProperties: false); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1435,7 +1435,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenKeyIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeOptionalProperties: false); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1487,7 +1487,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenBpmIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeOptionalProperties: false); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); @@ -1526,7 +1526,7 @@ public class UpdateTrackCommandValidatorTests public void Validate_WhenWorkIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeOptionalProperties: false); + UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false); // Act List result = _validator.TestValidate(command); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/AddBook/AddBookCommandHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/AddBook/AddBookCommandHandlerTests.cs index c795635f..f2c3dfa9 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/AddBook/AddBookCommandHandlerTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/AddBook/AddBookCommandHandlerTests.cs @@ -226,7 +226,7 @@ public class AddBookCommandHandlerTests public async Task HandleAsync_WhenCalledWithInvalidRating_ShouldReturnFailureResult() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeOptionalProperties: false)]); + AddBookCommand bookCommand = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeSource: false, includeVoteCount: false)]); // Act Result result = await _sut.HandleAsync(bookCommand, CancellationToken.None); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/AddBook/AddBookCommandValidatorTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/AddBook/AddBookCommandValidatorTests.cs index 6f2c0b09..49af0de5 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/AddBook/AddBookCommandValidatorTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/AddBook/AddBookCommandValidatorTests.cs @@ -210,7 +210,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenOriginalReleaseYearIsLessThan1_ShouldHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, 0, null, null, null, null))); + AddBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseYear: 0))); // Act List result = _validator.TestValidate(bookCommand); @@ -223,7 +223,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenOriginalReleaseYearIsGreaterThan9999_ShouldHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, 10000, null, null, null, null))); + AddBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseYear: 10000))); // Act List result = _validator.TestValidate(bookCommand); @@ -249,7 +249,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenReReleaseYearIsLessThan1_ShouldHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, null, null, 0, null, null))); + AddBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(reReleaseYear: 0))); // Act List result = _validator.TestValidate(bookCommand); @@ -262,7 +262,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenReReleaseYearIsGreaterThan9999_ShouldHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, null, null, 10000, null, null))); + AddBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(reReleaseYear: 10000))); // Act List result = _validator.TestValidate(bookCommand); @@ -756,7 +756,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenFormatIsNull_ShouldNotHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -795,7 +795,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenEditionIsNull_ShouldNotHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -834,7 +834,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenVolumeNumberIsNull_ShouldNotHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -954,7 +954,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenAsinIsNull_ShouldNotHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -980,7 +980,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenGoodreadsIdIsNull_ShouldNotHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1045,7 +1045,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenLccnIsNull_ShouldNotHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1110,7 +1110,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenCalledWithEmptyOclcNumber_ShouldNotHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1201,7 +1201,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenOpenLibraryIdIsNull_ShouldNotHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1266,7 +1266,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenCalledWithEmptyLibraryThingId_ShouldNotHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1305,7 +1305,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenCalledWithEmptyGoogleBooksId_ShouldNotHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1357,7 +1357,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenCalledWithEmptyBarnesAndNobleId_ShouldNotHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1409,7 +1409,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenCalledWithEmptyAppleBooksId_ShouldNotHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1448,7 +1448,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenCalledWithNullIsbns_ShouldHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1591,7 +1591,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenCalledWithNullRatings_ShouldHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1669,7 +1669,7 @@ public class AddBookCommandValidatorTests public void Validate_WhenCalledWithNullVoteCount_ShouldNotHaveValidationError() { // Arrange - AddBookCommand bookCommand = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(includeOptionalProperties: false)]); + AddBookCommand bookCommand = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(includeSource: false, includeVoteCount: false)]); // Act List result = _validator.TestValidate(bookCommand); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/UpdateBook/UpdateBookCommandHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/UpdateBook/UpdateBookCommandHandlerTests.cs index 365ad36a..c7eb1b3e 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/UpdateBook/UpdateBookCommandHandlerTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/UpdateBook/UpdateBookCommandHandlerTests.cs @@ -343,7 +343,7 @@ public class UpdateBookCommandHandlerTests public async Task HandleAsync_WhenCalledWithInvalidRating_ShouldReturnFailureResult() { // Arrange - UpdateBookCommand command = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeOptionalProperties: false)]); + UpdateBookCommand command = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeSource: false, includeVoteCount: false)]); BookEntity existingBook = _bookEntityFixture.Create(id: Guid.Parse(command.BookId!), libraryId: Guid.Parse(command.LibraryId!)); _mockBookRepository.GetByIdAsync(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any()) .Returns(Result.From(existingBook)); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/UpdateBook/UpdateBookCommandValidatorTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/UpdateBook/UpdateBookCommandValidatorTests.cs index 519307e6..7f8efc2a 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/UpdateBook/UpdateBookCommandValidatorTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/Commands/UpdateBook/UpdateBookCommandValidatorTests.cs @@ -197,7 +197,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenOriginalReleaseYearIsLessThan1_ShouldHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, 0, null, null, null, null))); + UpdateBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseYear: 0))); // Act List result = _validator.TestValidate(bookCommand); @@ -210,7 +210,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenOriginalReleaseYearIsGreaterThan9999_ShouldHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, 10000, null, null, null, null))); + UpdateBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseYear: 10000))); // Act List result = _validator.TestValidate(bookCommand); @@ -236,7 +236,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenReReleaseYearIsLessThan1_ShouldHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, null, null, 0, null, null))); + UpdateBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(reReleaseYear: 0))); // Act List result = _validator.TestValidate(bookCommand); @@ -249,7 +249,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenReReleaseYearIsGreaterThan9999_ShouldHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, null, null, 10000, null, null))); + UpdateBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(reReleaseYear: 10000))); // Act List result = _validator.TestValidate(bookCommand); @@ -743,7 +743,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenFormatIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -782,7 +782,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenEditionIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -821,7 +821,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenVolumeNumberIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -941,7 +941,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenAsinIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -967,7 +967,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenGoodreadsIdIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1032,7 +1032,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenLccnIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1097,7 +1097,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenCalledWithEmptyOclcNumber_ShouldNotHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1188,7 +1188,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenOpenLibraryIdIsNull_ShouldNotHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1253,7 +1253,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenCalledWithEmptyLibraryThingId_ShouldNotHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1292,7 +1292,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenCalledWithEmptyGoogleBooksId_ShouldNotHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1344,7 +1344,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenCalledWithEmptyBarnesAndNobleId_ShouldNotHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1396,7 +1396,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenCalledWithEmptyAppleBooksId_ShouldNotHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1435,7 +1435,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenCalledWithNullIsbns_ShouldHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1578,7 +1578,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenCalledWithNullRatings_ShouldHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); + UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false); // Act List result = _validator.TestValidate(bookCommand); @@ -1656,7 +1656,7 @@ public class UpdateBookCommandValidatorTests public void Validate_WhenCalledWithNullVoteCount_ShouldNotHaveValidationError() { // Arrange - UpdateBookCommand bookCommand = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(includeOptionalProperties: false)]); + UpdateBookCommand bookCommand = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(includeSource: false, includeVoteCount: false)]); // Act List result = _validator.TestValidate(bookCommand); diff --git a/tests/UnitTests/Lumina.Contracts.UnitTests/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingDtoTests.cs b/tests/UnitTests/Lumina.Contracts.UnitTests/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingDtoTests.cs index 84259d28..c4807b7b 100644 --- a/tests/UnitTests/Lumina.Contracts.UnitTests/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingDtoTests.cs +++ b/tests/UnitTests/Lumina.Contracts.UnitTests/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingDtoTests.cs @@ -20,7 +20,7 @@ public class BookRatingDtoTests public void Create_WhenOmittingOptionalProperties_ShouldReturnNullSourceAndVoteCount() { // Act - BookRatingDto sut = _bookRatingDtoFixture.Create(includeOptionalProperties: false); + BookRatingDto sut = _bookRatingDtoFixture.Create(includeSource: false, includeVoteCount: false); // Assert Assert.Null(sut.Source); diff --git a/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Metadata/MetadataAggregatorTests.cs b/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Metadata/MetadataAggregatorTests.cs index 878dc592..4a80ac70 100644 --- a/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Metadata/MetadataAggregatorTests.cs +++ b/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BookLibrary/Metadata/MetadataAggregatorTests.cs @@ -32,7 +32,11 @@ public class MetadataAggregatorTests public void Merge_WhenBothMetadataHaveScalarValues_ShouldKeepTheFirstValues() { // Arrange - BookMetadataDto first = _bookMetadataDtoFixture.Create(includeOptionalProperties: false, + BookMetadataDto first = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, title: "First Title", originalTitle: "First Original Title", description: "First Description", @@ -51,7 +55,11 @@ public class MetadataAggregatorTests barnesAndNobleId: "FIRST-BN", appleBooksId: "FIRST-APPLE", coverImagePath: "First Cover"); - BookMetadataDto second = _bookMetadataDtoFixture.Create(includeOptionalProperties: false, + BookMetadataDto second = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, title: "Second Title", originalTitle: "Second Original Title", description: "Second Description", @@ -99,8 +107,29 @@ public class MetadataAggregatorTests public void Merge_WhenFirstHasNullScalars_ShouldFallBackToTheSecondValues() { // Arrange - BookMetadataDto first = _bookMetadataDtoFixture.Create(includeOptionalProperties: false, title: null, description: null, publisher: null, pageCount: null); - BookMetadataDto second = _bookMetadataDtoFixture.Create(includeOptionalProperties: false, title: "Second Title", description: "Second Description", publisher: "Second Publisher", pageCount: 200); + BookMetadataDto first = _bookMetadataDtoFixture.Create( + includeTitle: false, + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: null, + description: null, + publisher: null, + pageCount: null); + BookMetadataDto second = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Second Title", + description: "Second Description", + publisher: "Second Publisher", + pageCount: 200); // Act BookMetadataDto result = MetadataAggregator.Merge(first, second); @@ -116,8 +145,26 @@ public class MetadataAggregatorTests public void Merge_WhenBothHaveNullScalars_ShouldReturnNullScalars() { // Arrange - BookMetadataDto first = _bookMetadataDtoFixture.Create(includeOptionalProperties: false, title: null, coverImagePath: null); - BookMetadataDto second = _bookMetadataDtoFixture.Create(includeOptionalProperties: false, title: null, coverImagePath: null); + BookMetadataDto first = _bookMetadataDtoFixture.Create( + includeTitle: false, + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: null, + coverImagePath: null); + BookMetadataDto second = _bookMetadataDtoFixture.Create( + includeTitle: false, + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: null, + coverImagePath: null); // Act BookMetadataDto result = MetadataAggregator.Merge(first, second); @@ -137,10 +184,24 @@ public class MetadataAggregatorTests public void Merge_WhenBothHaveReleaseInfo_ShouldCoalesceEachField() { // Arrange - BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false); - BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false); - first = first with { ReleaseInfo = _releaseInfoDtoFixture.Create(originalReleaseDate: new DateOnly(2001, 1, 1), originalReleaseYear: 2001, releaseCountry: ReleaseCountry.US) }; - second = second with { ReleaseInfo = _releaseInfoDtoFixture.Create(reReleaseDate: new DateOnly(2010, 5, 5), reReleaseYear: 2010, releaseCountry: ReleaseCountry.GB, releaseVersion: "2.0") }; + BookMetadataDto first = _bookMetadataDtoFixture.Create( + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseDate: new DateOnly(2001, 1, 1), originalReleaseYear: 2001, releaseCountry: ReleaseCountry.US)); + BookMetadataDto second = _bookMetadataDtoFixture.Create( + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + releaseInfo: _releaseInfoDtoFixture.Create(reReleaseDate: new DateOnly(2010, 5, 5), reReleaseYear: 2010, releaseCountry: ReleaseCountry.GB, releaseVersion: "2.0")); // Act BookMetadataDto result = MetadataAggregator.Merge(first, second); @@ -158,8 +219,24 @@ public class MetadataAggregatorTests public void Merge_WhenFirstReleaseInfoIsNull_ShouldUseTheSecondReleaseInfo() { // Arrange - BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { ReleaseInfo = null }; - BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { ReleaseInfo = _releaseInfoDtoFixture.Create(originalReleaseDate: new DateOnly(2001, 1, 1), originalReleaseYear: 2001) }; + BookMetadataDto first = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover"); + BookMetadataDto second = _bookMetadataDtoFixture.Create( + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseDate: new DateOnly(2001, 1, 1), originalReleaseYear: 2001)); // Act BookMetadataDto result = MetadataAggregator.Merge(first, second); @@ -172,8 +249,24 @@ public class MetadataAggregatorTests public void Merge_WhenBothReleaseInfosAreNull_ShouldReturnNullReleaseInfo() { // Arrange - BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { ReleaseInfo = null }; - BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { ReleaseInfo = null }; + BookMetadataDto first = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover"); + BookMetadataDto second = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover"); // Act BookMetadataDto result = MetadataAggregator.Merge(first, second); @@ -186,8 +279,24 @@ public class MetadataAggregatorTests public void Merge_WhenBothHaveGenres_ShouldUnionAndDeDuplicateByName() { // Arrange - BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Genres = [_genreDtoFixture.Create(name: "Science fiction"), _genreDtoFixture.Create(name: "Space opera")] }; - BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Genres = [_genreDtoFixture.Create(name: "Science fiction"), _genreDtoFixture.Create(name: "Fantasy")] }; + BookMetadataDto first = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + genres: [_genreDtoFixture.Create(name: "Science fiction"), _genreDtoFixture.Create(name: "Space opera")]); + BookMetadataDto second = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + genres: [_genreDtoFixture.Create(name: "Science fiction"), _genreDtoFixture.Create(name: "Fantasy")]); // Act BookMetadataDto result = MetadataAggregator.Merge(first, second); @@ -203,8 +312,24 @@ public class MetadataAggregatorTests public void Merge_WhenBothHaveTags_ShouldUnionAndDeDuplicateByName() { // Arrange - BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = [_tagDtoFixture.Create(name: "Tag A"), _tagDtoFixture.Create(name: "Tag B")] }; - BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = [_tagDtoFixture.Create(name: "Tag A"), _tagDtoFixture.Create(name: "Tag C")] }; + BookMetadataDto first = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + tags: [_tagDtoFixture.Create(name: "Tag A"), _tagDtoFixture.Create(name: "Tag B")]); + BookMetadataDto second = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + tags: [_tagDtoFixture.Create(name: "Tag A"), _tagDtoFixture.Create(name: "Tag C")]); // Act BookMetadataDto result = MetadataAggregator.Merge(first, second); @@ -220,8 +345,26 @@ public class MetadataAggregatorTests public void Merge_WhenBothHaveIsbns_ShouldUnionAndDeDuplicateByValue() { // Arrange - BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Isbns = [_isbnDtoFixture.Create(value: "9780306406157", format: IsbnFormat.Isbn13)] }; - BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Isbns = [_isbnDtoFixture.Create(value: "9780306406157", format: IsbnFormat.Isbn13), _isbnDtoFixture.Create(value: "0306406152", format: IsbnFormat.Isbn10)] }; + BookMetadataDto first = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + isbns: [_isbnDtoFixture.Create(value: "9780306406157", format: IsbnFormat.Isbn13)]); + BookMetadataDto second = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + isbns: [_isbnDtoFixture.Create(value: "9780306406157", format: IsbnFormat.Isbn13), _isbnDtoFixture.Create(value: "0306406152", format: IsbnFormat.Isbn10)]); // Act BookMetadataDto result = MetadataAggregator.Merge(first, second); @@ -236,8 +379,26 @@ public class MetadataAggregatorTests public void Merge_WhenBothHaveContributors_ShouldUnionAndDeDuplicateByDisplayNameAndRole() { // Arrange - BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Contributors = [_mediaContributorDtoFixture.Create("Author A", MediaContributorRole.Author)] }; - BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Contributors = [_mediaContributorDtoFixture.Create("Author A", MediaContributorRole.Author), _mediaContributorDtoFixture.Create("Translator B", MediaContributorRole.Translator)] }; + BookMetadataDto first = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + contributors: [_mediaContributorDtoFixture.Create("Author A", MediaContributorRole.Author)]); + BookMetadataDto second = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + contributors: [_mediaContributorDtoFixture.Create("Author A", MediaContributorRole.Author), _mediaContributorDtoFixture.Create("Translator B", MediaContributorRole.Translator)]); // Act BookMetadataDto result = MetadataAggregator.Merge(first, second); @@ -252,8 +413,26 @@ public class MetadataAggregatorTests public void Merge_WhenBothHaveRatings_ShouldUnionAndDeDuplicateBySource() { // Arrange - BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Ratings = [_bookRatingDtoFixture.Create(value: 8m, maxValue: 10m, source: BookRatingSource.Calibre, voteCount: null)] }; - BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Ratings = [_bookRatingDtoFixture.Create(value: 8m, maxValue: 10m, source: BookRatingSource.Calibre, voteCount: null), _bookRatingDtoFixture.Create(value: 4.2m, maxValue: 5m, source: BookRatingSource.OpenLibrary, voteCount: 100)] }; + BookMetadataDto first = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + ratings: [_bookRatingDtoFixture.Create(value: 8m, maxValue: 10m, source: BookRatingSource.Calibre, voteCount: null)]); + BookMetadataDto second = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + ratings: [_bookRatingDtoFixture.Create(value: 8m, maxValue: 10m, source: BookRatingSource.Calibre, voteCount: null), _bookRatingDtoFixture.Create(value: 4.2m, maxValue: 5m, source: BookRatingSource.OpenLibrary, voteCount: 100)]); // Act BookMetadataDto result = MetadataAggregator.Merge(first, second); @@ -268,8 +447,27 @@ public class MetadataAggregatorTests public void Merge_WhenOnlyFirstHasCollections_ShouldReturnTheFirstCollections() { // Arrange - BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = [_tagDtoFixture.Create(name: "Tag A")], Genres = [_genreDtoFixture.Create(name: "Genre A")], Isbns = [_isbnDtoFixture.Create(value: "9780306406157", format: IsbnFormat.Isbn13)], Contributors = [_mediaContributorDtoFixture.Create("Author A", MediaContributorRole.Author)], Ratings = [_bookRatingDtoFixture.Create(value: 8m, maxValue: 10m, source: BookRatingSource.Calibre, voteCount: null)] }; - BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = null, Genres = null, Isbns = null, Contributors = null, Ratings = null }; + BookMetadataDto first = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + tags: [_tagDtoFixture.Create(name: "Tag A")], + genres: [_genreDtoFixture.Create(name: "Genre A")], + isbns: [_isbnDtoFixture.Create(value: "9780306406157", format: IsbnFormat.Isbn13)], + contributors: [_mediaContributorDtoFixture.Create("Author A", MediaContributorRole.Author)], + ratings: [_bookRatingDtoFixture.Create(value: 8m, maxValue: 10m, source: BookRatingSource.Calibre, voteCount: null)]); + BookMetadataDto second = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover"); // Act BookMetadataDto result = MetadataAggregator.Merge(first, second); @@ -286,8 +484,27 @@ public class MetadataAggregatorTests public void Merge_WhenOnlySecondHasCollections_ShouldReturnTheSecondCollections() { // Arrange - BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = null, Genres = null, Isbns = null, Contributors = null, Ratings = null }; - BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = [_tagDtoFixture.Create(name: "Tag B")], Genres = [_genreDtoFixture.Create(name: "Genre B")], Isbns = [_isbnDtoFixture.Create(value: "0306406152", format: IsbnFormat.Isbn10)], Contributors = [_mediaContributorDtoFixture.Create("Author B", MediaContributorRole.Author)], Ratings = [_bookRatingDtoFixture.Create(value: 4.2m, maxValue: 5m, source: BookRatingSource.OpenLibrary, voteCount: 100)] }; + BookMetadataDto first = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover"); + BookMetadataDto second = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + tags: [_tagDtoFixture.Create(name: "Tag B")], + genres: [_genreDtoFixture.Create(name: "Genre B")], + isbns: [_isbnDtoFixture.Create(value: "0306406152", format: IsbnFormat.Isbn10)], + contributors: [_mediaContributorDtoFixture.Create("Author B", MediaContributorRole.Author)], + ratings: [_bookRatingDtoFixture.Create(value: 4.2m, maxValue: 5m, source: BookRatingSource.OpenLibrary, voteCount: 100)]); // Act BookMetadataDto result = MetadataAggregator.Merge(first, second); @@ -304,8 +521,24 @@ public class MetadataAggregatorTests public void Merge_WhenBothHaveNullCollections_ShouldReturnNullCollections() { // Arrange - BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = null, Genres = null, Isbns = null, Contributors = null, Ratings = null }; - BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = null, Genres = null, Isbns = null, Contributors = null, Ratings = null }; + BookMetadataDto first = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover"); + BookMetadataDto second = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeLanguage: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover"); // Act BookMetadataDto result = MetadataAggregator.Merge(first, second); @@ -322,8 +555,24 @@ public class MetadataAggregatorTests public void Merge_WhenBothHaveLanguages_ShouldKeepTheFirstLanguage() { // Arrange - BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Language = _languageInfoDtoFixture.Create(languageCode: "en", languageName: "English", nativeName: "English") }; - BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Language = _languageInfoDtoFixture.Create(languageCode: "de", languageName: "German", nativeName: "Deutsch") }; + BookMetadataDto first = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + language: _languageInfoDtoFixture.Create(languageCode: "en", languageName: "English", nativeName: "English")); + BookMetadataDto second = _bookMetadataDtoFixture.Create( + includeReleaseInfo: false, + includeGenres: false, + includeTags: false, + includeFormat: false, + includeVolumeNumber: false, + title: "Title", + coverImagePath: "First Cover", + language: _languageInfoDtoFixture.Create(languageCode: "de", languageName: "German", nativeName: "Deutsch")); // Act BookMetadataDto result = MetadataAggregator.Merge(first, second); diff --git a/tests/UnitTests/Lumina.Plugins.Contracts.UnitTests/Core/Metadata/IMetadataProviderGenericTests.cs b/tests/UnitTests/Lumina.Plugins.Contracts.UnitTests/Core/Metadata/IMetadataProviderGenericTests.cs index 6411a257..d6413507 100644 --- a/tests/UnitTests/Lumina.Plugins.Contracts.UnitTests/Core/Metadata/IMetadataProviderGenericTests.cs +++ b/tests/UnitTests/Lumina.Plugins.Contracts.UnitTests/Core/Metadata/IMetadataProviderGenericTests.cs @@ -30,7 +30,7 @@ public class IMetadataProviderGenericTests // Arrange BookMetadataLookupDto lookup = _bookMetadataLookupDtoFixture.Create(); CancellationToken cancellationToken = CancellationToken.None; - BookMetadataDto expectedMetadata = _bookMetadataDtoFixture.Create(title: "Search Result", includeOptionalProperties: false); + BookMetadataDto expectedMetadata = _bookMetadataDtoFixture.Create(title: "Search Result", includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false); TestBookMetadataProvider provider = new(expectedMetadata); IMetadataProvider baseProvider = provider; @@ -50,7 +50,7 @@ public class IMetadataProviderGenericTests // Arrange BookMetadataLookupDto lookup = _bookMetadataLookupDtoFixture.Create(); CancellationToken cancellationToken = CancellationToken.None; - BookMetadataDto expectedMetadata = _bookMetadataDtoFixture.Create(title: "Exact Result", includeOptionalProperties: false); + BookMetadataDto expectedMetadata = _bookMetadataDtoFixture.Create(title: "Exact Result", includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false); TestBookMetadataProvider provider = new(expectedMetadata); IMetadataProvider baseProvider = provider; @@ -68,7 +68,7 @@ public class IMetadataProviderGenericTests { // Arrange MetadataLookupDto otherLookup = _otherMetadataLookupDtoFixture.Create(); - TestBookMetadataProvider provider = new(_bookMetadataDtoFixture.Create(title: "Search Result", includeOptionalProperties: false)); + TestBookMetadataProvider provider = new(_bookMetadataDtoFixture.Create(title: "Search Result", includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false)); IMetadataProvider baseProvider = provider; // Act @@ -87,7 +87,7 @@ public class IMetadataProviderGenericTests { // Arrange MetadataLookupDto otherLookup = _otherMetadataLookupDtoFixture.Create(); - TestBookMetadataProvider provider = new(_bookMetadataDtoFixture.Create(title: "Exact Result", includeOptionalProperties: false)); + TestBookMetadataProvider provider = new(_bookMetadataDtoFixture.Create(title: "Exact Result", includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false)); IMetadataProvider baseProvider = provider; // Act