From e139a7bb00e996d486a57f767884000fdfa07f25 Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Sat, 10 Oct 2026 13:05:00 +0300 Subject: [PATCH] Adds the should aggregate artwork when missing setting to the user settings, configuration, and validation --- .../DTO/Configuration/MediaSettingsDto.cs | 5 ++ .../Users/UpdateUserSettingsRequestMapping.cs | 1 + .../Users/UserSettingsEntityMapping.cs | 2 + .../Users/UserSettingsMapping.cs | 2 + .../UpdateUserSettingsCommand.cs | 2 + .../UpdateUserSettingsCommandHandler.cs | 2 + .../Settings/UpdateUserSettingsRequest.cs | 2 + .../Settings/UserSettingsResponse.cs | 2 + .../UserSettingsAggregate/UserSettings.cs | 21 ++++++++- .../Common/Errors/Errors.Configuration.cs | 1 + .../Validators/MediaSettingsDtoValidator.cs | 4 ++ .../appsettings.shared.json | 3 +- .../Configuration/MediaSettingsDtoFixture.cs | 7 ++- .../UpdateUserSettingsCommandFixture.cs | 5 +- .../UpdateUserSettingsRequestFixture.cs | 3 ++ .../Settings/UserSettingsResponseFixture.cs | 3 ++ .../UserSettingsFixture.cs | 3 ++ .../UpdateUserSettingsRequestMappingTests.cs | 4 +- .../UserSettingsTests.cs | 12 ++--- .../Validation/ValidationOptionsTests.cs | 9 ++-- .../Validation/ValidationOptionsTests.cs | 47 +++++++++---------- 21 files changed, 97 insertions(+), 43 deletions(-) diff --git a/src/Lumina.Application/Common/Infrastructure/Models/DTO/Configuration/MediaSettingsDto.cs b/src/Lumina.Application/Common/Infrastructure/Models/DTO/Configuration/MediaSettingsDto.cs index c77c25f4..67fa84a6 100644 --- a/src/Lumina.Application/Common/Infrastructure/Models/DTO/Configuration/MediaSettingsDto.cs +++ b/src/Lumina.Application/Common/Infrastructure/Models/DTO/Configuration/MediaSettingsDto.cs @@ -26,4 +26,9 @@ public class MediaSettingsDto /// Gets or sets the directory where the media item files are stored. /// public required string BooksDirectory { get; init; } + + /// + /// Gets or sets the directory where the music library item files are stored. + /// + public required string MusicDirectory { get; init; } } diff --git a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UpdateUserSettingsRequestMapping.cs b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UpdateUserSettingsRequestMapping.cs index e4c9c955..a936d1b2 100644 --- a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UpdateUserSettingsRequestMapping.cs +++ b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UpdateUserSettingsRequestMapping.cs @@ -23,6 +23,7 @@ public static class UpdateUserSettingsRequestMapping request.ShouldIgnoreThePrefixForAlphaPicker, request.IsThemeCachingEnabled, request.ShouldAggregateMetadataWhenMissing, + request.ShouldAggregateArtworkWhenMissing, request.ShouldRenderPdfAsImages, request.ShouldPreserveBookStyles ); diff --git a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsEntityMapping.cs b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsEntityMapping.cs index f556846c..4da52a6f 100644 --- a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsEntityMapping.cs +++ b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsEntityMapping.cs @@ -31,6 +31,7 @@ public static class UserSettingsEntityMapping repositoryEntity.ShouldIgnoreThePrefixForAlphaPicker, repositoryEntity.IsThemeCachingEnabled, repositoryEntity.ShouldAggregateMetadataWhenMissing, + repositoryEntity.ShouldAggregateArtworkWhenMissing, repositoryEntity.ShouldRenderPdfAsImages, repositoryEntity.ShouldPreserveBookStyles ); @@ -50,6 +51,7 @@ public static class UserSettingsEntityMapping repositoryEntity.ShouldIgnoreThePrefixForAlphaPicker, repositoryEntity.IsThemeCachingEnabled, repositoryEntity.ShouldAggregateMetadataWhenMissing, + repositoryEntity.ShouldAggregateArtworkWhenMissing, repositoryEntity.ShouldRenderPdfAsImages, repositoryEntity.ShouldPreserveBookStyles ); diff --git a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsMapping.cs b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsMapping.cs index 01c0e99a..aabba107 100644 --- a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsMapping.cs +++ b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsMapping.cs @@ -27,6 +27,7 @@ public static class UserSettingsMapping ShouldIgnoreThePrefixForAlphaPicker = domainEntity.ShouldIgnoreThePrefixForAlphaPicker, IsThemeCachingEnabled = domainEntity.IsThemeCachingEnabled, ShouldAggregateMetadataWhenMissing = domainEntity.ShouldAggregateMetadataWhenMissing, + ShouldAggregateArtworkWhenMissing = domainEntity.ShouldAggregateArtworkWhenMissing, ShouldRenderPdfAsImages = domainEntity.ShouldRenderPdfAsImages, ShouldPreserveBookStyles = domainEntity.ShouldPreserveBookStyles }; @@ -46,6 +47,7 @@ public static class UserSettingsMapping domainEntity.ShouldIgnoreThePrefixForAlphaPicker, domainEntity.IsThemeCachingEnabled, domainEntity.ShouldAggregateMetadataWhenMissing, + domainEntity.ShouldAggregateArtworkWhenMissing, domainEntity.ShouldRenderPdfAsImages, domainEntity.ShouldPreserveBookStyles ); diff --git a/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommand.cs b/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommand.cs index 44a547f4..7dbaa12e 100644 --- a/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommand.cs +++ b/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommand.cs @@ -12,6 +12,7 @@ namespace Lumina.Application.Core.UsersManagement.Settings.Commands.UpdateUserSe /// Whether the "The" prefix of library item titles is ignored by the alpha picker, or not. /// Whether the theme data served to this user is cached, or not. /// Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not. +/// Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not. /// Whether PDF books are rendered as page images for the user, or not. /// Whether the styles of the book content are preserved when it is rendered for the user, or not. public record UpdateUserSettingsCommand( @@ -20,6 +21,7 @@ public record UpdateUserSettingsCommand( bool ShouldIgnoreThePrefixForAlphaPicker, bool IsThemeCachingEnabled, bool ShouldAggregateMetadataWhenMissing, + bool ShouldAggregateArtworkWhenMissing, bool ShouldRenderPdfAsImages, bool ShouldPreserveBookStyles ) : ICommand; diff --git a/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandHandler.cs b/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandHandler.cs index af92e828..73317f73 100644 --- a/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandHandler.cs +++ b/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandHandler.cs @@ -74,6 +74,7 @@ public class UpdateUserSettingsCommandHandler : ICommandHandlerWhether the "The" prefix of library item titles is ignored by the alpha picker, or not. Required. /// Whether the theme data served to this user is cached, or not. Required. /// Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not. Required. +/// Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not. Required. /// Whether PDF books are rendered as page images for the user, or not. Required. /// Whether the styles of the book content are preserved when it is rendered for the user, or not. Required. [DebuggerDisplay("IsPaginationEnabled: {IsPaginationEnabled}; ItemsPerPage: {ItemsPerPage}")] @@ -21,6 +22,7 @@ public sealed record UpdateUserSettingsRequest( bool ShouldIgnoreThePrefixForAlphaPicker, bool IsThemeCachingEnabled, bool ShouldAggregateMetadataWhenMissing, + bool ShouldAggregateArtworkWhenMissing, bool ShouldRenderPdfAsImages, bool ShouldPreserveBookStyles ); diff --git a/src/Lumina.Contracts/Responses/UsersManagement/Settings/UserSettingsResponse.cs b/src/Lumina.Contracts/Responses/UsersManagement/Settings/UserSettingsResponse.cs index 0db9b39e..11bdbf60 100644 --- a/src/Lumina.Contracts/Responses/UsersManagement/Settings/UserSettingsResponse.cs +++ b/src/Lumina.Contracts/Responses/UsersManagement/Settings/UserSettingsResponse.cs @@ -14,6 +14,7 @@ namespace Lumina.Contracts.Responses.UsersManagement.Settings; /// Whether the "The" prefix of library item titles is ignored by the alpha picker, or not. /// Whether the theme data served to this user is cached, or not. /// Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not. +/// Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not. /// Whether PDF books are rendered as page images for the user, or not. /// Whether the styles of the book content are preserved when it is rendered for the user, or not. [DebuggerDisplay("UserId: {UserId}")] @@ -24,6 +25,7 @@ public sealed record UserSettingsResponse( bool ShouldIgnoreThePrefixForAlphaPicker, bool IsThemeCachingEnabled, bool ShouldAggregateMetadataWhenMissing, + bool ShouldAggregateArtworkWhenMissing, bool ShouldRenderPdfAsImages, bool ShouldPreserveBookStyles ); diff --git a/src/Lumina.Domain/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettings.cs b/src/Lumina.Domain/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettings.cs index 067f3f0a..59f22083 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettings.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettings.cs @@ -20,6 +20,7 @@ public class UserSettings : AggregateRoot private const bool DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER = false; private const bool DEFAULT_IS_THEME_CACHING_ENABLED = true; private const bool DEFAULT_AGGREGATE_METADATA_WHEN_MISSING = false; + private const bool DEFAULT_AGGREGATE_ARTWORK_WHEN_MISSING = false; private const bool DEFAULT_SHOULD_RENDER_PDF_AS_IMAGES = false; private const bool DEFAULT_SHOULD_PRESERVE_BOOK_STYLES = true; @@ -53,6 +54,11 @@ public class UserSettings : AggregateRoot /// public bool ShouldAggregateMetadataWhenMissing { get; private set; } + /// + /// Gets whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not. + /// + public bool ShouldAggregateArtworkWhenMissing { get; private set; } + /// /// Gets whether PDF books are rendered as page images for the user, or not. Rendering PDFs as images preserves the original /// layout, but the pages are not selectable or searchable, unlike their text layer. @@ -76,6 +82,7 @@ public class UserSettings : AggregateRoot /// Whether the "The" prefix of library item titles is ignored by the alpha picker, or not. /// Whether the theme data served to this user is cached, or not. /// Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not. + /// Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not. /// Whether PDF books are rendered as page images for the user, or not. /// Whether the styles of the book content are preserved when it is rendered for the user, or not. private UserSettings( @@ -86,6 +93,7 @@ public class UserSettings : AggregateRoot bool shouldIgnoreThePrefixForAlphaPicker, bool isThemeCachingEnabled, bool shouldAggregateMetadataWhenMissing, + bool shouldAggregateArtworkWhenMissing, bool shouldRenderPdfAsImages, bool shouldPreserveBookStyles) : base(id) { @@ -95,6 +103,7 @@ public class UserSettings : AggregateRoot ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker; IsThemeCachingEnabled = isThemeCachingEnabled; ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing; + ShouldAggregateArtworkWhenMissing = shouldAggregateArtworkWhenMissing; ShouldRenderPdfAsImages = shouldRenderPdfAsImages; ShouldPreserveBookStyles = shouldPreserveBookStyles; } @@ -114,6 +123,7 @@ public class UserSettings : AggregateRoot DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER, DEFAULT_IS_THEME_CACHING_ENABLED, DEFAULT_AGGREGATE_METADATA_WHEN_MISSING, + DEFAULT_AGGREGATE_ARTWORK_WHEN_MISSING, DEFAULT_SHOULD_RENDER_PDF_AS_IMAGES, DEFAULT_SHOULD_PRESERVE_BOOK_STYLES ); @@ -135,6 +145,7 @@ public class UserSettings : AggregateRoot DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER, DEFAULT_IS_THEME_CACHING_ENABLED, DEFAULT_AGGREGATE_METADATA_WHEN_MISSING, + DEFAULT_AGGREGATE_ARTWORK_WHEN_MISSING, DEFAULT_SHOULD_RENDER_PDF_AS_IMAGES, DEFAULT_SHOULD_PRESERVE_BOOK_STYLES ); @@ -149,6 +160,7 @@ public class UserSettings : AggregateRoot /// Whether the "The" prefix of library item titles is ignored by the alpha picker, or not. /// Whether the theme data served to this user is cached, or not. /// Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not. + /// Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not. /// Whether PDF books are rendered as page images for the user, or not. /// Whether the styles of the book content are preserved when it is rendered for the user, or not. /// @@ -161,6 +173,7 @@ public class UserSettings : AggregateRoot bool shouldIgnoreThePrefixForAlphaPicker, bool isThemeCachingEnabled, bool shouldAggregateMetadataWhenMissing, + bool shouldAggregateArtworkWhenMissing, bool shouldRenderPdfAsImages, bool shouldPreserveBookStyles) { @@ -175,6 +188,7 @@ public class UserSettings : AggregateRoot shouldIgnoreThePrefixForAlphaPicker, isThemeCachingEnabled, shouldAggregateMetadataWhenMissing, + shouldAggregateArtworkWhenMissing, shouldRenderPdfAsImages, shouldPreserveBookStyles); } @@ -189,6 +203,7 @@ public class UserSettings : AggregateRoot /// Whether the "The" prefix of library item titles is ignored by the alpha picker, or not. /// Whether the theme data served to this user is cached, or not. /// Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not. + /// Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not. /// Whether PDF books are rendered as page images for the user, or not. /// Whether the styles of the book content are preserved when it is rendered for the user, or not. /// @@ -202,13 +217,14 @@ public class UserSettings : AggregateRoot bool shouldIgnoreThePrefixForAlphaPicker, bool isThemeCachingEnabled, bool shouldAggregateMetadataWhenMissing, + bool shouldAggregateArtworkWhenMissing, bool shouldRenderPdfAsImages, bool shouldPreserveBookStyles) { if (itemsPerPage <= 0) return Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero; - return new UserSettings(id, userId, isPaginationEnabled, itemsPerPage, shouldIgnoreThePrefixForAlphaPicker, isThemeCachingEnabled, shouldAggregateMetadataWhenMissing, shouldRenderPdfAsImages, shouldPreserveBookStyles); + return new UserSettings(id, userId, isPaginationEnabled, itemsPerPage, shouldIgnoreThePrefixForAlphaPicker, isThemeCachingEnabled, shouldAggregateMetadataWhenMissing, shouldAggregateArtworkWhenMissing, shouldRenderPdfAsImages, shouldPreserveBookStyles); } /// @@ -219,6 +235,7 @@ public class UserSettings : AggregateRoot /// Whether the "The" prefix of library item titles is ignored by the alpha picker, or not. /// Whether the theme data served to this user is cached, or not. /// Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not. + /// Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not. /// Whether PDF books are rendered as page images for the user, or not. /// Whether the styles of the book content are preserved when it is rendered for the user, or not. /// An representing either a successful update, or an error. @@ -228,6 +245,7 @@ public class UserSettings : AggregateRoot bool shouldIgnoreThePrefixForAlphaPicker, bool isThemeCachingEnabled, bool shouldAggregateMetadataWhenMissing, + bool shouldAggregateArtworkWhenMissing, bool shouldRenderPdfAsImages, bool shouldPreserveBookStyles) { @@ -239,6 +257,7 @@ public class UserSettings : AggregateRoot ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker; IsThemeCachingEnabled = isThemeCachingEnabled; ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing; + ShouldAggregateArtworkWhenMissing = shouldAggregateArtworkWhenMissing; ShouldRenderPdfAsImages = shouldRenderPdfAsImages; ShouldPreserveBookStyles = shouldPreserveBookStyles; return Result.Updated; diff --git a/src/Lumina.Infrastructure/Common/Errors/Errors.Configuration.cs b/src/Lumina.Infrastructure/Common/Errors/Errors.Configuration.cs index 60244347..d5aa5e0e 100644 --- a/src/Lumina.Infrastructure/Common/Errors/Errors.Configuration.cs +++ b/src/Lumina.Infrastructure/Common/Errors/Errors.Configuration.cs @@ -15,6 +15,7 @@ public static partial class Errors public static Error MediaRootDirectoryCannotBeEmpty => Error.Validation(description: nameof(MediaRootDirectoryCannotBeEmpty)); public static Error MediaLibrariesDirectoryCannotBeEmpty => Error.Validation(description: nameof(MediaLibrariesDirectoryCannotBeEmpty)); public static Error MediaBooksDirectoryCannotBeEmpty => Error.Validation(description: nameof(MediaBooksDirectoryCannotBeEmpty)); + public static Error MediaMusicDirectoryCannotBeEmpty => Error.Validation(description: nameof(MediaMusicDirectoryCannotBeEmpty)); public static Error EncryptionSecretKeyCannotBeEmpty => Error.Validation(description: nameof(EncryptionSecretKeyCannotBeEmpty)); public static Error EncryptionSecretKeyMustBeABase64String => Error.Validation(description: nameof(EncryptionSecretKeyMustBeABase64String)); public static Error JwtSecretKeyCannotBeEmpty => Error.Validation(description: nameof(JwtSecretKeyCannotBeEmpty)); diff --git a/src/Lumina.Infrastructure/Common/Validators/MediaSettingsDtoValidator.cs b/src/Lumina.Infrastructure/Common/Validators/MediaSettingsDtoValidator.cs index 3c3b9829..d5eb92a9 100644 --- a/src/Lumina.Infrastructure/Common/Validators/MediaSettingsDtoValidator.cs +++ b/src/Lumina.Infrastructure/Common/Validators/MediaSettingsDtoValidator.cs @@ -27,5 +27,9 @@ public class MediaSettingsDtoValidator : AbstractValidator RuleFor(settings => settings.BooksDirectory) .NotEmpty() .WithError(Errors.Errors.Configuration.MediaBooksDirectoryCannotBeEmpty); + + RuleFor(settings => settings.MusicDirectory) + .NotEmpty() + .WithError(Errors.Errors.Configuration.MediaMusicDirectoryCannotBeEmpty); } } diff --git a/src/Lumina.Infrastructure/appsettings.shared.json b/src/Lumina.Infrastructure/appsettings.shared.json index 6671a6dd..dfeb872c 100644 --- a/src/Lumina.Infrastructure/appsettings.shared.json +++ b/src/Lumina.Infrastructure/appsettings.shared.json @@ -2,7 +2,8 @@ "MediaSettings": { "RootDirectory": "media", "LibrariesDirectory": "libraries", - "BooksDirectory": "books" + "BooksDirectory": "books", + "MusicDirectory": "music" }, "PluginsSettings": { "Directory": "plugins" diff --git a/tests/Common/Lumina.Application.Fixtures/Common/Infrastructure/Models/DTO/Configuration/MediaSettingsDtoFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/Infrastructure/Models/DTO/Configuration/MediaSettingsDtoFixture.cs index 22d42e9a..73ab2a18 100644 --- a/tests/Common/Lumina.Application.Fixtures/Common/Infrastructure/Models/DTO/Configuration/MediaSettingsDtoFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Common/Infrastructure/Models/DTO/Configuration/MediaSettingsDtoFixture.cs @@ -22,17 +22,20 @@ public class MediaSettingsDtoFixture /// Optional. The root directory where media files are stored. /// Optional. The directory where media library files are stored. /// Optional. The directory where the media item files are stored. + /// Optional. The directory where the music library item files are stored. /// The created . public MediaSettingsDto Create( string? rootDirectory = null, string? librariesDirectory = null, - string? booksDirectory = null) + string? booksDirectory = null, + string? musicDirectory = null) { return new MediaSettingsDto { RootDirectory = rootDirectory ?? _faker.System.DirectoryPath(), LibrariesDirectory = librariesDirectory ?? _faker.System.DirectoryPath(), - BooksDirectory = booksDirectory ?? _faker.System.DirectoryPath() + BooksDirectory = booksDirectory ?? _faker.System.DirectoryPath(), + MusicDirectory = musicDirectory ?? _faker.System.DirectoryPath() }; } diff --git a/tests/Common/Lumina.Application.Fixtures/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandFixture.cs index 83ebbd9a..36b56f5f 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandFixture.cs @@ -22,6 +22,7 @@ public class UpdateUserSettingsCommandFixture /// Optional. Whether the "The" prefix is ignored by the alpha picker, or not. /// Optional. Whether the theme data served to this user is cached, or not. /// Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing. + /// Optional. Whether the artwork of the media library items is aggregated from multiple providers, when it is missing. /// Optional. Whether PDF books are rendered as page images for the user. /// Optional. Whether the styles of the book content are preserved when it is rendered for the user. /// The created command. @@ -31,16 +32,18 @@ public class UpdateUserSettingsCommandFixture bool? shouldIgnoreThePrefixForAlphaPicker = null, bool? isThemeCachingEnabled = null, bool? shouldAggregateMetadataWhenMissing = null, + bool? shouldAggregateArtworkWhenMissing = null, bool? shouldRenderPdfAsImages = null, bool? shouldPreserveBookStyles = null) { return new Faker() - .CustomInstantiator(f => new UpdateUserSettingsCommand(default, default, default, default, default, default, default)) + .CustomInstantiator(f => new UpdateUserSettingsCommand(default, default, default, default, default, default, default, default)) .RuleFor(x => x.IsPaginationEnabled, f => isPaginationEnabled ?? f.Random.Bool()) .RuleFor(x => x.ItemsPerPage, f => itemsPerPage ?? f.Random.Int(1, 100)) .RuleFor(x => x.ShouldIgnoreThePrefixForAlphaPicker, f => shouldIgnoreThePrefixForAlphaPicker ?? f.Random.Bool()) .RuleFor(x => x.IsThemeCachingEnabled, f => isThemeCachingEnabled ?? f.Random.Bool()) .RuleFor(x => x.ShouldAggregateMetadataWhenMissing, f => shouldAggregateMetadataWhenMissing ?? f.Random.Bool()) + .RuleFor(x => x.ShouldAggregateArtworkWhenMissing, f => shouldAggregateArtworkWhenMissing ?? f.Random.Bool()) .RuleFor(x => x.ShouldRenderPdfAsImages, f => shouldRenderPdfAsImages ?? f.Random.Bool()) .RuleFor(x => x.ShouldPreserveBookStyles, f => shouldPreserveBookStyles ?? f.Random.Bool()) .Generate(); diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/UsersManagement/Settings/UpdateUserSettingsRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/UsersManagement/Settings/UpdateUserSettingsRequestFixture.cs index 37f2fc05..6240d10e 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/UsersManagement/Settings/UpdateUserSettingsRequestFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/UsersManagement/Settings/UpdateUserSettingsRequestFixture.cs @@ -24,6 +24,7 @@ public class UpdateUserSettingsRequestFixture /// Whether the "The" prefix is ignored by the alpha picker. /// Whether the theme data served to this user is cached. /// Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing. + /// Whether the artwork of the media library items is aggregated from multiple providers, when it is missing. /// Whether PDF books are rendered as page images for the user. /// Whether the styles of the book content are preserved when it is rendered for the user. /// The created . @@ -33,6 +34,7 @@ public class UpdateUserSettingsRequestFixture bool? shouldIgnoreThePrefixForAlphaPicker = null, bool? isThemeCachingEnabled = null, bool? shouldAggregateMetadataWhenMissing = null, + bool? shouldAggregateArtworkWhenMissing = null, bool? shouldRenderPdfAsImages = null, bool? shouldPreserveBookStyles = null) { @@ -42,6 +44,7 @@ public class UpdateUserSettingsRequestFixture shouldIgnoreThePrefixForAlphaPicker ?? _faker.Random.Bool(), isThemeCachingEnabled ?? _faker.Random.Bool(), shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool(), + shouldAggregateArtworkWhenMissing ?? _faker.Random.Bool(), shouldRenderPdfAsImages ?? _faker.Random.Bool(), shouldPreserveBookStyles ?? _faker.Random.Bool()); } diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/UsersManagement/Settings/UserSettingsResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/UsersManagement/Settings/UserSettingsResponseFixture.cs index cd4d3fbd..0723a9d2 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/UsersManagement/Settings/UserSettingsResponseFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/UsersManagement/Settings/UserSettingsResponseFixture.cs @@ -26,6 +26,7 @@ public class UserSettingsResponseFixture /// Optional. Whether the "The" prefix is ignored by the alpha picker. /// Optional. Whether the theme data served to this user is cached. /// Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing. + /// Optional. Whether the artwork of the media library items is aggregated from multiple providers, when it is missing. /// Optional. Whether PDF books are rendered as page images for the user. /// Optional. Whether the styles of the book content are preserved when it is rendered for the user. /// The created . @@ -36,6 +37,7 @@ public class UserSettingsResponseFixture bool? shouldIgnoreThePrefixForAlphaPicker = null, bool? isThemeCachingEnabled = null, bool? shouldAggregateMetadataWhenMissing = null, + bool? shouldAggregateArtworkWhenMissing = null, bool? shouldRenderPdfAsImages = null, bool? shouldPreserveBookStyles = null) { @@ -46,6 +48,7 @@ public class UserSettingsResponseFixture shouldIgnoreThePrefixForAlphaPicker ?? _faker.Random.Bool(), isThemeCachingEnabled ?? _faker.Random.Bool(), shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool(), + shouldAggregateArtworkWhenMissing ?? _faker.Random.Bool(), shouldRenderPdfAsImages ?? _faker.Random.Bool(), shouldPreserveBookStyles ?? _faker.Random.Bool()); } diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsFixture.cs index f41719d0..066592cc 100644 --- a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsFixture.cs +++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsFixture.cs @@ -25,6 +25,7 @@ public class UserSettingsFixture /// Whether the "The" prefix of library item titles is ignored by the alpha picker. /// Whether the theme data served to this user is cached. /// Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing. + /// Whether the artwork of the media library items is aggregated from multiple providers, when it is missing. /// Whether PDF books are rendered as page images for the user. /// Whether the styles of the book content are preserved when it is rendered for the user. /// The created . @@ -35,6 +36,7 @@ public class UserSettingsFixture bool shouldIgnoreThePrefixForAlphaPicker = false, bool isThemeCachingEnabled = true, bool shouldAggregateMetadataWhenMissing = false, + bool shouldAggregateArtworkWhenMissing = false, bool shouldRenderPdfAsImages = false, bool shouldPreserveBookStyles = true) { @@ -45,6 +47,7 @@ public class UserSettingsFixture shouldIgnoreThePrefixForAlphaPicker, isThemeCachingEnabled, shouldAggregateMetadataWhenMissing, + shouldAggregateArtworkWhenMissing, shouldRenderPdfAsImages, shouldPreserveBookStyles); return settings.Value; diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UsersManagement/Users/UpdateUserSettingsRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UsersManagement/Users/UpdateUserSettingsRequestMappingTests.cs index 426f561b..2ae1fa52 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UsersManagement/Users/UpdateUserSettingsRequestMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UsersManagement/Users/UpdateUserSettingsRequestMappingTests.cs @@ -14,13 +14,13 @@ namespace Lumina.Application.UnitTests.Common.Mapping.UsersManagement.Users; [ExcludeFromCodeCoverage] public class UpdateUserSettingsRequestMappingTests { - private readonly UpdateUserSettingsRequestFixture _requestFixture = new(); + private readonly UpdateUserSettingsRequestFixture _updateUserSettingsRequestFixture = new(); [Fact] public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly() { // Arrange - UpdateUserSettingsRequest request = _requestFixture.Create( + UpdateUserSettingsRequest request = _updateUserSettingsRequestFixture.Create( isPaginationEnabled: true, itemsPerPage: 48, shouldIgnoreThePrefixForAlphaPicker: false, diff --git a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsTests.cs b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsTests.cs index 27de1b25..49092a2e 100644 --- a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsTests.cs +++ b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsTests.cs @@ -80,7 +80,7 @@ public class UserSettingsTests UserId userId = _userIdFixture.Create(); // Act - Result result = UserSettings.Create(userId, isPaginationEnabled: false, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: true, shouldRenderPdfAsImages: true, shouldPreserveBookStyles: true); + Result result = UserSettings.Create(userId, isPaginationEnabled: false, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: true, shouldAggregateArtworkWhenMissing: true, shouldRenderPdfAsImages: true, shouldPreserveBookStyles: true); // Assert Assert.False(result.IsFailure); @@ -117,7 +117,7 @@ public class UserSettingsTests UserId userId = _userIdFixture.Create(); // Act - Result result = UserSettings.Create(userId, isPaginationEnabled: true, itemsPerPage: itemsPerPage, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: false); + Result result = UserSettings.Create(userId, isPaginationEnabled: true, itemsPerPage: itemsPerPage, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldAggregateArtworkWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: false); // Assert Assert.True(result.IsFailure); @@ -132,7 +132,7 @@ public class UserSettingsTests UserSettingsId id = _userSettingsIdFixture.Create(); // Act - Result result = UserSettings.Create(id, userId, isPaginationEnabled: true, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: true); + Result result = UserSettings.Create(id, userId, isPaginationEnabled: true, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldAggregateArtworkWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: true); // Assert Assert.False(result.IsFailure); @@ -149,7 +149,7 @@ public class UserSettingsTests UserSettingsId id = _userSettingsIdFixture.Create(); // Act - Result result = UserSettings.Create(id, userId, isPaginationEnabled: true, itemsPerPage: 0, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: false); + Result result = UserSettings.Create(id, userId, isPaginationEnabled: true, itemsPerPage: 0, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldAggregateArtworkWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: false); // Assert Assert.True(result.IsFailure); @@ -163,7 +163,7 @@ public class UserSettingsTests UserSettings userSettings = _userSettingsFixture.Create(); // Act - Result result = userSettings.UpdateSettings(isPaginationEnabled: false, itemsPerPage: 12, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: false, shouldAggregateMetadataWhenMissing: true, shouldRenderPdfAsImages: true, shouldPreserveBookStyles: true); + Result result = userSettings.UpdateSettings(isPaginationEnabled: false, itemsPerPage: 12, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: false, shouldAggregateMetadataWhenMissing: true, shouldAggregateArtworkWhenMissing: true, shouldRenderPdfAsImages: true, shouldPreserveBookStyles: true); // Assert Assert.False(result.IsFailure); @@ -185,7 +185,7 @@ public class UserSettingsTests UserSettings userSettings = _userSettingsFixture.Create(); // Act - Result result = userSettings.UpdateSettings(isPaginationEnabled: true, itemsPerPage: itemsPerPage, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: false); + Result result = userSettings.UpdateSettings(isPaginationEnabled: true, itemsPerPage: itemsPerPage, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldAggregateArtworkWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: false); // Assert Assert.True(result.IsFailure); diff --git a/tests/UnitTests/Lumina.Infrastructure.UnitTests/Common/Validation/ValidationOptionsTests.cs b/tests/UnitTests/Lumina.Infrastructure.UnitTests/Common/Validation/ValidationOptionsTests.cs index f103f529..2f4f76cf 100644 --- a/tests/UnitTests/Lumina.Infrastructure.UnitTests/Common/Validation/ValidationOptionsTests.cs +++ b/tests/UnitTests/Lumina.Infrastructure.UnitTests/Common/Validation/ValidationOptionsTests.cs @@ -21,6 +21,7 @@ namespace Lumina.Infrastructure.UnitTests.Common.Validation; public class ValidationOptionsTests { private readonly IFixture _fixture; + private readonly ValidationOptionsFixture _validationOptionsFixture = new(); /// /// Initializes a new instance of the class. @@ -35,7 +36,7 @@ public class ValidationOptionsTests { // Arrange string name = _fixture.Create(); - ValidationOptionsFixture options = _fixture.Create(); + ValidationOptionsFixture options = _validationOptionsFixture.Create(); IValidator validator = Substitute.For>(); validator.Validate(options).Returns([]); ValidationOptions sut = new(name, validator); @@ -55,7 +56,7 @@ public class ValidationOptionsTests // Arrange string name = _fixture.Create(); string differentName = _fixture.Create(); - ValidationOptionsFixture options = _fixture.Create(); + ValidationOptionsFixture options = _validationOptionsFixture.Create(); IValidator validator = Substitute.For>(); ValidationOptions sut = new(name, validator); @@ -71,7 +72,7 @@ public class ValidationOptionsTests public void Validate_WhenNullName_ShouldValidateOptions() { // Arrange - ValidationOptionsFixture options = _fixture.Create(); + ValidationOptionsFixture options = _validationOptionsFixture.Create(); IValidator validator = Substitute.For>(); validator.Validate(options).Returns([]); ValidationOptions sut = new(null, validator); @@ -105,7 +106,7 @@ public class ValidationOptionsTests { // Arrange string name = _fixture.Create(); - ValidationOptionsFixture options = _fixture.Create(); + ValidationOptionsFixture options = _validationOptionsFixture.Create(); IValidator validator = Substitute.For>(); List validationFailures = [ diff --git a/tests/UnitTests/Lumina.Presentation.Web.UnitTests/Common/Validation/ValidationOptionsTests.cs b/tests/UnitTests/Lumina.Presentation.Web.UnitTests/Common/Validation/ValidationOptionsTests.cs index 466a7c72..82cf4c11 100644 --- a/tests/UnitTests/Lumina.Presentation.Web.UnitTests/Common/Validation/ValidationOptionsTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Web.UnitTests/Common/Validation/ValidationOptionsTests.cs @@ -1,6 +1,7 @@ #region ========================================================================= USING ===================================================================================== using Lumina.Presentation.Web.Common.Primitives; using Lumina.Presentation.Web.Common.Validation; +using Lumina.Presentation.Web.Fixtures.Common.Validation; using Microsoft.Extensions.Options; using NSubstitute; using System; @@ -17,15 +18,17 @@ namespace Lumina.Presentation.Web.UnitTests.Common.Validation; [ExcludeFromCodeCoverage] public class ValidationOptionsTests { + private readonly ValidationOptionsFixture _validationOptionsFixture = new(); + [Fact] public void Validate_WhenMatchingName_ShouldValidateOptions() { // Arrange string optionsName = "OptionsName"; - TestOptions options = new(); - IValidator validator = Substitute.For>(); + ValidationOptionsFixture options = _validationOptionsFixture.Create(); + IValidator validator = Substitute.For>(); validator.Validate(options).Returns([]); - ValidationOptions sut = new(optionsName, validator); + ValidationOptions sut = new(optionsName, validator); // Act ValidateOptionsResult result = sut.Validate(optionsName, options); @@ -42,9 +45,9 @@ public class ValidationOptionsTests // Arrange string optionsName = "OptionsName"; string differentOptionsName = "DifferentOptionsName"; - TestOptions options = new(); - IValidator validator = Substitute.For>(); - ValidationOptions sut = new(optionsName, validator); + ValidationOptionsFixture options = _validationOptionsFixture.Create(); + IValidator validator = Substitute.For>(); + ValidationOptions sut = new(optionsName, validator); // Act ValidateOptionsResult result = sut.Validate(differentOptionsName, options); @@ -58,10 +61,10 @@ public class ValidationOptionsTests public void Validate_WhenNullName_ShouldValidateOptions() { // Arrange - TestOptions options = new(); - IValidator validator = Substitute.For>(); + ValidationOptionsFixture options = _validationOptionsFixture.Create(); + IValidator validator = Substitute.For>(); validator.Validate(options).Returns([]); - ValidationOptions sut = new(null, validator); + ValidationOptions sut = new(null, validator); // Act ValidateOptionsResult result = sut.Validate("AnyOptionsName", options); @@ -77,15 +80,15 @@ public class ValidationOptionsTests { // Arrange string optionsName = "OptionsName"; - IValidator validator = Substitute.For>(); - ValidationOptions sut = new(optionsName, validator); + IValidator validator = Substitute.For>(); + ValidationOptions sut = new(optionsName, validator); // Act Action act = () => sut.Validate(optionsName, null!); // Assert Assert.Throws(act); - validator.DidNotReceive().Validate(Arg.Any()); + validator.DidNotReceive().Validate(Arg.Any()); } [Fact] @@ -93,14 +96,14 @@ public class ValidationOptionsTests { // Arrange string optionsName = "OptionsName"; - TestOptions options = new(); - IValidator validator = Substitute.For>(); + ValidationOptionsFixture options = _validationOptionsFixture.Create(); + IValidator validator = Substitute.For>(); List validationFailures = [ Error.Validation("PropertyName", "Error Message") ]; validator.Validate(options).Returns(validationFailures); - ValidationOptions sut = new(optionsName, validator); + ValidationOptions sut = new(optionsName, validator); // Act ValidateOptionsResult result = sut.Validate(optionsName, options); @@ -117,15 +120,15 @@ public class ValidationOptionsTests { // Arrange string optionsName = "OptionsName"; - TestOptions options = new(); - IValidator validator = Substitute.For>(); + ValidationOptionsFixture options = _validationOptionsFixture.Create(); + IValidator validator = Substitute.For>(); List validationFailures = [ Error.Validation("PropertyOne", "First Error Message"), Error.Validation("PropertyTwo", "Second Error Message") ]; validator.Validate(options).Returns(validationFailures); - ValidationOptions sut = new(optionsName, validator); + ValidationOptions sut = new(optionsName, validator); // Act ValidateOptionsResult result = sut.Validate(optionsName, options); @@ -137,12 +140,4 @@ public class ValidationOptionsTests Assert.Contains("Options validation failed for 'PropertyOne' with error: 'First Error Message'", result.Failures); Assert.Contains("Options validation failed for 'PropertyTwo' with error: 'Second Error Message'", result.Failures); } - - /// - /// Placeholder options type used to exercise the generic class. - /// - [ExcludeFromCodeCoverage] - public sealed class TestOptions - { - } }