mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:21:10 +00:00
Adds the media library artwork aggregation services, enrichers, and their provider contracts
This commit is contained in:
1 parent
00376c8313
commit
9e118864c3
33 files changed
+4621
-1118
No files matched your search
+7
-7
@@ -34,16 +34,16 @@ public class IArtworkProviderGenericTests
|
||||
IArtworkProvider baseProvider = provider;
|
||||
|
||||
// Act
|
||||
ArtworkDto? result = await baseProvider.GetArtworkAsync(lookup, cancellationToken);
|
||||
IReadOnlyList<ArtworkDto> result = await baseProvider.GetArtworkAsync(lookup, cancellationToken);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedArtwork, result);
|
||||
Assert.Equal([expectedArtwork], result);
|
||||
Assert.Same(lookup, provider.ReceivedLookup);
|
||||
Assert.Equal(cancellationToken, provider.ReceivedCancellationToken);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetArtworkAsync_WhenLookupIsOfAnotherRuntimeType_ShouldReturnNull()
|
||||
public async Task GetArtworkAsync_WhenLookupIsOfAnotherRuntimeType_ShouldReturnEmpty()
|
||||
{
|
||||
// Arrange
|
||||
MetadataLookupDto otherLookup = _otherMetadataLookupDtoFixture.Create();
|
||||
@@ -51,10 +51,10 @@ public class IArtworkProviderGenericTests
|
||||
IArtworkProvider baseProvider = provider;
|
||||
|
||||
// Act
|
||||
ArtworkDto? result = await baseProvider.GetArtworkAsync(otherLookup, CancellationToken.None);
|
||||
IReadOnlyList<ArtworkDto> result = await baseProvider.GetArtworkAsync(otherLookup, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.Null(result);
|
||||
Assert.Empty(result);
|
||||
Assert.Null(provider.ReceivedLookup);
|
||||
}
|
||||
|
||||
@@ -95,11 +95,11 @@ public class IArtworkProviderGenericTests
|
||||
public bool RequiresWebAccess => false;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Task<ArtworkDto?> GetArtworkAsync(BookMetadataLookupDto lookup, CancellationToken cancellationToken)
|
||||
public Task<IReadOnlyList<ArtworkDto>> GetArtworkAsync(BookMetadataLookupDto lookup, CancellationToken cancellationToken)
|
||||
{
|
||||
ReceivedLookup = lookup;
|
||||
ReceivedCancellationToken = cancellationToken;
|
||||
return Task.FromResult<ArtworkDto?>(_artwork);
|
||||
return Task.FromResult<IReadOnlyList<ArtworkDto>>([_artwork]);
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
-12
@@ -64,7 +64,7 @@ public class IMetadataProviderGenericTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetSearchResultsAsync_WhenLookupIsOfAnotherRuntimeType_ShouldThrowInvalidCastException()
|
||||
public async Task GetSearchResultsAsync_WhenLookupIsOfAnotherRuntimeType_ShouldReturnEmptyAndNotForward()
|
||||
{
|
||||
// Arrange
|
||||
MetadataLookupDto otherLookup = _otherMetadataLookupDtoFixture.Create();
|
||||
@@ -72,18 +72,15 @@ public class IMetadataProviderGenericTests
|
||||
IMetadataProvider baseProvider = provider;
|
||||
|
||||
// Act
|
||||
async Task Act()
|
||||
{
|
||||
await baseProvider.GetSearchResultsAsync(otherLookup, CancellationToken.None);
|
||||
}
|
||||
IReadOnlyList<MetadataDto> result = await baseProvider.GetSearchResultsAsync(otherLookup, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await Assert.ThrowsAsync<InvalidCastException>(Act);
|
||||
Assert.Empty(result);
|
||||
Assert.Null(provider.ReceivedLookup);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetMetadataAsync_WhenLookupIsOfAnotherRuntimeType_ShouldThrowInvalidCastException()
|
||||
public async Task GetMetadataAsync_WhenLookupIsOfAnotherRuntimeType_ShouldReturnNullAndNotForward()
|
||||
{
|
||||
// Arrange
|
||||
MetadataLookupDto otherLookup = _otherMetadataLookupDtoFixture.Create();
|
||||
@@ -91,16 +88,27 @@ public class IMetadataProviderGenericTests
|
||||
IMetadataProvider baseProvider = provider;
|
||||
|
||||
// Act
|
||||
async Task Act()
|
||||
{
|
||||
await baseProvider.GetMetadataAsync(otherLookup, CancellationToken.None);
|
||||
}
|
||||
MetadataDto? result = await baseProvider.GetMetadataAsync(otherLookup, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await Assert.ThrowsAsync<InvalidCastException>(Act);
|
||||
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>
|
||||
|
||||
Reference in new issue
Block a user