mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 05:11:10 +00:00
Adds artwork provider system and Calibre plugin
This commit is contained in:
1 parent
c82fadc7a2
commit
6693ff3f60
124 files changed
+9715
-74
No files matched your search
+57
@@ -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))];
|
||||
}
|
||||
}
|
||||
+46
@@ -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())];
|
||||
}
|
||||
}
|
||||
+50
@@ -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())];
|
||||
}
|
||||
}
|
||||
+41
@@ -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())];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.DTO.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ArtworkDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ArtworkDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates an <see cref="ArtworkDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="localPath">Optional. The local file system path of the artwork.</param>
|
||||
/// <param name="remoteUrl">Optional. The remote URL of the artwork.</param>
|
||||
/// <returns>The created <see cref="ArtworkDto"/>.</returns>
|
||||
public ArtworkDto Create(
|
||||
string? localPath = null,
|
||||
string? remoteUrl = null)
|
||||
{
|
||||
return new ArtworkDto(localPath, remoteUrl);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ArtworkDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ArtworkDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetLibraryArtworkProvidersRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetLibraryArtworkProvidersRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetLibraryArtworkProvidersRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library whose artwork providers are retrieved.</param>
|
||||
/// <returns>The created <see cref="GetLibraryArtworkProvidersRequest"/>.</returns>
|
||||
public GetLibraryArtworkProvidersRequest Create(
|
||||
Guid? libraryId = null)
|
||||
{
|
||||
return new GetLibraryArtworkProvidersRequest(
|
||||
libraryId ?? _faker.Random.Guid()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetLibraryArtworkProvidersRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetLibraryArtworkProvidersRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ReorderLibraryArtworkProvidersRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReorderLibraryArtworkProvidersRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ReorderLibraryArtworkProvidersRequest"/>.
|
||||
/// </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 <see cref="ReorderLibraryArtworkProvidersRequest"/>.</returns>
|
||||
public ReorderLibraryArtworkProvidersRequest Create(
|
||||
Guid? libraryId = null,
|
||||
IReadOnlyList<Guid>? pluginIds = null)
|
||||
{
|
||||
return new ReorderLibraryArtworkProvidersRequest(
|
||||
libraryId ?? _faker.Random.Guid(),
|
||||
pluginIds ?? [Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()]
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ReorderLibraryArtworkProvidersRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ReorderLibraryArtworkProvidersRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="SetLibraryArtworkProviderEnabledRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SetLibraryArtworkProviderEnabledRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="SetLibraryArtworkProviderEnabledRequest"/>.
|
||||
/// </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">Optional. Whether the artwork provider should be enabled.</param>
|
||||
/// <returns>The created <see cref="SetLibraryArtworkProviderEnabledRequest"/>.</returns>
|
||||
public SetLibraryArtworkProviderEnabledRequest Create(
|
||||
Guid? libraryId = null,
|
||||
Guid? pluginId = null,
|
||||
bool? isEnabled = null)
|
||||
{
|
||||
return new SetLibraryArtworkProviderEnabledRequest(
|
||||
libraryId ?? _faker.Random.Guid(),
|
||||
pluginId ?? _faker.Random.Guid(),
|
||||
isEnabled ?? _faker.Random.Bool()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="SetLibraryArtworkProviderEnabledRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<SetLibraryArtworkProviderEnabledRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryArtworkProviderResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryArtworkProviderResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryArtworkProviderResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">Optional. The Id of the plugin providing the artwork.</param>
|
||||
/// <param name="name">Optional. The display name of the artwork provider.</param>
|
||||
/// <param name="isEnabled">Optional. Whether the artwork provider is enabled for the media library.</param>
|
||||
/// <param name="rank">Optional. The rank of the artwork provider.</param>
|
||||
/// <returns>The created <see cref="LibraryArtworkProviderResponse"/>.</returns>
|
||||
public LibraryArtworkProviderResponse Create(
|
||||
Guid? pluginId = null,
|
||||
string? name = null,
|
||||
bool? isEnabled = null,
|
||||
int? rank = null)
|
||||
{
|
||||
return new LibraryArtworkProviderResponse(
|
||||
pluginId ?? Guid.NewGuid(),
|
||||
name ?? _faker.Company.CompanyName(),
|
||||
isEnabled ?? _faker.Random.Bool(),
|
||||
rank ?? _faker.Random.Int(1, 100));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryArtworkProviderResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<LibraryArtworkProviderResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Fixtures.Common.Setup;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="HttpMessageHandler"/> test double that returns the configured response for every request, without performing any network I/O.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
internal sealed class StubHttpMessageHandler : HttpMessageHandler
|
||||
{
|
||||
private HttpStatusCode _statusCode;
|
||||
private byte[] _responseBody;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StubHttpMessageHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="statusCode">The initial status code of the response to return.</param>
|
||||
/// <param name="responseBody">The initial body of the response to return.</param>
|
||||
public StubHttpMessageHandler(HttpStatusCode statusCode = HttpStatusCode.OK, byte[]? responseBody = null)
|
||||
{
|
||||
_statusCode = statusCode;
|
||||
_responseBody = responseBody ?? [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the response to return for every subsequent request.
|
||||
/// </summary>
|
||||
/// <param name="statusCode">The status code of the response to return.</param>
|
||||
/// <param name="responseBody">The body of the response to return.</param>
|
||||
public void SetResponse(HttpStatusCode statusCode, byte[] responseBody)
|
||||
{
|
||||
_statusCode = statusCode;
|
||||
_responseBody = responseBody;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a response with the configured status code and body.
|
||||
/// </summary>
|
||||
/// <param name="request">The request, which is ignored.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to cancel the operation.</param>
|
||||
/// <returns>The configured response.</returns>
|
||||
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(new HttpResponseMessage(_statusCode)
|
||||
{
|
||||
Content = new ByteArrayContent(_responseBody)
|
||||
});
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Plugins.Calibre.Common.Models.DTO.Opf;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.Calibre.Fixtures.Common.Models.DTO.Opf;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="OpfContributorDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
internal sealed class OpfContributorDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates an <see cref="OpfContributorDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the contributor.</param>
|
||||
/// <param name="role">The role code of the contributor, for example <c>bkp</c> for the book producer.</param>
|
||||
/// <returns>The created <see cref="OpfContributorDto"/>.</returns>
|
||||
public OpfContributorDto Create(
|
||||
string name = "Test Contributor",
|
||||
string? role = null)
|
||||
{
|
||||
return new OpfContributorDto(name, role);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="OpfContributorDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<OpfContributorDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Plugins.Calibre.Common.Models.DTO.Opf;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.Calibre.Fixtures.Common.Models.DTO.Opf;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="OpfCreatorDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
internal sealed class OpfCreatorDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates an <see cref="OpfCreatorDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the creator.</param>
|
||||
/// <param name="role">The role code of the creator, for example <c>aut</c> for author.</param>
|
||||
/// <returns>The created <see cref="OpfCreatorDto"/>.</returns>
|
||||
public OpfCreatorDto Create(
|
||||
string name = "Test Creator",
|
||||
string? role = null)
|
||||
{
|
||||
return new OpfCreatorDto(name, role);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="OpfCreatorDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<OpfCreatorDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Plugins.Calibre.Common.Models.DTO.Opf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.Calibre.Fixtures.Common.Models.DTO.Opf;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="OpfDocumentDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
internal sealed class OpfDocumentDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates an <see cref="OpfDocumentDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional. The title of the book.</param>
|
||||
/// <param name="description">Optional. The description of the book, in HTML format.</param>
|
||||
/// <param name="publisher">Optional. The publisher of the book.</param>
|
||||
/// <param name="publishDate">Optional. The publication date of the book.</param>
|
||||
/// <param name="languageCode">Optional. The language code of the book.</param>
|
||||
/// <param name="series">Optional. The name of the series the book belongs to.</param>
|
||||
/// <param name="seriesIndex">Optional. The index of the book within its series.</param>
|
||||
/// <param name="rating">Optional. The personal rating of the book, on a scale of 0 to 10.</param>
|
||||
/// <param name="coverHref">Optional. The href of the cover image, relative to the directory of the book.</param>
|
||||
/// <param name="subjects">Optional. The subjects of the book, used as tags.</param>
|
||||
/// <param name="creators">Optional. The creators of the book.</param>
|
||||
/// <param name="contributors">Optional. The contributors of the book.</param>
|
||||
/// <param name="identifiers">Optional. The identifiers of the book, with their schemes.</param>
|
||||
/// <returns>The created <see cref="OpfDocumentDto"/>.</returns>
|
||||
public OpfDocumentDto Create(
|
||||
string? title = null,
|
||||
string? description = null,
|
||||
string? publisher = null,
|
||||
DateTimeOffset? publishDate = null,
|
||||
string? languageCode = null,
|
||||
string? series = null,
|
||||
double? seriesIndex = null,
|
||||
int? rating = null,
|
||||
string? coverHref = null,
|
||||
IEnumerable<string>? subjects = null,
|
||||
IEnumerable<OpfCreatorDto>? creators = null,
|
||||
IEnumerable<OpfContributorDto>? contributors = null,
|
||||
IEnumerable<OpfIdentifierDto>? identifiers = null)
|
||||
{
|
||||
OpfDocumentDto document = new()
|
||||
{
|
||||
Title = title,
|
||||
Description = description,
|
||||
Publisher = publisher,
|
||||
PublishDate = publishDate,
|
||||
LanguageCode = languageCode,
|
||||
Series = series,
|
||||
SeriesIndex = seriesIndex,
|
||||
Rating = rating,
|
||||
CoverHref = coverHref
|
||||
};
|
||||
if (subjects is not null)
|
||||
document.Subjects.AddRange(subjects);
|
||||
if (creators is not null)
|
||||
document.Creators.AddRange(creators);
|
||||
if (contributors is not null)
|
||||
document.Contributors.AddRange(contributors);
|
||||
if (identifiers is not null)
|
||||
document.Identifiers.AddRange(identifiers);
|
||||
return document;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="OpfDocumentDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<OpfDocumentDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Plugins.Calibre.Common.Models.DTO.Opf;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.Calibre.Fixtures.Common.Models.DTO.Opf;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="OpfIdentifierDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
internal sealed class OpfIdentifierDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates an <see cref="OpfIdentifierDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="scheme">The scheme of the identifier, for example <c>ISBN</c> or <c>GOODREADS</c>.</param>
|
||||
/// <param name="value">The value of the identifier.</param>
|
||||
/// <returns>The created <see cref="OpfIdentifierDto"/>.</returns>
|
||||
public OpfIdentifierDto Create(
|
||||
string scheme = "ISBN",
|
||||
string value = "9780306406157")
|
||||
{
|
||||
return new OpfIdentifierDto(scheme, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="OpfIdentifierDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<OpfIdentifierDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.Calibre.Fixtures.Core.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Concrete <see cref="MetadataLookupDto"/> used to represent a lookup that is not a book lookup.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
internal sealed record TestMetadataLookup(Guid LibraryId, string Path) : MetadataLookupDto;
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.Calibre.Fixtures.Core.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TestMetadataLookup"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
internal sealed class TestMetadataLookupFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a <see cref="TestMetadataLookup"/> that is not a book lookup.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library, or <see langword="null"/> to generate a random one.</param>
|
||||
/// <param name="path">The file system path of the media item.</param>
|
||||
/// <returns>The created <see cref="TestMetadataLookup"/>.</returns>
|
||||
public TestMetadataLookup Create(
|
||||
Guid? libraryId = null,
|
||||
string? path = null)
|
||||
{
|
||||
return new TestMetadataLookup(libraryId ?? Guid.NewGuid(), path ?? "/some/path");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="TestMetadataLookup"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<TestMetadataLookup> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<BaseOutputPath>$(SolutionDir)..\bin\api\</BaseOutputPath>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>false</IsTestProject>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoFixture" />
|
||||
<PackageReference Include="AutoFixture.AutoNSubstitute" />
|
||||
<PackageReference Include="AutoFixture.Xunit2" />
|
||||
<PackageReference Include="Bogus" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\plugins\Lumina.Plugins.Calibre\Lumina.Plugins.Calibre.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Lumina.Plugins.Contracts\Lumina.Plugins.Contracts.csproj" />
|
||||
<ProjectReference Include="..\..\Common\Lumina.Contracts.Fixtures\Lumina.Contracts.Fixtures.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Lumina.Plugins.Calibre.Fixtures")]
|
||||
[assembly: AssemblyProduct("Lumina.Plugins.Calibre.Fixtures")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("B6F9E5D2-3C4D-5E6F-9A7B-8C9D0E1F2A31")]
|
||||
|
||||
[assembly: InternalsVisibleTo("Lumina.Plugins.Calibre.UnitTests")]
|
||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
||||
Reference in new issue
Block a user