mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 15:11:10 +00:00
Merge branch 'feature/add-metadata-aggregation' into feature/add-artwork-provider-and-metadata-aggregation
This commit is contained in:
commit
b47588cf83
168 files changed
+3503
-1062
No files matched your search
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryContentLocationEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryContentLocationEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryContentLocationEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">Optional. The path of the media library content location.</param>
|
||||
/// <returns>The created <see cref="LibraryContentLocationEntity"/>.</returns>
|
||||
public LibraryContentLocationEntity Create(
|
||||
string? path = null)
|
||||
{
|
||||
return new LibraryContentLocationEntity
|
||||
{
|
||||
Path = path ?? _faker.System.DirectoryPath()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryContentLocationEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryContentLocationEntity"/> instances.</returns>
|
||||
public List<LibraryContentLocationEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -27,7 +27,7 @@ public class LibraryEntityFixture
|
||||
/// <param name="coverImage">Optional. The cover image path of the media library.</param>
|
||||
/// <param name="isEnabled">Whether the media library is enabled or not.</param>
|
||||
/// <param name="isLocked">Whether the media library is locked or not.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether the metadata should be saved in the media directories or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during a scan or not.</param>
|
||||
/// <returns>The created media library entity.</returns>
|
||||
@@ -40,7 +40,7 @@ public class LibraryEntityFixture
|
||||
string? coverImage = null,
|
||||
bool isEnabled = true,
|
||||
bool isLocked = false,
|
||||
bool downloadMetadataFromWeb = true,
|
||||
bool canDownloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = true,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false)
|
||||
{
|
||||
@@ -56,7 +56,7 @@ public class LibraryEntityFixture
|
||||
LibraryScans = [],
|
||||
IsEnabled = isEnabled,
|
||||
IsLocked = isLocked,
|
||||
DownloadMetadataFromWeb = downloadMetadataFromWeb,
|
||||
CanDownloadMetadataFromWeb = canDownloadMetadataFromWeb,
|
||||
ShouldSaveMetadataInMediaDirectories = shouldSaveMetadataInMediaDirectories,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan = shouldSkipUnchangedDirectoriesDuringScan,
|
||||
CreatedOnUtc = default,
|
||||
|
||||
+7
-2
@@ -21,14 +21,19 @@ public class LibraryMetadataProviderConfigurationEntityFixture
|
||||
/// <param name="libraryId">The Id of the media library the configuration belongs to.</param>
|
||||
/// <param name="pluginId">The Id of the plugin providing the metadata.</param>
|
||||
/// <param name="rank">The rank of the metadata provider, determining the order in which providers are tried.</param>
|
||||
/// <param name="isEnabled">Whether the metadata provider is enabled or not.</param>
|
||||
/// <returns>The created <see cref="LibraryMetadataProviderConfigurationEntity"/>.</returns>
|
||||
public LibraryMetadataProviderConfigurationEntity Create(Guid libraryId, Guid pluginId, int rank)
|
||||
public LibraryMetadataProviderConfigurationEntity Create(
|
||||
Guid libraryId,
|
||||
Guid pluginId,
|
||||
int rank,
|
||||
bool isEnabled = true)
|
||||
{
|
||||
return new Faker<LibraryMetadataProviderConfigurationEntity>()
|
||||
.RuleFor(configuration => configuration.Id, faker => faker.Random.Guid())
|
||||
.RuleFor(configuration => configuration.LibraryId, libraryId)
|
||||
.RuleFor(configuration => configuration.PluginId, pluginId)
|
||||
.RuleFor(configuration => configuration.IsEnabled, faker => faker.Random.Bool())
|
||||
.RuleFor(configuration => configuration.IsEnabled, isEnabled)
|
||||
.RuleFor(configuration => configuration.Rank, rank)
|
||||
.RuleFor(configuration => configuration.CreatedOnUtc, faker => faker.Date.Past())
|
||||
.RuleFor(configuration => configuration.CreatedBy, faker => faker.Random.Guid())
|
||||
|
||||
+13
-4
@@ -21,17 +21,26 @@ public class PluginEntityFixture
|
||||
/// Creates a random valid <see cref="PluginEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">The Id of the plugin, or <see langword="null"/> to generate a random one.</param>
|
||||
/// <param name="name">The name of the plugin, or <see langword="null"/> to generate a random one.</param>
|
||||
/// <param name="loadStatus">The load status of the plugin, or <see langword="null"/> to generate a random one.</param>
|
||||
/// <param name="settingsJson">The serialized settings of the plugin, or <see langword="null"/> to generate random ones.</param>
|
||||
/// <param name="includeSettingsJson">Whether the settings should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PluginEntity"/>.</returns>
|
||||
public PluginEntity Create(Guid? id = null)
|
||||
public PluginEntity Create(
|
||||
Guid? id = null,
|
||||
string? name = null,
|
||||
PluginLoadStatus? loadStatus = null,
|
||||
string? settingsJson = null,
|
||||
bool includeSettingsJson = true)
|
||||
{
|
||||
return new Faker<PluginEntity>()
|
||||
.RuleFor(plugin => plugin.Id, faker => id ?? faker.Random.Guid())
|
||||
.RuleFor(plugin => plugin.Name, faker => faker.Company.CompanyName())
|
||||
.RuleFor(plugin => plugin.Name, faker => name ?? faker.Company.CompanyName())
|
||||
.RuleFor(plugin => plugin.Author, faker => faker.Name.FullName())
|
||||
.RuleFor(plugin => plugin.Version, faker => faker.System.Semver())
|
||||
.RuleFor(plugin => plugin.Description, faker => faker.Lorem.Sentence())
|
||||
.RuleFor(plugin => plugin.LoadStatus, faker => faker.PickRandom<PluginLoadStatus>())
|
||||
.RuleFor(plugin => plugin.SettingsJson, faker => JsonSerializer.Serialize(new Dictionary<string, string> { [faker.Random.String2(1, 10)] = faker.Random.String2(1, 20) }))
|
||||
.RuleFor(plugin => plugin.LoadStatus, faker => loadStatus ?? faker.PickRandom<PluginLoadStatus>())
|
||||
.RuleFor(plugin => plugin.SettingsJson, faker => includeSettingsJson ? settingsJson ?? JsonSerializer.Serialize(new Dictionary<string, string> { [faker.Random.String2(1, 10)] = faker.Random.String2(1, 20) }) : null)
|
||||
.RuleFor(plugin => plugin.CreatedOnUtc, faker => faker.Date.Past())
|
||||
.RuleFor(plugin => plugin.CreatedBy, faker => faker.Random.Guid())
|
||||
.RuleFor(plugin => plugin.UpdatedOnUtc, faker => faker.Date.Recent())
|
||||
|
||||
+8
-5
@@ -22,16 +22,18 @@ public class UserSettingsEntityFixture
|
||||
/// <param name="userId">Optional. The Id of the user that owns these settings.</param>
|
||||
/// <param name="isPaginationEnabled">Optional. Whether pagination is enabled for the user, or not.</param>
|
||||
/// <param name="itemsPerPage">Optional. The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">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="shouldAggregateMetadataWhenMissing">Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||
/// <returns>The created user settings entity.</returns>
|
||||
public UserSettingsEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? userId = null,
|
||||
bool? isPaginationEnabled = null,
|
||||
int? itemsPerPage = null,
|
||||
bool? ignoreThePrefixForAlphaPicker = null,
|
||||
bool? isThemeCachingEnabled = null)
|
||||
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
||||
bool? isThemeCachingEnabled = null,
|
||||
bool? shouldAggregateMetadataWhenMissing = null)
|
||||
{
|
||||
return new Faker<UserSettingsEntity>()
|
||||
.CustomInstantiator(f => new UserSettingsEntity
|
||||
@@ -40,8 +42,9 @@ public class UserSettingsEntityFixture
|
||||
UserId = userId ?? Guid.NewGuid(),
|
||||
IsPaginationEnabled = isPaginationEnabled ?? f.Random.Bool(),
|
||||
ItemsPerPage = itemsPerPage ?? f.Random.Int(1, 100),
|
||||
IgnoreThePrefixForAlphaPicker = ignoreThePrefixForAlphaPicker ?? f.Random.Bool(),
|
||||
IsThemeCachingEnabled = isThemeCachingEnabled ?? f.Random.Bool()
|
||||
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker ?? f.Random.Bool(),
|
||||
IsThemeCachingEnabled = isThemeCachingEnabled ?? f.Random.Bool(),
|
||||
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing ?? f.Random.Bool()
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.Infrastructure.Models.DTO.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.Infrastructure.Models.DTO.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaSettingsDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaSettingsDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaSettingsDto"/>.
|
||||
/// </summary>
|
||||
/// <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="booksDirectory">Optional. The directory where the media item files are stored.</param>
|
||||
/// <returns>The created <see cref="MediaSettingsDto"/>.</returns>
|
||||
public MediaSettingsDto Create(
|
||||
string? rootDirectory = null,
|
||||
string? librariesDirectory = null,
|
||||
string? booksDirectory = null)
|
||||
{
|
||||
return new MediaSettingsDto
|
||||
{
|
||||
RootDirectory = rootDirectory ?? _faker.System.DirectoryPath(),
|
||||
LibrariesDirectory = librariesDirectory ?? _faker.System.DirectoryPath(),
|
||||
BooksDirectory = booksDirectory ?? _faker.System.DirectoryPath()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaSettingsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaSettingsDto"/> instances.</returns>
|
||||
public List<MediaSettingsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -2,7 +2,6 @@
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
@@ -25,7 +24,7 @@ public class AddLibraryCommandFixture
|
||||
/// <param name="coverImage">Optional. The cover image path of the media library.</param>
|
||||
/// <param name="isEnabled">Whether the media library is enabled or not.</param>
|
||||
/// <param name="isLocked">Whether the media library is locked or not.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether the metadata should be saved in the media directories or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during a scan or not.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
@@ -36,7 +35,7 @@ public class AddLibraryCommandFixture
|
||||
string? coverImage = null,
|
||||
bool isEnabled = true,
|
||||
bool isLocked = false,
|
||||
bool downloadMetadataFromWeb = true,
|
||||
bool canDownloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = true,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false)
|
||||
{
|
||||
@@ -58,7 +57,7 @@ public class AddLibraryCommandFixture
|
||||
.RuleFor(x => x.CoverImage, f => coverImage ?? f.System.FilePath())
|
||||
.RuleFor(x => x.IsEnabled, isEnabled)
|
||||
.RuleFor(x => x.IsLocked, isLocked)
|
||||
.RuleFor(x => x.DownloadMetadataFromWeb, downloadMetadataFromWeb)
|
||||
.RuleFor(x => x.CanDownloadMetadataFromWeb, canDownloadMetadataFromWeb)
|
||||
.RuleFor(x => x.ShouldSaveMetadataInMediaDirectories, shouldSaveMetadataInMediaDirectories)
|
||||
.RuleFor(x => x.ShouldSkipUnchangedDirectoriesDuringScan, shouldSkipUnchangedDirectoriesDuringScan)
|
||||
.Generate();
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ public class UpdateLibraryCommandFixture
|
||||
/// <param name="coverImage">Optional. The cover image path of the media library.</param>
|
||||
/// <param name="isEnabled">Whether the media library is enabled or not.</param>
|
||||
/// <param name="isLocked">Whether the media library is locked or not.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether the metadata should be saved in the media directories or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during a scan or not.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
@@ -40,7 +40,7 @@ public class UpdateLibraryCommandFixture
|
||||
string? coverImage = null,
|
||||
bool isEnabled = true,
|
||||
bool isLocked = false,
|
||||
bool downloadMetadataFromWeb = true,
|
||||
bool canDownloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = true,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ public class UpdateLibraryCommandFixture
|
||||
.RuleFor(x => x.CoverImage, f => coverImage ?? f.System.FilePath())
|
||||
.RuleFor(x => x.IsEnabled, isEnabled)
|
||||
.RuleFor(x => x.IsLocked, isLocked)
|
||||
.RuleFor(x => x.DownloadMetadataFromWeb, downloadMetadataFromWeb)
|
||||
.RuleFor(x => x.CanDownloadMetadataFromWeb, canDownloadMetadataFromWeb)
|
||||
.RuleFor(x => x.ShouldSaveMetadataInMediaDirectories, shouldSaveMetadataInMediaDirectories)
|
||||
.RuleFor(x => x.ShouldSkipUnchangedDirectoriesDuringScan, shouldSkipUnchangedDirectoriesDuringScan)
|
||||
.Generate();
|
||||
|
||||
+7
-5
@@ -19,21 +19,23 @@ public class UpdateUserSettingsCommandFixture
|
||||
/// </summary>
|
||||
/// <param name="isPaginationEnabled">Optional. Whether pagination is enabled for the user, or not.</param>
|
||||
/// <param name="itemsPerPage">Optional. The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">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>
|
||||
/// <returns>The created command.</returns>
|
||||
public UpdateUserSettingsCommand Create(
|
||||
bool? isPaginationEnabled = null,
|
||||
int? itemsPerPage = null,
|
||||
bool? ignoreThePrefixForAlphaPicker = null,
|
||||
bool? isThemeCachingEnabled = null)
|
||||
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
||||
bool? isThemeCachingEnabled = null,
|
||||
bool? shouldAggregateMetadataWhenMissing = null)
|
||||
{
|
||||
return new Faker<UpdateUserSettingsCommand>()
|
||||
.CustomInstantiator(f => new UpdateUserSettingsCommand(default, default, default, default))
|
||||
.CustomInstantiator(f => new UpdateUserSettingsCommand(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.IgnoreThePrefixForAlphaPicker, f => ignoreThePrefixForAlphaPicker ?? f.Random.Bool())
|
||||
.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())
|
||||
.Generate();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user