Adds artwork provider system and Calibre plugin

This commit is contained in:
BinaryAlley committed 2026-08-24 14:18:14 -07:00
1 parent c82fadc7a2
commit 6693ff3f60
124 files changed
+9715 -74

No files matched your search

@@ -0,0 +1,57 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Common.DataAccess.Entities.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Plugins;
/// <summary>
/// Fixture class for the <see cref="LibraryArtworkProviderConfigurationEntity"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryArtworkProviderConfigurationEntityFixture
{
/// <summary>
/// Creates a random valid <see cref="LibraryArtworkProviderConfigurationEntity"/> for the provided media library, plugin and rank.
/// </summary>
/// <param name="libraryId">The Id of the media library the configuration belongs to.</param>
/// <param name="pluginId">The Id of the plugin providing the artwork.</param>
/// <param name="rank">The rank of the artwork provider, determining the order in which providers are tried.</param>
/// <param name="isEnabled">Whether the artwork provider is enabled or not.</param>
/// <returns>The created <see cref="LibraryArtworkProviderConfigurationEntity"/>.</returns>
public LibraryArtworkProviderConfigurationEntity Create(
Guid libraryId,
Guid pluginId,
int rank,
bool isEnabled = true)
{
return new Faker<LibraryArtworkProviderConfigurationEntity>()
.RuleFor(configuration => configuration.Id, faker => faker.Random.Guid())
.RuleFor(configuration => configuration.LibraryId, libraryId)
.RuleFor(configuration => configuration.PluginId, pluginId)
.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())
.RuleFor(configuration => configuration.UpdatedOnUtc, faker => faker.Date.Recent())
.RuleFor(configuration => configuration.UpdatedBy, faker => faker.Random.Guid())
.Generate();
}
/// <summary>
/// Creates a list of <see cref="LibraryArtworkProviderConfigurationEntity"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <param name="libraryId">The Id of the media library the configurations belong to.</param>
/// <param name="pluginId">The Id of the plugin providing the artwork.</param>
/// <param name="rank">The rank of the artwork providers.</param>
/// <returns>List of configured <see cref="LibraryArtworkProviderConfigurationEntity"/> instances.</returns>
public List<LibraryArtworkProviderConfigurationEntity> CreateMany(int count, Guid libraryId, Guid pluginId, int rank)
{
return [.. Enumerable.Range(0, count).Select(_ => Create(libraryId, pluginId, rank))];
}
}
@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.Plugins.Commands.ReorderLibraryArtworkProviders;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Plugins.Commands.ReorderLibraryArtworkProviders;
/// <summary>
/// Fixture class for the <see cref="ReorderLibraryArtworkProvidersCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReorderLibraryArtworkProvidersCommandFixture
{
/// <summary>
/// Creates a random valid command to reorder the artwork providers of a media library.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library whose artwork providers are reordered.</param>
/// <param name="pluginIds">Optional. The plugin Ids in the new order.</param>
/// <returns>The created command.</returns>
public ReorderLibraryArtworkProvidersCommand Create(
Guid? libraryId = null,
IReadOnlyList<Guid>? pluginIds = null)
{
return new Faker<ReorderLibraryArtworkProvidersCommand>()
.CustomInstantiator(f => new ReorderLibraryArtworkProvidersCommand(
default,
default!))
.RuleFor(x => x.LibraryId, libraryId ?? Guid.NewGuid())
.RuleFor(x => x.PluginIds, f => pluginIds ?? [Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()])
.Generate();
}
/// <summary>
/// Creates a list of <see cref="ReorderLibraryArtworkProvidersCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ReorderLibraryArtworkProvidersCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,50 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.Plugins.Commands.SetLibraryArtworkProviderEnabled;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Plugins.Commands.SetLibraryArtworkProviderEnabled;
/// <summary>
/// Fixture class for the <see cref="SetLibraryArtworkProviderEnabledCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class SetLibraryArtworkProviderEnabledCommandFixture
{
/// <summary>
/// Creates a random valid command to enable or disable an artwork provider for a media library.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library whose artwork provider is enabled or disabled.</param>
/// <param name="pluginId">Optional. The Id of the plugin providing the artwork.</param>
/// <param name="isEnabled">Whether the artwork provider should be enabled for the media library.</param>
/// <returns>The created command.</returns>
public SetLibraryArtworkProviderEnabledCommand Create(
Guid? libraryId = null,
Guid? pluginId = null,
bool isEnabled = true)
{
return new Faker<SetLibraryArtworkProviderEnabledCommand>()
.CustomInstantiator(f => new SetLibraryArtworkProviderEnabledCommand(
default,
default,
true))
.RuleFor(x => x.LibraryId, libraryId ?? Guid.NewGuid())
.RuleFor(x => x.PluginId, pluginId ?? Guid.NewGuid())
.RuleFor(x => x.IsEnabled, isEnabled)
.Generate();
}
/// <summary>
/// Creates a list of <see cref="SetLibraryArtworkProviderEnabledCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<SetLibraryArtworkProviderEnabledCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,41 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.Plugins.Queries.GetLibraryArtworkProviders;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.Plugins.Queries.GetLibraryArtworkProviders;
/// <summary>
/// Fixture class for the <see cref="GetLibraryArtworkProvidersQuery"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetLibraryArtworkProvidersQueryFixture
{
/// <summary>
/// Creates a random valid query to get the artwork providers of a media library.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library whose artwork providers are retrieved.</param>
/// <returns>The created query.</returns>
public GetLibraryArtworkProvidersQuery Create(
Guid? libraryId = null)
{
return new Faker<GetLibraryArtworkProvidersQuery>()
.CustomInstantiator(f => new GetLibraryArtworkProvidersQuery(
libraryId ?? Guid.NewGuid()))
.Generate();
}
/// <summary>
/// Creates a list of <see cref="GetLibraryArtworkProvidersQuery"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<GetLibraryArtworkProvidersQuery> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}