mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 08:11:10 +00:00
Integrates the plugin system into the host and the media library scan pipeline
This commit is contained in:
1 parent
f71e72a948
commit
6f501a51f3
45 files changed
+1268
-370
No files matched your search
+72
@@ -0,0 +1,72 @@
|
||||
#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.Fakes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.Contracts.UnitTests.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="IRemoteMetadataProvider"/> contracts.
|
||||
/// </summary>
|
||||
public class RemoteMetadataProviderTests
|
||||
{
|
||||
private readonly IRemoteMetadataProvider _provider = 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 _provider.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 _provider.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 _provider.GetSearchResultsAsync(lookup, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.Single(result);
|
||||
BookMetadataDto bookMetadata = Assert.IsType<BookMetadataDto>(result[0]);
|
||||
Assert.Equal("The Fellowship of the Ring", bookMetadata.Title);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user