mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 19:21:10 +00:00
Adds the should aggregate artwork when missing setting to the user settings, configuration, and validation
This commit is contained in:
1 parent
6b5e731546
commit
e139a7bb00
21 files changed
+97
-43
No files matched your search
+5
@@ -26,4 +26,9 @@ public class MediaSettingsDto
|
|||||||
/// Gets or sets the directory where the media item files are stored.
|
/// Gets or sets the directory where the media item files are stored.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public required string BooksDirectory { get; init; }
|
public required string BooksDirectory { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the directory where the music library item files are stored.
|
||||||
|
/// </summary>
|
||||||
|
public required string MusicDirectory { get; init; }
|
||||||
}
|
}
|
||||||
+1
@@ -23,6 +23,7 @@ public static class UpdateUserSettingsRequestMapping
|
|||||||
request.ShouldIgnoreThePrefixForAlphaPicker,
|
request.ShouldIgnoreThePrefixForAlphaPicker,
|
||||||
request.IsThemeCachingEnabled,
|
request.IsThemeCachingEnabled,
|
||||||
request.ShouldAggregateMetadataWhenMissing,
|
request.ShouldAggregateMetadataWhenMissing,
|
||||||
|
request.ShouldAggregateArtworkWhenMissing,
|
||||||
request.ShouldRenderPdfAsImages,
|
request.ShouldRenderPdfAsImages,
|
||||||
request.ShouldPreserveBookStyles
|
request.ShouldPreserveBookStyles
|
||||||
);
|
);
|
||||||
|
|||||||
+2
@@ -31,6 +31,7 @@ public static class UserSettingsEntityMapping
|
|||||||
repositoryEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
repositoryEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
||||||
repositoryEntity.IsThemeCachingEnabled,
|
repositoryEntity.IsThemeCachingEnabled,
|
||||||
repositoryEntity.ShouldAggregateMetadataWhenMissing,
|
repositoryEntity.ShouldAggregateMetadataWhenMissing,
|
||||||
|
repositoryEntity.ShouldAggregateArtworkWhenMissing,
|
||||||
repositoryEntity.ShouldRenderPdfAsImages,
|
repositoryEntity.ShouldRenderPdfAsImages,
|
||||||
repositoryEntity.ShouldPreserveBookStyles
|
repositoryEntity.ShouldPreserveBookStyles
|
||||||
);
|
);
|
||||||
@@ -50,6 +51,7 @@ public static class UserSettingsEntityMapping
|
|||||||
repositoryEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
repositoryEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
||||||
repositoryEntity.IsThemeCachingEnabled,
|
repositoryEntity.IsThemeCachingEnabled,
|
||||||
repositoryEntity.ShouldAggregateMetadataWhenMissing,
|
repositoryEntity.ShouldAggregateMetadataWhenMissing,
|
||||||
|
repositoryEntity.ShouldAggregateArtworkWhenMissing,
|
||||||
repositoryEntity.ShouldRenderPdfAsImages,
|
repositoryEntity.ShouldRenderPdfAsImages,
|
||||||
repositoryEntity.ShouldPreserveBookStyles
|
repositoryEntity.ShouldPreserveBookStyles
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public static class UserSettingsMapping
|
|||||||
ShouldIgnoreThePrefixForAlphaPicker = domainEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
ShouldIgnoreThePrefixForAlphaPicker = domainEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
||||||
IsThemeCachingEnabled = domainEntity.IsThemeCachingEnabled,
|
IsThemeCachingEnabled = domainEntity.IsThemeCachingEnabled,
|
||||||
ShouldAggregateMetadataWhenMissing = domainEntity.ShouldAggregateMetadataWhenMissing,
|
ShouldAggregateMetadataWhenMissing = domainEntity.ShouldAggregateMetadataWhenMissing,
|
||||||
|
ShouldAggregateArtworkWhenMissing = domainEntity.ShouldAggregateArtworkWhenMissing,
|
||||||
ShouldRenderPdfAsImages = domainEntity.ShouldRenderPdfAsImages,
|
ShouldRenderPdfAsImages = domainEntity.ShouldRenderPdfAsImages,
|
||||||
ShouldPreserveBookStyles = domainEntity.ShouldPreserveBookStyles
|
ShouldPreserveBookStyles = domainEntity.ShouldPreserveBookStyles
|
||||||
};
|
};
|
||||||
@@ -46,6 +47,7 @@ public static class UserSettingsMapping
|
|||||||
domainEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
domainEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
||||||
domainEntity.IsThemeCachingEnabled,
|
domainEntity.IsThemeCachingEnabled,
|
||||||
domainEntity.ShouldAggregateMetadataWhenMissing,
|
domainEntity.ShouldAggregateMetadataWhenMissing,
|
||||||
|
domainEntity.ShouldAggregateArtworkWhenMissing,
|
||||||
domainEntity.ShouldRenderPdfAsImages,
|
domainEntity.ShouldRenderPdfAsImages,
|
||||||
domainEntity.ShouldPreserveBookStyles
|
domainEntity.ShouldPreserveBookStyles
|
||||||
);
|
);
|
||||||
|
|||||||
+2
@@ -12,6 +12,7 @@ namespace Lumina.Application.Core.UsersManagement.Settings.Commands.UpdateUserSe
|
|||||||
/// <param name="ShouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
/// <param name="ShouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||||
/// <param name="IsThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
/// <param name="IsThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
||||||
/// <param name="ShouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
/// <param name="ShouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||||
|
/// <param name="ShouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
|
||||||
/// <param name="ShouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
/// <param name="ShouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
||||||
/// <param name="ShouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
/// <param name="ShouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
||||||
public record UpdateUserSettingsCommand(
|
public record UpdateUserSettingsCommand(
|
||||||
@@ -20,6 +21,7 @@ public record UpdateUserSettingsCommand(
|
|||||||
bool ShouldIgnoreThePrefixForAlphaPicker,
|
bool ShouldIgnoreThePrefixForAlphaPicker,
|
||||||
bool IsThemeCachingEnabled,
|
bool IsThemeCachingEnabled,
|
||||||
bool ShouldAggregateMetadataWhenMissing,
|
bool ShouldAggregateMetadataWhenMissing,
|
||||||
|
bool ShouldAggregateArtworkWhenMissing,
|
||||||
bool ShouldRenderPdfAsImages,
|
bool ShouldRenderPdfAsImages,
|
||||||
bool ShouldPreserveBookStyles
|
bool ShouldPreserveBookStyles
|
||||||
) : ICommand;
|
) : ICommand;
|
||||||
+2
@@ -74,6 +74,7 @@ public class UpdateUserSettingsCommandHandler : ICommandHandler<UpdateUserSettin
|
|||||||
command.ShouldIgnoreThePrefixForAlphaPicker,
|
command.ShouldIgnoreThePrefixForAlphaPicker,
|
||||||
command.IsThemeCachingEnabled,
|
command.IsThemeCachingEnabled,
|
||||||
command.ShouldAggregateMetadataWhenMissing,
|
command.ShouldAggregateMetadataWhenMissing,
|
||||||
|
command.ShouldAggregateArtworkWhenMissing,
|
||||||
command.ShouldRenderPdfAsImages,
|
command.ShouldRenderPdfAsImages,
|
||||||
command.ShouldPreserveBookStyles);
|
command.ShouldPreserveBookStyles);
|
||||||
if (createSettingsResult.IsFailure)
|
if (createSettingsResult.IsFailure)
|
||||||
@@ -96,6 +97,7 @@ public class UpdateUserSettingsCommandHandler : ICommandHandler<UpdateUserSettin
|
|||||||
command.ShouldIgnoreThePrefixForAlphaPicker,
|
command.ShouldIgnoreThePrefixForAlphaPicker,
|
||||||
command.IsThemeCachingEnabled,
|
command.IsThemeCachingEnabled,
|
||||||
command.ShouldAggregateMetadataWhenMissing,
|
command.ShouldAggregateMetadataWhenMissing,
|
||||||
|
command.ShouldAggregateArtworkWhenMissing,
|
||||||
command.ShouldRenderPdfAsImages,
|
command.ShouldRenderPdfAsImages,
|
||||||
command.ShouldPreserveBookStyles);
|
command.ShouldPreserveBookStyles);
|
||||||
if (updateSettingsResult.IsFailure)
|
if (updateSettingsResult.IsFailure)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace Lumina.Contracts.Requests.UsersManagement.Settings;
|
|||||||
/// <param name="ShouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not. Required.</param>
|
/// <param name="ShouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not. Required.</param>
|
||||||
/// <param name="IsThemeCachingEnabled">Whether the theme data served to this user is cached, or not. Required.</param>
|
/// <param name="IsThemeCachingEnabled">Whether the theme data served to this user is cached, or not. Required.</param>
|
||||||
/// <param name="ShouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not. Required.</param>
|
/// <param name="ShouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not. Required.</param>
|
||||||
|
/// <param name="ShouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not. Required.</param>
|
||||||
/// <param name="ShouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not. Required.</param>
|
/// <param name="ShouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not. Required.</param>
|
||||||
/// <param name="ShouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not. Required.</param>
|
/// <param name="ShouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not. Required.</param>
|
||||||
[DebuggerDisplay("IsPaginationEnabled: {IsPaginationEnabled}; ItemsPerPage: {ItemsPerPage}")]
|
[DebuggerDisplay("IsPaginationEnabled: {IsPaginationEnabled}; ItemsPerPage: {ItemsPerPage}")]
|
||||||
@@ -21,6 +22,7 @@ public sealed record UpdateUserSettingsRequest(
|
|||||||
bool ShouldIgnoreThePrefixForAlphaPicker,
|
bool ShouldIgnoreThePrefixForAlphaPicker,
|
||||||
bool IsThemeCachingEnabled,
|
bool IsThemeCachingEnabled,
|
||||||
bool ShouldAggregateMetadataWhenMissing,
|
bool ShouldAggregateMetadataWhenMissing,
|
||||||
|
bool ShouldAggregateArtworkWhenMissing,
|
||||||
bool ShouldRenderPdfAsImages,
|
bool ShouldRenderPdfAsImages,
|
||||||
bool ShouldPreserveBookStyles
|
bool ShouldPreserveBookStyles
|
||||||
);
|
);
|
||||||
@@ -14,6 +14,7 @@ namespace Lumina.Contracts.Responses.UsersManagement.Settings;
|
|||||||
/// <param name="ShouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
/// <param name="ShouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||||
/// <param name="IsThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
/// <param name="IsThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
||||||
/// <param name="ShouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
/// <param name="ShouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||||
|
/// <param name="ShouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
|
||||||
/// <param name="ShouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
/// <param name="ShouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
||||||
/// <param name="ShouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
/// <param name="ShouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
||||||
[DebuggerDisplay("UserId: {UserId}")]
|
[DebuggerDisplay("UserId: {UserId}")]
|
||||||
@@ -24,6 +25,7 @@ public sealed record UserSettingsResponse(
|
|||||||
bool ShouldIgnoreThePrefixForAlphaPicker,
|
bool ShouldIgnoreThePrefixForAlphaPicker,
|
||||||
bool IsThemeCachingEnabled,
|
bool IsThemeCachingEnabled,
|
||||||
bool ShouldAggregateMetadataWhenMissing,
|
bool ShouldAggregateMetadataWhenMissing,
|
||||||
|
bool ShouldAggregateArtworkWhenMissing,
|
||||||
bool ShouldRenderPdfAsImages,
|
bool ShouldRenderPdfAsImages,
|
||||||
bool ShouldPreserveBookStyles
|
bool ShouldPreserveBookStyles
|
||||||
);
|
);
|
||||||
+20
-1
@@ -20,6 +20,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
|||||||
private const bool DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER = false;
|
private const bool DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER = false;
|
||||||
private const bool DEFAULT_IS_THEME_CACHING_ENABLED = true;
|
private const bool DEFAULT_IS_THEME_CACHING_ENABLED = true;
|
||||||
private const bool DEFAULT_AGGREGATE_METADATA_WHEN_MISSING = false;
|
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_RENDER_PDF_AS_IMAGES = false;
|
||||||
private const bool DEFAULT_SHOULD_PRESERVE_BOOK_STYLES = true;
|
private const bool DEFAULT_SHOULD_PRESERVE_BOOK_STYLES = true;
|
||||||
|
|
||||||
@@ -53,6 +54,11 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ShouldAggregateMetadataWhenMissing { get; private set; }
|
public bool ShouldAggregateMetadataWhenMissing { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.
|
||||||
|
/// </summary>
|
||||||
|
public bool ShouldAggregateArtworkWhenMissing { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets whether PDF books are rendered as page images for the user, or not. Rendering PDFs as images preserves the original
|
/// 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.
|
/// layout, but the pages are not selectable or searchable, unlike their text layer.
|
||||||
@@ -76,6 +82,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
|||||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
||||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||||
|
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
|
||||||
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
||||||
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
||||||
private UserSettings(
|
private UserSettings(
|
||||||
@@ -86,6 +93,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
|||||||
bool shouldIgnoreThePrefixForAlphaPicker,
|
bool shouldIgnoreThePrefixForAlphaPicker,
|
||||||
bool isThemeCachingEnabled,
|
bool isThemeCachingEnabled,
|
||||||
bool shouldAggregateMetadataWhenMissing,
|
bool shouldAggregateMetadataWhenMissing,
|
||||||
|
bool shouldAggregateArtworkWhenMissing,
|
||||||
bool shouldRenderPdfAsImages,
|
bool shouldRenderPdfAsImages,
|
||||||
bool shouldPreserveBookStyles) : base(id)
|
bool shouldPreserveBookStyles) : base(id)
|
||||||
{
|
{
|
||||||
@@ -95,6 +103,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
|||||||
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker;
|
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker;
|
||||||
IsThemeCachingEnabled = isThemeCachingEnabled;
|
IsThemeCachingEnabled = isThemeCachingEnabled;
|
||||||
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing;
|
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing;
|
||||||
|
ShouldAggregateArtworkWhenMissing = shouldAggregateArtworkWhenMissing;
|
||||||
ShouldRenderPdfAsImages = shouldRenderPdfAsImages;
|
ShouldRenderPdfAsImages = shouldRenderPdfAsImages;
|
||||||
ShouldPreserveBookStyles = shouldPreserveBookStyles;
|
ShouldPreserveBookStyles = shouldPreserveBookStyles;
|
||||||
}
|
}
|
||||||
@@ -114,6 +123,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
|||||||
DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER,
|
DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER,
|
||||||
DEFAULT_IS_THEME_CACHING_ENABLED,
|
DEFAULT_IS_THEME_CACHING_ENABLED,
|
||||||
DEFAULT_AGGREGATE_METADATA_WHEN_MISSING,
|
DEFAULT_AGGREGATE_METADATA_WHEN_MISSING,
|
||||||
|
DEFAULT_AGGREGATE_ARTWORK_WHEN_MISSING,
|
||||||
DEFAULT_SHOULD_RENDER_PDF_AS_IMAGES,
|
DEFAULT_SHOULD_RENDER_PDF_AS_IMAGES,
|
||||||
DEFAULT_SHOULD_PRESERVE_BOOK_STYLES
|
DEFAULT_SHOULD_PRESERVE_BOOK_STYLES
|
||||||
);
|
);
|
||||||
@@ -135,6 +145,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
|||||||
DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER,
|
DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER,
|
||||||
DEFAULT_IS_THEME_CACHING_ENABLED,
|
DEFAULT_IS_THEME_CACHING_ENABLED,
|
||||||
DEFAULT_AGGREGATE_METADATA_WHEN_MISSING,
|
DEFAULT_AGGREGATE_METADATA_WHEN_MISSING,
|
||||||
|
DEFAULT_AGGREGATE_ARTWORK_WHEN_MISSING,
|
||||||
DEFAULT_SHOULD_RENDER_PDF_AS_IMAGES,
|
DEFAULT_SHOULD_RENDER_PDF_AS_IMAGES,
|
||||||
DEFAULT_SHOULD_PRESERVE_BOOK_STYLES
|
DEFAULT_SHOULD_PRESERVE_BOOK_STYLES
|
||||||
);
|
);
|
||||||
@@ -149,6 +160,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
|||||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
||||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||||
|
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
|
||||||
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
||||||
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
@@ -161,6 +173,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
|||||||
bool shouldIgnoreThePrefixForAlphaPicker,
|
bool shouldIgnoreThePrefixForAlphaPicker,
|
||||||
bool isThemeCachingEnabled,
|
bool isThemeCachingEnabled,
|
||||||
bool shouldAggregateMetadataWhenMissing,
|
bool shouldAggregateMetadataWhenMissing,
|
||||||
|
bool shouldAggregateArtworkWhenMissing,
|
||||||
bool shouldRenderPdfAsImages,
|
bool shouldRenderPdfAsImages,
|
||||||
bool shouldPreserveBookStyles)
|
bool shouldPreserveBookStyles)
|
||||||
{
|
{
|
||||||
@@ -175,6 +188,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
|||||||
shouldIgnoreThePrefixForAlphaPicker,
|
shouldIgnoreThePrefixForAlphaPicker,
|
||||||
isThemeCachingEnabled,
|
isThemeCachingEnabled,
|
||||||
shouldAggregateMetadataWhenMissing,
|
shouldAggregateMetadataWhenMissing,
|
||||||
|
shouldAggregateArtworkWhenMissing,
|
||||||
shouldRenderPdfAsImages,
|
shouldRenderPdfAsImages,
|
||||||
shouldPreserveBookStyles);
|
shouldPreserveBookStyles);
|
||||||
}
|
}
|
||||||
@@ -189,6 +203,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
|||||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
||||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||||
|
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
|
||||||
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
||||||
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
@@ -202,13 +217,14 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
|||||||
bool shouldIgnoreThePrefixForAlphaPicker,
|
bool shouldIgnoreThePrefixForAlphaPicker,
|
||||||
bool isThemeCachingEnabled,
|
bool isThemeCachingEnabled,
|
||||||
bool shouldAggregateMetadataWhenMissing,
|
bool shouldAggregateMetadataWhenMissing,
|
||||||
|
bool shouldAggregateArtworkWhenMissing,
|
||||||
bool shouldRenderPdfAsImages,
|
bool shouldRenderPdfAsImages,
|
||||||
bool shouldPreserveBookStyles)
|
bool shouldPreserveBookStyles)
|
||||||
{
|
{
|
||||||
if (itemsPerPage <= 0)
|
if (itemsPerPage <= 0)
|
||||||
return Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -219,6 +235,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
|||||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
||||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||||
|
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
|
||||||
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
||||||
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
||||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful update, or an error.</returns>
|
/// <returns>An <see cref="Result{TValue}"/> representing either a successful update, or an error.</returns>
|
||||||
@@ -228,6 +245,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
|||||||
bool shouldIgnoreThePrefixForAlphaPicker,
|
bool shouldIgnoreThePrefixForAlphaPicker,
|
||||||
bool isThemeCachingEnabled,
|
bool isThemeCachingEnabled,
|
||||||
bool shouldAggregateMetadataWhenMissing,
|
bool shouldAggregateMetadataWhenMissing,
|
||||||
|
bool shouldAggregateArtworkWhenMissing,
|
||||||
bool shouldRenderPdfAsImages,
|
bool shouldRenderPdfAsImages,
|
||||||
bool shouldPreserveBookStyles)
|
bool shouldPreserveBookStyles)
|
||||||
{
|
{
|
||||||
@@ -239,6 +257,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
|||||||
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker;
|
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker;
|
||||||
IsThemeCachingEnabled = isThemeCachingEnabled;
|
IsThemeCachingEnabled = isThemeCachingEnabled;
|
||||||
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing;
|
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing;
|
||||||
|
ShouldAggregateArtworkWhenMissing = shouldAggregateArtworkWhenMissing;
|
||||||
ShouldRenderPdfAsImages = shouldRenderPdfAsImages;
|
ShouldRenderPdfAsImages = shouldRenderPdfAsImages;
|
||||||
ShouldPreserveBookStyles = shouldPreserveBookStyles;
|
ShouldPreserveBookStyles = shouldPreserveBookStyles;
|
||||||
return Result.Updated;
|
return Result.Updated;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public static partial class Errors
|
|||||||
public static Error MediaRootDirectoryCannotBeEmpty => Error.Validation(description: nameof(MediaRootDirectoryCannotBeEmpty));
|
public static Error MediaRootDirectoryCannotBeEmpty => Error.Validation(description: nameof(MediaRootDirectoryCannotBeEmpty));
|
||||||
public static Error MediaLibrariesDirectoryCannotBeEmpty => Error.Validation(description: nameof(MediaLibrariesDirectoryCannotBeEmpty));
|
public static Error MediaLibrariesDirectoryCannotBeEmpty => Error.Validation(description: nameof(MediaLibrariesDirectoryCannotBeEmpty));
|
||||||
public static Error MediaBooksDirectoryCannotBeEmpty => Error.Validation(description: nameof(MediaBooksDirectoryCannotBeEmpty));
|
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 EncryptionSecretKeyCannotBeEmpty => Error.Validation(description: nameof(EncryptionSecretKeyCannotBeEmpty));
|
||||||
public static Error EncryptionSecretKeyMustBeABase64String => Error.Validation(description: nameof(EncryptionSecretKeyMustBeABase64String));
|
public static Error EncryptionSecretKeyMustBeABase64String => Error.Validation(description: nameof(EncryptionSecretKeyMustBeABase64String));
|
||||||
public static Error JwtSecretKeyCannotBeEmpty => Error.Validation(description: nameof(JwtSecretKeyCannotBeEmpty));
|
public static Error JwtSecretKeyCannotBeEmpty => Error.Validation(description: nameof(JwtSecretKeyCannotBeEmpty));
|
||||||
|
|||||||
@@ -27,5 +27,9 @@ public class MediaSettingsDtoValidator : AbstractValidator<MediaSettingsDto>
|
|||||||
RuleFor(settings => settings.BooksDirectory)
|
RuleFor(settings => settings.BooksDirectory)
|
||||||
.NotEmpty()
|
.NotEmpty()
|
||||||
.WithError(Errors.Errors.Configuration.MediaBooksDirectoryCannotBeEmpty);
|
.WithError(Errors.Errors.Configuration.MediaBooksDirectoryCannotBeEmpty);
|
||||||
|
|
||||||
|
RuleFor(settings => settings.MusicDirectory)
|
||||||
|
.NotEmpty()
|
||||||
|
.WithError(Errors.Errors.Configuration.MediaMusicDirectoryCannotBeEmpty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,8 @@
|
|||||||
"MediaSettings": {
|
"MediaSettings": {
|
||||||
"RootDirectory": "media",
|
"RootDirectory": "media",
|
||||||
"LibrariesDirectory": "libraries",
|
"LibrariesDirectory": "libraries",
|
||||||
"BooksDirectory": "books"
|
"BooksDirectory": "books",
|
||||||
|
"MusicDirectory": "music"
|
||||||
},
|
},
|
||||||
"PluginsSettings": {
|
"PluginsSettings": {
|
||||||
"Directory": "plugins"
|
"Directory": "plugins"
|
||||||
|
|||||||
+5
-2
@@ -22,17 +22,20 @@ public class MediaSettingsDtoFixture
|
|||||||
/// <param name="rootDirectory">Optional. The root directory where media files are stored.</param>
|
/// <param name="rootDirectory">Optional. The root directory where media files are stored.</param>
|
||||||
/// <param name="librariesDirectory">Optional. The directory where media library files are stored.</param>
|
/// <param name="librariesDirectory">Optional. The directory where media library files are stored.</param>
|
||||||
/// <param name="booksDirectory">Optional. The directory where the media item files are stored.</param>
|
/// <param name="booksDirectory">Optional. The directory where the media item files are stored.</param>
|
||||||
|
/// <param name="musicDirectory">Optional. The directory where the music library item files are stored.</param>
|
||||||
/// <returns>The created <see cref="MediaSettingsDto"/>.</returns>
|
/// <returns>The created <see cref="MediaSettingsDto"/>.</returns>
|
||||||
public MediaSettingsDto Create(
|
public MediaSettingsDto Create(
|
||||||
string? rootDirectory = null,
|
string? rootDirectory = null,
|
||||||
string? librariesDirectory = null,
|
string? librariesDirectory = null,
|
||||||
string? booksDirectory = null)
|
string? booksDirectory = null,
|
||||||
|
string? musicDirectory = null)
|
||||||
{
|
{
|
||||||
return new MediaSettingsDto
|
return new MediaSettingsDto
|
||||||
{
|
{
|
||||||
RootDirectory = rootDirectory ?? _faker.System.DirectoryPath(),
|
RootDirectory = rootDirectory ?? _faker.System.DirectoryPath(),
|
||||||
LibrariesDirectory = librariesDirectory ?? _faker.System.DirectoryPath(),
|
LibrariesDirectory = librariesDirectory ?? _faker.System.DirectoryPath(),
|
||||||
BooksDirectory = booksDirectory ?? _faker.System.DirectoryPath()
|
BooksDirectory = booksDirectory ?? _faker.System.DirectoryPath(),
|
||||||
|
MusicDirectory = musicDirectory ?? _faker.System.DirectoryPath()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -22,6 +22,7 @@ public class UpdateUserSettingsCommandFixture
|
|||||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Optional. Whether the "The" prefix is ignored by the alpha picker, or not.</param>
|
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Optional. Whether the "The" prefix is ignored by the alpha picker, or not.</param>
|
||||||
/// <param name="isThemeCachingEnabled">Optional. Whether the theme data served to this user is cached, or not.</param>
|
/// <param name="isThemeCachingEnabled">Optional. Whether the theme data served to this user is cached, or not.</param>
|
||||||
/// <param name="shouldAggregateMetadataWhenMissing">Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
|
/// <param name="shouldAggregateMetadataWhenMissing">Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
|
||||||
|
/// <param name="shouldAggregateArtworkWhenMissing">Optional. Whether the artwork of the media library items is aggregated from multiple providers, when it is missing.</param>
|
||||||
/// <param name="shouldRenderPdfAsImages">Optional. Whether PDF books are rendered as page images for the user.</param>
|
/// <param name="shouldRenderPdfAsImages">Optional. Whether PDF books are rendered as page images for the user.</param>
|
||||||
/// <param name="shouldPreserveBookStyles">Optional. Whether the styles of the book content are preserved when it is rendered for the user.</param>
|
/// <param name="shouldPreserveBookStyles">Optional. Whether the styles of the book content are preserved when it is rendered for the user.</param>
|
||||||
/// <returns>The created command.</returns>
|
/// <returns>The created command.</returns>
|
||||||
@@ -31,16 +32,18 @@ public class UpdateUserSettingsCommandFixture
|
|||||||
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
||||||
bool? isThemeCachingEnabled = null,
|
bool? isThemeCachingEnabled = null,
|
||||||
bool? shouldAggregateMetadataWhenMissing = null,
|
bool? shouldAggregateMetadataWhenMissing = null,
|
||||||
|
bool? shouldAggregateArtworkWhenMissing = null,
|
||||||
bool? shouldRenderPdfAsImages = null,
|
bool? shouldRenderPdfAsImages = null,
|
||||||
bool? shouldPreserveBookStyles = null)
|
bool? shouldPreserveBookStyles = null)
|
||||||
{
|
{
|
||||||
return new Faker<UpdateUserSettingsCommand>()
|
return new Faker<UpdateUserSettingsCommand>()
|
||||||
.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.IsPaginationEnabled, f => isPaginationEnabled ?? f.Random.Bool())
|
||||||
.RuleFor(x => x.ItemsPerPage, f => itemsPerPage ?? f.Random.Int(1, 100))
|
.RuleFor(x => x.ItemsPerPage, f => itemsPerPage ?? f.Random.Int(1, 100))
|
||||||
.RuleFor(x => x.ShouldIgnoreThePrefixForAlphaPicker, f => shouldIgnoreThePrefixForAlphaPicker ?? f.Random.Bool())
|
.RuleFor(x => x.ShouldIgnoreThePrefixForAlphaPicker, f => shouldIgnoreThePrefixForAlphaPicker ?? f.Random.Bool())
|
||||||
.RuleFor(x => x.IsThemeCachingEnabled, f => isThemeCachingEnabled ?? f.Random.Bool())
|
.RuleFor(x => x.IsThemeCachingEnabled, f => isThemeCachingEnabled ?? f.Random.Bool())
|
||||||
.RuleFor(x => x.ShouldAggregateMetadataWhenMissing, f => shouldAggregateMetadataWhenMissing ?? 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.ShouldRenderPdfAsImages, f => shouldRenderPdfAsImages ?? f.Random.Bool())
|
||||||
.RuleFor(x => x.ShouldPreserveBookStyles, f => shouldPreserveBookStyles ?? f.Random.Bool())
|
.RuleFor(x => x.ShouldPreserveBookStyles, f => shouldPreserveBookStyles ?? f.Random.Bool())
|
||||||
.Generate();
|
.Generate();
|
||||||
|
|||||||
+3
@@ -24,6 +24,7 @@ public class UpdateUserSettingsRequestFixture
|
|||||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix is ignored by the alpha picker.</param>
|
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix is ignored by the alpha picker.</param>
|
||||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached.</param>
|
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached.</param>
|
||||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
|
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
|
||||||
|
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing.</param>
|
||||||
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user.</param>
|
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user.</param>
|
||||||
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user.</param>
|
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user.</param>
|
||||||
/// <returns>The created <see cref="UpdateUserSettingsRequest"/>.</returns>
|
/// <returns>The created <see cref="UpdateUserSettingsRequest"/>.</returns>
|
||||||
@@ -33,6 +34,7 @@ public class UpdateUserSettingsRequestFixture
|
|||||||
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
||||||
bool? isThemeCachingEnabled = null,
|
bool? isThemeCachingEnabled = null,
|
||||||
bool? shouldAggregateMetadataWhenMissing = null,
|
bool? shouldAggregateMetadataWhenMissing = null,
|
||||||
|
bool? shouldAggregateArtworkWhenMissing = null,
|
||||||
bool? shouldRenderPdfAsImages = null,
|
bool? shouldRenderPdfAsImages = null,
|
||||||
bool? shouldPreserveBookStyles = null)
|
bool? shouldPreserveBookStyles = null)
|
||||||
{
|
{
|
||||||
@@ -42,6 +44,7 @@ public class UpdateUserSettingsRequestFixture
|
|||||||
shouldIgnoreThePrefixForAlphaPicker ?? _faker.Random.Bool(),
|
shouldIgnoreThePrefixForAlphaPicker ?? _faker.Random.Bool(),
|
||||||
isThemeCachingEnabled ?? _faker.Random.Bool(),
|
isThemeCachingEnabled ?? _faker.Random.Bool(),
|
||||||
shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool(),
|
shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool(),
|
||||||
|
shouldAggregateArtworkWhenMissing ?? _faker.Random.Bool(),
|
||||||
shouldRenderPdfAsImages ?? _faker.Random.Bool(),
|
shouldRenderPdfAsImages ?? _faker.Random.Bool(),
|
||||||
shouldPreserveBookStyles ?? _faker.Random.Bool());
|
shouldPreserveBookStyles ?? _faker.Random.Bool());
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -26,6 +26,7 @@ public class UserSettingsResponseFixture
|
|||||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Optional. Whether the "The" prefix is ignored by the alpha picker.</param>
|
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Optional. Whether the "The" prefix is ignored by the alpha picker.</param>
|
||||||
/// <param name="isThemeCachingEnabled">Optional. Whether the theme data served to this user is cached.</param>
|
/// <param name="isThemeCachingEnabled">Optional. Whether the theme data served to this user is cached.</param>
|
||||||
/// <param name="shouldAggregateMetadataWhenMissing">Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
|
/// <param name="shouldAggregateMetadataWhenMissing">Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
|
||||||
|
/// <param name="shouldAggregateArtworkWhenMissing">Optional. Whether the artwork of the media library items is aggregated from multiple providers, when it is missing.</param>
|
||||||
/// <param name="shouldRenderPdfAsImages">Optional. Whether PDF books are rendered as page images for the user.</param>
|
/// <param name="shouldRenderPdfAsImages">Optional. Whether PDF books are rendered as page images for the user.</param>
|
||||||
/// <param name="shouldPreserveBookStyles">Optional. Whether the styles of the book content are preserved when it is rendered for the user.</param>
|
/// <param name="shouldPreserveBookStyles">Optional. Whether the styles of the book content are preserved when it is rendered for the user.</param>
|
||||||
/// <returns>The created <see cref="UserSettingsResponse"/>.</returns>
|
/// <returns>The created <see cref="UserSettingsResponse"/>.</returns>
|
||||||
@@ -36,6 +37,7 @@ public class UserSettingsResponseFixture
|
|||||||
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
||||||
bool? isThemeCachingEnabled = null,
|
bool? isThemeCachingEnabled = null,
|
||||||
bool? shouldAggregateMetadataWhenMissing = null,
|
bool? shouldAggregateMetadataWhenMissing = null,
|
||||||
|
bool? shouldAggregateArtworkWhenMissing = null,
|
||||||
bool? shouldRenderPdfAsImages = null,
|
bool? shouldRenderPdfAsImages = null,
|
||||||
bool? shouldPreserveBookStyles = null)
|
bool? shouldPreserveBookStyles = null)
|
||||||
{
|
{
|
||||||
@@ -46,6 +48,7 @@ public class UserSettingsResponseFixture
|
|||||||
shouldIgnoreThePrefixForAlphaPicker ?? _faker.Random.Bool(),
|
shouldIgnoreThePrefixForAlphaPicker ?? _faker.Random.Bool(),
|
||||||
isThemeCachingEnabled ?? _faker.Random.Bool(),
|
isThemeCachingEnabled ?? _faker.Random.Bool(),
|
||||||
shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool(),
|
shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool(),
|
||||||
|
shouldAggregateArtworkWhenMissing ?? _faker.Random.Bool(),
|
||||||
shouldRenderPdfAsImages ?? _faker.Random.Bool(),
|
shouldRenderPdfAsImages ?? _faker.Random.Bool(),
|
||||||
shouldPreserveBookStyles ?? _faker.Random.Bool());
|
shouldPreserveBookStyles ?? _faker.Random.Bool());
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -25,6 +25,7 @@ public class UserSettingsFixture
|
|||||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker.</param>
|
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker.</param>
|
||||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached.</param>
|
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached.</param>
|
||||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
|
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
|
||||||
|
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing.</param>
|
||||||
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user.</param>
|
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user.</param>
|
||||||
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user.</param>
|
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user.</param>
|
||||||
/// <returns>The created <see cref="UserSettings"/>.</returns>
|
/// <returns>The created <see cref="UserSettings"/>.</returns>
|
||||||
@@ -35,6 +36,7 @@ public class UserSettingsFixture
|
|||||||
bool shouldIgnoreThePrefixForAlphaPicker = false,
|
bool shouldIgnoreThePrefixForAlphaPicker = false,
|
||||||
bool isThemeCachingEnabled = true,
|
bool isThemeCachingEnabled = true,
|
||||||
bool shouldAggregateMetadataWhenMissing = false,
|
bool shouldAggregateMetadataWhenMissing = false,
|
||||||
|
bool shouldAggregateArtworkWhenMissing = false,
|
||||||
bool shouldRenderPdfAsImages = false,
|
bool shouldRenderPdfAsImages = false,
|
||||||
bool shouldPreserveBookStyles = true)
|
bool shouldPreserveBookStyles = true)
|
||||||
{
|
{
|
||||||
@@ -45,6 +47,7 @@ public class UserSettingsFixture
|
|||||||
shouldIgnoreThePrefixForAlphaPicker,
|
shouldIgnoreThePrefixForAlphaPicker,
|
||||||
isThemeCachingEnabled,
|
isThemeCachingEnabled,
|
||||||
shouldAggregateMetadataWhenMissing,
|
shouldAggregateMetadataWhenMissing,
|
||||||
|
shouldAggregateArtworkWhenMissing,
|
||||||
shouldRenderPdfAsImages,
|
shouldRenderPdfAsImages,
|
||||||
shouldPreserveBookStyles);
|
shouldPreserveBookStyles);
|
||||||
return settings.Value;
|
return settings.Value;
|
||||||
|
|||||||
+2
-2
@@ -14,13 +14,13 @@ namespace Lumina.Application.UnitTests.Common.Mapping.UsersManagement.Users;
|
|||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public class UpdateUserSettingsRequestMappingTests
|
public class UpdateUserSettingsRequestMappingTests
|
||||||
{
|
{
|
||||||
private readonly UpdateUserSettingsRequestFixture _requestFixture = new();
|
private readonly UpdateUserSettingsRequestFixture _updateUserSettingsRequestFixture = new();
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
|
public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
UpdateUserSettingsRequest request = _requestFixture.Create(
|
UpdateUserSettingsRequest request = _updateUserSettingsRequestFixture.Create(
|
||||||
isPaginationEnabled: true,
|
isPaginationEnabled: true,
|
||||||
itemsPerPage: 48,
|
itemsPerPage: 48,
|
||||||
shouldIgnoreThePrefixForAlphaPicker: false,
|
shouldIgnoreThePrefixForAlphaPicker: false,
|
||||||
|
|||||||
+6
-6
@@ -80,7 +80,7 @@ public class UserSettingsTests
|
|||||||
UserId userId = _userIdFixture.Create();
|
UserId userId = _userIdFixture.Create();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<UserSettings> result = UserSettings.Create(userId, isPaginationEnabled: false, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: true, shouldRenderPdfAsImages: true, shouldPreserveBookStyles: true);
|
Result<UserSettings> result = UserSettings.Create(userId, isPaginationEnabled: false, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: true, shouldAggregateArtworkWhenMissing: true, shouldRenderPdfAsImages: true, shouldPreserveBookStyles: true);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.False(result.IsFailure);
|
Assert.False(result.IsFailure);
|
||||||
@@ -117,7 +117,7 @@ public class UserSettingsTests
|
|||||||
UserId userId = _userIdFixture.Create();
|
UserId userId = _userIdFixture.Create();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<UserSettings> result = UserSettings.Create(userId, isPaginationEnabled: true, itemsPerPage: itemsPerPage, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: false);
|
Result<UserSettings> result = UserSettings.Create(userId, isPaginationEnabled: true, itemsPerPage: itemsPerPage, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldAggregateArtworkWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: false);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.True(result.IsFailure);
|
Assert.True(result.IsFailure);
|
||||||
@@ -132,7 +132,7 @@ public class UserSettingsTests
|
|||||||
UserSettingsId id = _userSettingsIdFixture.Create();
|
UserSettingsId id = _userSettingsIdFixture.Create();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<UserSettings> result = UserSettings.Create(id, userId, isPaginationEnabled: true, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: true);
|
Result<UserSettings> result = UserSettings.Create(id, userId, isPaginationEnabled: true, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldAggregateArtworkWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: true);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.False(result.IsFailure);
|
Assert.False(result.IsFailure);
|
||||||
@@ -149,7 +149,7 @@ public class UserSettingsTests
|
|||||||
UserSettingsId id = _userSettingsIdFixture.Create();
|
UserSettingsId id = _userSettingsIdFixture.Create();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<UserSettings> result = UserSettings.Create(id, userId, isPaginationEnabled: true, itemsPerPage: 0, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: false);
|
Result<UserSettings> result = UserSettings.Create(id, userId, isPaginationEnabled: true, itemsPerPage: 0, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldAggregateArtworkWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: false);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.True(result.IsFailure);
|
Assert.True(result.IsFailure);
|
||||||
@@ -163,7 +163,7 @@ public class UserSettingsTests
|
|||||||
UserSettings userSettings = _userSettingsFixture.Create();
|
UserSettings userSettings = _userSettingsFixture.Create();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<Updated> result = userSettings.UpdateSettings(isPaginationEnabled: false, itemsPerPage: 12, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: false, shouldAggregateMetadataWhenMissing: true, shouldRenderPdfAsImages: true, shouldPreserveBookStyles: true);
|
Result<Updated> result = userSettings.UpdateSettings(isPaginationEnabled: false, itemsPerPage: 12, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: false, shouldAggregateMetadataWhenMissing: true, shouldAggregateArtworkWhenMissing: true, shouldRenderPdfAsImages: true, shouldPreserveBookStyles: true);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.False(result.IsFailure);
|
Assert.False(result.IsFailure);
|
||||||
@@ -185,7 +185,7 @@ public class UserSettingsTests
|
|||||||
UserSettings userSettings = _userSettingsFixture.Create();
|
UserSettings userSettings = _userSettingsFixture.Create();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Result<Updated> result = userSettings.UpdateSettings(isPaginationEnabled: true, itemsPerPage: itemsPerPage, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: false);
|
Result<Updated> result = userSettings.UpdateSettings(isPaginationEnabled: true, itemsPerPage: itemsPerPage, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldAggregateArtworkWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: false);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.True(result.IsFailure);
|
Assert.True(result.IsFailure);
|
||||||
|
|||||||
+5
-4
@@ -21,6 +21,7 @@ namespace Lumina.Infrastructure.UnitTests.Common.Validation;
|
|||||||
public class ValidationOptionsTests
|
public class ValidationOptionsTests
|
||||||
{
|
{
|
||||||
private readonly IFixture _fixture;
|
private readonly IFixture _fixture;
|
||||||
|
private readonly ValidationOptionsFixture _validationOptionsFixture = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ValidationOptionsTests"/> class.
|
/// Initializes a new instance of the <see cref="ValidationOptionsTests"/> class.
|
||||||
@@ -35,7 +36,7 @@ public class ValidationOptionsTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
string name = _fixture.Create<string>();
|
string name = _fixture.Create<string>();
|
||||||
ValidationOptionsFixture options = _fixture.Create<ValidationOptionsFixture>();
|
ValidationOptionsFixture options = _validationOptionsFixture.Create();
|
||||||
IValidator<ValidationOptionsFixture> validator = Substitute.For<IValidator<ValidationOptionsFixture>>();
|
IValidator<ValidationOptionsFixture> validator = Substitute.For<IValidator<ValidationOptionsFixture>>();
|
||||||
validator.Validate(options).Returns([]);
|
validator.Validate(options).Returns([]);
|
||||||
ValidationOptions<ValidationOptionsFixture> sut = new(name, validator);
|
ValidationOptions<ValidationOptionsFixture> sut = new(name, validator);
|
||||||
@@ -55,7 +56,7 @@ public class ValidationOptionsTests
|
|||||||
// Arrange
|
// Arrange
|
||||||
string name = _fixture.Create<string>();
|
string name = _fixture.Create<string>();
|
||||||
string differentName = _fixture.Create<string>();
|
string differentName = _fixture.Create<string>();
|
||||||
ValidationOptionsFixture options = _fixture.Create<ValidationOptionsFixture>();
|
ValidationOptionsFixture options = _validationOptionsFixture.Create();
|
||||||
IValidator<ValidationOptionsFixture> validator = Substitute.For<IValidator<ValidationOptionsFixture>>();
|
IValidator<ValidationOptionsFixture> validator = Substitute.For<IValidator<ValidationOptionsFixture>>();
|
||||||
ValidationOptions<ValidationOptionsFixture> sut = new(name, validator);
|
ValidationOptions<ValidationOptionsFixture> sut = new(name, validator);
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ public class ValidationOptionsTests
|
|||||||
public void Validate_WhenNullName_ShouldValidateOptions()
|
public void Validate_WhenNullName_ShouldValidateOptions()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ValidationOptionsFixture options = _fixture.Create<ValidationOptionsFixture>();
|
ValidationOptionsFixture options = _validationOptionsFixture.Create();
|
||||||
IValidator<ValidationOptionsFixture> validator = Substitute.For<IValidator<ValidationOptionsFixture>>();
|
IValidator<ValidationOptionsFixture> validator = Substitute.For<IValidator<ValidationOptionsFixture>>();
|
||||||
validator.Validate(options).Returns([]);
|
validator.Validate(options).Returns([]);
|
||||||
ValidationOptions<ValidationOptionsFixture> sut = new(null, validator);
|
ValidationOptions<ValidationOptionsFixture> sut = new(null, validator);
|
||||||
@@ -105,7 +106,7 @@ public class ValidationOptionsTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
string name = _fixture.Create<string>();
|
string name = _fixture.Create<string>();
|
||||||
ValidationOptionsFixture options = _fixture.Create<ValidationOptionsFixture>();
|
ValidationOptionsFixture options = _validationOptionsFixture.Create();
|
||||||
IValidator<ValidationOptionsFixture> validator = Substitute.For<IValidator<ValidationOptionsFixture>>();
|
IValidator<ValidationOptionsFixture> validator = Substitute.For<IValidator<ValidationOptionsFixture>>();
|
||||||
List<Error> validationFailures =
|
List<Error> validationFailures =
|
||||||
[
|
[
|
||||||
|
|||||||
+21
-26
@@ -1,6 +1,7 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Presentation.Web.Common.Primitives;
|
using Lumina.Presentation.Web.Common.Primitives;
|
||||||
using Lumina.Presentation.Web.Common.Validation;
|
using Lumina.Presentation.Web.Common.Validation;
|
||||||
|
using Lumina.Presentation.Web.Fixtures.Common.Validation;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using NSubstitute;
|
using NSubstitute;
|
||||||
using System;
|
using System;
|
||||||
@@ -17,15 +18,17 @@ namespace Lumina.Presentation.Web.UnitTests.Common.Validation;
|
|||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public class ValidationOptionsTests
|
public class ValidationOptionsTests
|
||||||
{
|
{
|
||||||
|
private readonly ValidationOptionsFixture _validationOptionsFixture = new();
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Validate_WhenMatchingName_ShouldValidateOptions()
|
public void Validate_WhenMatchingName_ShouldValidateOptions()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
string optionsName = "OptionsName";
|
string optionsName = "OptionsName";
|
||||||
TestOptions options = new();
|
ValidationOptionsFixture options = _validationOptionsFixture.Create();
|
||||||
IValidator<TestOptions> validator = Substitute.For<IValidator<TestOptions>>();
|
IValidator<ValidationOptionsFixture> validator = Substitute.For<IValidator<ValidationOptionsFixture>>();
|
||||||
validator.Validate(options).Returns([]);
|
validator.Validate(options).Returns([]);
|
||||||
ValidationOptions<TestOptions> sut = new(optionsName, validator);
|
ValidationOptions<ValidationOptionsFixture> sut = new(optionsName, validator);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
ValidateOptionsResult result = sut.Validate(optionsName, options);
|
ValidateOptionsResult result = sut.Validate(optionsName, options);
|
||||||
@@ -42,9 +45,9 @@ public class ValidationOptionsTests
|
|||||||
// Arrange
|
// Arrange
|
||||||
string optionsName = "OptionsName";
|
string optionsName = "OptionsName";
|
||||||
string differentOptionsName = "DifferentOptionsName";
|
string differentOptionsName = "DifferentOptionsName";
|
||||||
TestOptions options = new();
|
ValidationOptionsFixture options = _validationOptionsFixture.Create();
|
||||||
IValidator<TestOptions> validator = Substitute.For<IValidator<TestOptions>>();
|
IValidator<ValidationOptionsFixture> validator = Substitute.For<IValidator<ValidationOptionsFixture>>();
|
||||||
ValidationOptions<TestOptions> sut = new(optionsName, validator);
|
ValidationOptions<ValidationOptionsFixture> sut = new(optionsName, validator);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
ValidateOptionsResult result = sut.Validate(differentOptionsName, options);
|
ValidateOptionsResult result = sut.Validate(differentOptionsName, options);
|
||||||
@@ -58,10 +61,10 @@ public class ValidationOptionsTests
|
|||||||
public void Validate_WhenNullName_ShouldValidateOptions()
|
public void Validate_WhenNullName_ShouldValidateOptions()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
TestOptions options = new();
|
ValidationOptionsFixture options = _validationOptionsFixture.Create();
|
||||||
IValidator<TestOptions> validator = Substitute.For<IValidator<TestOptions>>();
|
IValidator<ValidationOptionsFixture> validator = Substitute.For<IValidator<ValidationOptionsFixture>>();
|
||||||
validator.Validate(options).Returns([]);
|
validator.Validate(options).Returns([]);
|
||||||
ValidationOptions<TestOptions> sut = new(null, validator);
|
ValidationOptions<ValidationOptionsFixture> sut = new(null, validator);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
ValidateOptionsResult result = sut.Validate("AnyOptionsName", options);
|
ValidateOptionsResult result = sut.Validate("AnyOptionsName", options);
|
||||||
@@ -77,15 +80,15 @@ public class ValidationOptionsTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
string optionsName = "OptionsName";
|
string optionsName = "OptionsName";
|
||||||
IValidator<TestOptions> validator = Substitute.For<IValidator<TestOptions>>();
|
IValidator<ValidationOptionsFixture> validator = Substitute.For<IValidator<ValidationOptionsFixture>>();
|
||||||
ValidationOptions<TestOptions> sut = new(optionsName, validator);
|
ValidationOptions<ValidationOptionsFixture> sut = new(optionsName, validator);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Action act = () => sut.Validate(optionsName, null!);
|
Action act = () => sut.Validate(optionsName, null!);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Throws<ArgumentNullException>(act);
|
Assert.Throws<ArgumentNullException>(act);
|
||||||
validator.DidNotReceive().Validate(Arg.Any<TestOptions>());
|
validator.DidNotReceive().Validate(Arg.Any<ValidationOptionsFixture>());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -93,14 +96,14 @@ public class ValidationOptionsTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
string optionsName = "OptionsName";
|
string optionsName = "OptionsName";
|
||||||
TestOptions options = new();
|
ValidationOptionsFixture options = _validationOptionsFixture.Create();
|
||||||
IValidator<TestOptions> validator = Substitute.For<IValidator<TestOptions>>();
|
IValidator<ValidationOptionsFixture> validator = Substitute.For<IValidator<ValidationOptionsFixture>>();
|
||||||
List<Error> validationFailures =
|
List<Error> validationFailures =
|
||||||
[
|
[
|
||||||
Error.Validation("PropertyName", "Error Message")
|
Error.Validation("PropertyName", "Error Message")
|
||||||
];
|
];
|
||||||
validator.Validate(options).Returns(validationFailures);
|
validator.Validate(options).Returns(validationFailures);
|
||||||
ValidationOptions<TestOptions> sut = new(optionsName, validator);
|
ValidationOptions<ValidationOptionsFixture> sut = new(optionsName, validator);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
ValidateOptionsResult result = sut.Validate(optionsName, options);
|
ValidateOptionsResult result = sut.Validate(optionsName, options);
|
||||||
@@ -117,15 +120,15 @@ public class ValidationOptionsTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
string optionsName = "OptionsName";
|
string optionsName = "OptionsName";
|
||||||
TestOptions options = new();
|
ValidationOptionsFixture options = _validationOptionsFixture.Create();
|
||||||
IValidator<TestOptions> validator = Substitute.For<IValidator<TestOptions>>();
|
IValidator<ValidationOptionsFixture> validator = Substitute.For<IValidator<ValidationOptionsFixture>>();
|
||||||
List<Error> validationFailures =
|
List<Error> validationFailures =
|
||||||
[
|
[
|
||||||
Error.Validation("PropertyOne", "First Error Message"),
|
Error.Validation("PropertyOne", "First Error Message"),
|
||||||
Error.Validation("PropertyTwo", "Second Error Message")
|
Error.Validation("PropertyTwo", "Second Error Message")
|
||||||
];
|
];
|
||||||
validator.Validate(options).Returns(validationFailures);
|
validator.Validate(options).Returns(validationFailures);
|
||||||
ValidationOptions<TestOptions> sut = new(optionsName, validator);
|
ValidationOptions<ValidationOptionsFixture> sut = new(optionsName, validator);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
ValidateOptionsResult result = sut.Validate(optionsName, options);
|
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 'PropertyOne' with error: 'First Error Message'", result.Failures);
|
||||||
Assert.Contains("Options validation failed for 'PropertyTwo' with error: 'Second Error Message'", result.Failures);
|
Assert.Contains("Options validation failed for 'PropertyTwo' with error: 'Second Error Message'", result.Failures);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Placeholder options type used to exercise the generic <see cref="ValidationOptions{TOptions}"/> class.
|
|
||||||
/// </summary>
|
|
||||||
[ExcludeFromCodeCoverage]
|
|
||||||
public sealed class TestOptions
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user