mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
Standardizes test projects against conventions
This commit is contained in:
1 parent
59e16d645a
commit
ced1f778c4
78 files changed
+283
-201
No files matched your search
+74
@@ -0,0 +1,74 @@
|
||||
#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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#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!);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user