Renames project paths from Lumina to Nemera

This commit is contained in:
BinaryAlley committed 2026-11-27 15:34:43 +02:00
1 parent ce6fddb4c9
commit 0f659a4877
6450 files changed

No files matched your search

@@ -0,0 +1,51 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.Plugins;
using Lumina.Plugins.Contracts.Common.Models.DTO.Settings;
using Lumina.Plugins.Contracts.Fixtures.Common.Models.DTO.Settings;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Plugins.Contracts.UnitTests.Common.Models.DTO.Settings;
/// <summary>
/// Contains unit tests for the <see cref="PluginSettingDescriptorDto"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class PluginSettingDescriptorDtoTests
{
private readonly PluginSettingDescriptorDtoFixture _pluginSettingDescriptorDtoFixture = new();
[Fact]
public void Create_WhenConstructedWithValues_ShouldPreserveAllValues()
{
// Arrange
IReadOnlyList<string> allowedValues = ["Fiction", "Non-Fiction"];
// Act
PluginSettingDescriptorDto result = _pluginSettingDescriptorDtoFixture.Create(
key: "Theme",
label: "Theme",
type: PluginSettingType.Select,
defaultValue: "Fiction",
allowedValues: allowedValues);
// Assert
Assert.Equal("Theme", result.Key);
Assert.Equal("Theme", result.Label);
Assert.Equal(PluginSettingType.Select, result.Type);
Assert.Equal("Fiction", result.DefaultValue);
Assert.Same(allowedValues, result.AllowedValues);
}
[Fact]
public void Create_WhenDefaultValuesAreNotProvided_ShouldDefaultToNull()
{
// Act
PluginSettingDescriptorDto result = _pluginSettingDescriptorDtoFixture.Create(defaultValue: null, allowedValues: null);
// Assert
Assert.Null(result.DefaultValue);
Assert.Null(result.AllowedValues);
}
}
@@ -0,0 +1,105 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.Common;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using Lumina.Plugins.Contracts.Core.Metadata;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Plugins.Contracts.UnitTests.Core.Metadata;
/// <summary>
/// Contains unit tests for the <see cref="IArtworkProvider{TLookup}"/> interface.
/// </summary>
[ExcludeFromCodeCoverage]
public class IArtworkProviderGenericTests
{
private readonly BookMetadataLookupDtoFixture _bookMetadataLookupDtoFixture = new();
private readonly ArtworkDtoFixture _artworkDtoFixture = new();
private readonly OtherMetadataLookupDtoFixture _otherMetadataLookupDtoFixture = new();
[Fact]
public async Task GetArtworkAsync_WhenCalledThroughBaseInterface_ShouldForwardToTypedImplementation()
{
// Arrange
BookMetadataLookupDto lookup = _bookMetadataLookupDtoFixture.Create();
CancellationToken cancellationToken = CancellationToken.None;
ArtworkDto expectedArtwork = _artworkDtoFixture.Create();
TestBookArtworkProvider provider = new(expectedArtwork);
IArtworkProvider baseProvider = provider;
// Act
IReadOnlyList<ArtworkDto> result = await baseProvider.GetArtworkAsync(lookup, cancellationToken);
// Assert
Assert.Equal([expectedArtwork], result);
Assert.Same(lookup, provider.ReceivedLookup);
Assert.Equal(cancellationToken, provider.ReceivedCancellationToken);
}
[Fact]
public async Task GetArtworkAsync_WhenLookupIsOfAnotherRuntimeType_ShouldReturnEmpty()
{
// Arrange
MetadataLookupDto otherLookup = _otherMetadataLookupDtoFixture.Create();
TestBookArtworkProvider provider = new(_artworkDtoFixture.Create());
IArtworkProvider baseProvider = provider;
// Act
IReadOnlyList<ArtworkDto> result = await baseProvider.GetArtworkAsync(otherLookup, CancellationToken.None);
// Assert
Assert.Empty(result);
Assert.Null(provider.ReceivedLookup);
}
/// <summary>
/// Test double for the typed artwork provider interface that records the forwarded arguments.
/// </summary>
[ExcludeFromCodeCoverage]
private sealed class TestBookArtworkProvider : IArtworkProvider<BookMetadataLookupDto>
{
private readonly ArtworkDto _artwork;
/// <summary>
/// Gets the lookup that was forwarded to the typed implementation.
/// </summary>
public BookMetadataLookupDto? ReceivedLookup { get; private set; }
/// <summary>
/// Gets the cancellation token that was forwarded to the typed implementation.
/// </summary>
public CancellationToken ReceivedCancellationToken { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="TestBookArtworkProvider"/> class.
/// </summary>
/// <param name="artwork">The artwork returned by the typed implementation.</param>
public TestBookArtworkProvider(ArtworkDto artwork)
{
_artwork = artwork;
}
/// <inheritdoc/>
public string Name => "Test Provider";
/// <inheritdoc/>
public IReadOnlyList<LibraryType> SupportedLibraryTypes => [LibraryType.Book];
/// <inheritdoc/>
public bool RequiresWebAccess => false;
/// <inheritdoc/>
public Task<IReadOnlyList<ArtworkDto>> GetArtworkAsync(BookMetadataLookupDto lookup, CancellationToken cancellationToken)
{
ReceivedLookup = lookup;
ReceivedCancellationToken = cancellationToken;
return Task.FromResult<IReadOnlyList<ArtworkDto>>([_artwork]);
}
}
}
@@ -0,0 +1,164 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.Common;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using Lumina.Plugins.Contracts.Core.Metadata;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Plugins.Contracts.UnitTests.Core.Metadata;
/// <summary>
/// Contains unit tests for the <see cref="IMetadataProvider{TLookup, TMetadata}"/> interface.
/// </summary>
[ExcludeFromCodeCoverage]
public class IMetadataProviderGenericTests
{
private readonly BookMetadataLookupDtoFixture _bookMetadataLookupDtoFixture = new();
private readonly BookMetadataDtoFixture _bookMetadataDtoFixture = new();
private readonly OtherMetadataLookupDtoFixture _otherMetadataLookupDtoFixture = new();
[Fact]
public async Task GetSearchResultsAsync_WhenCalledThroughBaseInterface_ShouldForwardToTypedImplementation()
{
// Arrange
BookMetadataLookupDto lookup = _bookMetadataLookupDtoFixture.Create();
CancellationToken cancellationToken = CancellationToken.None;
BookMetadataDto expectedMetadata = _bookMetadataDtoFixture.Create(title: "Search Result", includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false);
TestBookMetadataProvider provider = new(expectedMetadata);
IMetadataProvider baseProvider = provider;
// Act
IReadOnlyList<MetadataDto> result = await baseProvider.GetSearchResultsAsync(lookup, cancellationToken);
// Assert
BookMetadataDto metadata = Assert.IsType<BookMetadataDto>(Assert.Single(result));
Assert.Equal(expectedMetadata, metadata);
Assert.Same(lookup, provider.ReceivedLookup);
Assert.Equal(cancellationToken, provider.ReceivedCancellationToken);
}
[Fact]
public async Task GetMetadataAsync_WhenCalledThroughBaseInterface_ShouldForwardToTypedImplementation()
{
// Arrange
BookMetadataLookupDto lookup = _bookMetadataLookupDtoFixture.Create();
CancellationToken cancellationToken = CancellationToken.None;
BookMetadataDto expectedMetadata = _bookMetadataDtoFixture.Create(title: "Exact Result", includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false);
TestBookMetadataProvider provider = new(expectedMetadata);
IMetadataProvider baseProvider = provider;
// Act
MetadataDto? result = await baseProvider.GetMetadataAsync(lookup, cancellationToken);
// Assert
Assert.Equal(expectedMetadata, Assert.IsType<BookMetadataDto>(result));
Assert.Same(lookup, provider.ReceivedLookup);
Assert.Equal(cancellationToken, provider.ReceivedCancellationToken);
}
[Fact]
public async Task GetSearchResultsAsync_WhenLookupIsOfAnotherRuntimeType_ShouldReturnEmptyAndNotForward()
{
// Arrange
MetadataLookupDto otherLookup = _otherMetadataLookupDtoFixture.Create();
TestBookMetadataProvider provider = new(_bookMetadataDtoFixture.Create(title: "Search Result", includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false));
IMetadataProvider baseProvider = provider;
// Act
IReadOnlyList<MetadataDto> result = await baseProvider.GetSearchResultsAsync(otherLookup, CancellationToken.None);
// Assert
Assert.Empty(result);
Assert.Null(provider.ReceivedLookup);
}
[Fact]
public async Task GetMetadataAsync_WhenLookupIsOfAnotherRuntimeType_ShouldReturnNullAndNotForward()
{
// Arrange
MetadataLookupDto otherLookup = _otherMetadataLookupDtoFixture.Create();
TestBookMetadataProvider provider = new(_bookMetadataDtoFixture.Create(title: "Exact Result", includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false));
IMetadataProvider baseProvider = provider;
// Act
MetadataDto? result = await baseProvider.GetMetadataAsync(otherLookup, CancellationToken.None);
// Assert
Assert.Null(result);
Assert.Null(provider.ReceivedLookup);
}
[Fact]
public void LookupType_WhenReadThroughBaseInterface_ShouldReturnTypedLookupType()
{
// Arrange
TestBookMetadataProvider provider = new(_bookMetadataDtoFixture.Create(title: "Exact Result", includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false));
IMetadataProvider baseProvider = provider;
// Act
Type lookupType = baseProvider.LookupType;
// Assert
Assert.Equal(typeof(BookMetadataLookupDto), lookupType);
}
/// <summary>
/// Test double for the typed metadata provider interface that records the forwarded arguments.
/// </summary>
[ExcludeFromCodeCoverage]
private sealed class TestBookMetadataProvider : IMetadataProvider<BookMetadataLookupDto, BookMetadataDto>
{
private readonly BookMetadataDto _metadata;
/// <summary>
/// Gets the lookup that was forwarded to the typed implementation.
/// </summary>
public BookMetadataLookupDto? ReceivedLookup { get; private set; }
/// <summary>
/// Gets the cancellation token that was forwarded to the typed implementation.
/// </summary>
public CancellationToken ReceivedCancellationToken { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="TestBookMetadataProvider"/> class.
/// </summary>
/// <param name="metadata">The metadata returned by the typed implementation.</param>
public TestBookMetadataProvider(BookMetadataDto metadata)
{
_metadata = metadata;
}
/// <inheritdoc/>
public string Name => "Test Provider";
/// <inheritdoc/>
public IReadOnlyList<LibraryType> SupportedLibraryTypes => [LibraryType.Book];
/// <inheritdoc/>
public bool RequiresWebAccess => false;
/// <inheritdoc/>
public Task<IReadOnlyList<BookMetadataDto>> GetSearchResultsAsync(BookMetadataLookupDto lookup, CancellationToken cancellationToken)
{
ReceivedLookup = lookup;
ReceivedCancellationToken = cancellationToken;
return Task.FromResult<IReadOnlyList<BookMetadataDto>>([_metadata]);
}
/// <inheritdoc/>
public Task<BookMetadataDto?> GetMetadataAsync(BookMetadataLookupDto lookup, CancellationToken cancellationToken)
{
ReceivedLookup = lookup;
ReceivedCancellationToken = cancellationToken;
return Task.FromResult<BookMetadataDto?>(_metadata);
}
}
}
@@ -0,0 +1,152 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using Lumina.Plugins.Contracts.Core.Reading;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Plugins.Contracts.UnitTests.Core.Reading;
/// <summary>
/// Contains unit tests for the <see cref="IBookReader"/> interface.
/// </summary>
[ExcludeFromCodeCoverage]
public class IBookReaderGenericTests
{
private readonly ReadingDocumentDtoFixture _readingDocumentDtoFixture = new();
[Fact]
public async Task OpenAsync_WhenCalled_ShouldForwardArgumentsToTheReaderImplementation()
{
// Arrange
string path = "/books/test.epub";
string workingDirectory = "/tmp/reading-cache";
bool shouldRenderPdfAsImages = true;
CancellationToken cancellationToken = CancellationToken.None;
ReadingDocumentDto expectedDocument = _readingDocumentDtoFixture.Create();
TestBookReader reader = new(expectedDocument, [1, 2, 3]);
// Act
ReadingDocumentDto result = await reader.OpenAsync(path, workingDirectory, shouldRenderPdfAsImages, cancellationToken);
// Assert
Assert.Equal(expectedDocument, result);
Assert.Equal(path, reader.ReceivedPath);
Assert.Equal(workingDirectory, reader.ReceivedWorkingDirectory);
Assert.Equal(shouldRenderPdfAsImages, reader.ReceivedShouldRenderPdfAsImages);
Assert.Equal(cancellationToken, reader.ReceivedCancellationToken);
}
[Fact]
public async Task GetResourceAsync_WhenCalled_ShouldForwardArgumentsToTheReaderImplementation()
{
// Arrange
string path = "/books/test.epub";
string workingDirectory = "/tmp/reading-cache";
string resourceKey = "resources/cover.png";
CancellationToken cancellationToken = CancellationToken.None;
byte[] expectedResource = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A];
TestBookReader reader = new(_readingDocumentDtoFixture.Create(), expectedResource);
// Act
byte[] result = await reader.GetResourceAsync(path, workingDirectory, resourceKey, cancellationToken);
// Assert
Assert.Equal(expectedResource, result);
Assert.Equal(path, reader.ReceivedResourcePath);
Assert.Equal(workingDirectory, reader.ReceivedResourceWorkingDirectory);
Assert.Equal(resourceKey, reader.ReceivedResourceKey);
Assert.Equal(cancellationToken, reader.ReceivedResourceCancellationToken);
}
/// <summary>
/// Test double for the book reader interface that records the forwarded arguments.
/// </summary>
[ExcludeFromCodeCoverage]
private sealed class TestBookReader : IBookReader
{
private readonly ReadingDocumentDto _document;
private readonly byte[] _resource;
/// <summary>
/// Gets the path that was forwarded to the OpenAsync implementation.
/// </summary>
public string? ReceivedPath { get; private set; }
/// <summary>
/// Gets the working directory that was forwarded to the OpenAsync implementation.
/// </summary>
public string? ReceivedWorkingDirectory { get; private set; }
/// <summary>
/// Gets the rendering preference that was forwarded to the OpenAsync implementation.
/// </summary>
public bool ReceivedShouldRenderPdfAsImages { get; private set; }
/// <summary>
/// Gets the cancellation token that was forwarded to the OpenAsync implementation.
/// </summary>
public CancellationToken ReceivedCancellationToken { get; private set; }
/// <summary>
/// Gets the path that was forwarded to the GetResourceAsync implementation.
/// </summary>
public string? ReceivedResourcePath { get; private set; }
/// <summary>
/// Gets the working directory that was forwarded to the GetResourceAsync implementation.
/// </summary>
public string? ReceivedResourceWorkingDirectory { get; private set; }
/// <summary>
/// Gets the resource key that was forwarded to the GetResourceAsync implementation.
/// </summary>
public string? ReceivedResourceKey { get; private set; }
/// <summary>
/// Gets the cancellation token that was forwarded to the GetResourceAsync implementation.
/// </summary>
public CancellationToken ReceivedResourceCancellationToken { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="TestBookReader"/> class.
/// </summary>
/// <param name="document">The document returned by the OpenAsync implementation.</param>
/// <param name="resource">The resource data returned by the GetResourceAsync implementation.</param>
public TestBookReader(ReadingDocumentDto document, byte[] resource)
{
_document = document;
_resource = resource;
}
/// <inheritdoc/>
public IReadOnlyList<string> SupportedExtensions => [".epub"];
/// <inheritdoc/>
public IReadOnlyList<LibraryType> SupportedLibraryTypes => [LibraryType.EBook];
/// <inheritdoc/>
public Task<ReadingDocumentDto> OpenAsync(string path, string workingDirectory, bool shouldRenderPdfAsImages, CancellationToken cancellationToken)
{
ReceivedPath = path;
ReceivedWorkingDirectory = workingDirectory;
ReceivedShouldRenderPdfAsImages = shouldRenderPdfAsImages;
ReceivedCancellationToken = cancellationToken;
return Task.FromResult(_document);
}
/// <inheritdoc/>
public Task<byte[]> GetResourceAsync(string path, string workingDirectory, string resourceKey, CancellationToken cancellationToken)
{
ReceivedResourcePath = path;
ReceivedResourceWorkingDirectory = workingDirectory;
ReceivedResourceKey = resourceKey;
ReceivedResourceCancellationToken = cancellationToken;
return Task.FromResult(_resource);
}
}
}
@@ -0,0 +1,46 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<AssemblyAttribute Include="Xunit.CollectionBehaviorAttribute">
<_Parameter1>DisableTestParallelization = true</_Parameter1>
<_Parameter1_IsLiteral>true</_Parameter1_IsLiteral>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoFixture.AutoNSubstitute" />
<PackageReference Include="AutoFixture.Xunit2" />
<PackageReference Include="Bogus" />
<PackageReference Include="coverlet.collector">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Lumina.Plugins.Contracts\Lumina.Plugins.Contracts.csproj" />
<ProjectReference Include="..\..\Common\Lumina.Plugins.Contracts.Fixtures\Lumina.Plugins.Contracts.Fixtures.csproj" />
<ProjectReference Include="..\..\Common\Lumina.Contracts.Fixtures\Lumina.Contracts.Fixtures.csproj" />
</ItemGroup>
</Project>