Adds commands and queries validators unit tests

This commit is contained in:
BinaryAlley committed 2026-08-15 06:35:07 -07:00
1 parent 7f335b70f1
commit f393b93ce7
25 files changed
+1553 -307

No files matched your search

@@ -1,74 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Plugins.Contracts.Core.Metadata;
using Lumina.Plugins.Contracts.UnitTests.Common.Fakes;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Plugins.Contracts.UnitTests.Core.Metadata;
/// <summary>
/// Contains unit tests for the <see cref="IRemoteMetadataProvider"/> contracts.
/// </summary>
[ExcludeFromCodeCoverage]
public class RemoteMetadataProviderTests
{
private readonly IRemoteMetadataProvider _sut = new FakeBookMetadataProvider();
[Fact]
public async Task GetMetadataAsync_WhenCalledThroughNonGenericInterface_ShouldReturnTypedMetadata()
{
// Arrange
MetadataLookupDto lookup = new BookMetadataLookupDto(
LibraryId: Guid.NewGuid(),
Path: "/books/the-fellowship-of-the-ring.epub",
Title: "The Fellowship of the Ring");
// Act
MetadataDto? result = await _sut.GetMetadataAsync(lookup, CancellationToken.None);
// Assert
Assert.NotNull(result);
BookMetadataDto bookMetadata = Assert.IsType<BookMetadataDto>(result);
Assert.Equal("The Fellowship of the Ring", bookMetadata.Title);
Assert.Equal("3", bookMetadata.GoodreadsId);
}
[Fact]
public async Task GetMetadataAsync_WhenNoMetadataFound_ShouldReturnNull()
{
// Arrange
MetadataLookupDto lookup = new BookMetadataLookupDto(
LibraryId: Guid.NewGuid(),
Path: "/books/unknown.epub");
// Act
MetadataDto? result = await _sut.GetMetadataAsync(lookup, CancellationToken.None);
// Assert
Assert.Null(result);
}
[Fact]
public async Task GetSearchResultsAsync_WhenCalledThroughNonGenericInterface_ShouldReturnTypedResults()
{
// Arrange
MetadataLookupDto lookup = new BookMetadataLookupDto(
LibraryId: Guid.NewGuid(),
Path: "/books/the-fellowship-of-the-ring.epub",
Title: "The Fellowship of the Ring");
// Act
IReadOnlyList<MetadataDto> result = await _sut.GetSearchResultsAsync(lookup, CancellationToken.None);
// Assert
Assert.Single(result);
BookMetadataDto bookMetadata = Assert.IsType<BookMetadataDto>(result[0]);
Assert.Equal("The Fellowship of the Ring", bookMetadata.Title);
}
}
@@ -1,36 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Plugins.Contracts.Core.Plugins;
using Lumina.Plugins.Contracts.Core.Plugins.Settings;
using Lumina.Plugins.Contracts.UnitTests.Common.Fakes;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Plugins.Contracts.UnitTests.Core.Plugins;
/// <summary>
/// Contains unit tests for the <see cref="IPlugin"/> contract.
/// </summary>
[ExcludeFromCodeCoverage]
public class PluginTests
{
private readonly IPlugin _sut = new FakeBookMetadataProvider();
[Fact]
public void GetSettingsSchema_WhenCalled_ShouldReturnDeclaredSettings()
{
// Arrange
// Act
IReadOnlyList<PluginSettingDescriptor> schema = _sut.GetSettingsSchema();
// Assert
Assert.Equal(2, schema.Count);
Assert.Equal("preferredLanguage", schema[0].Key);
Assert.Equal(PluginSettingType.Text, schema[0].Type);
Assert.Equal("en", schema[0].DefaultValue);
Assert.Equal("selectionStrategy", schema[1].Key);
Assert.Equal(PluginSettingType.Select, schema[1].Type);
Assert.Contains("first", schema[1].AllowedValues!);
}
}