Refactored GetCoverImage to a static class and unit tested it. Enhanced the method by defaulting to folder.jpg file if exists, else takes first entry.
This commit is contained in:
parent
451d459473
commit
7f5a1d0518
12 changed files with 92 additions and 27 deletions
21
API.Tests/Services/ImageProviderTest.cs
Normal file
21
API.Tests/Services/ImageProviderTest.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using API.IO;
|
||||
using Xunit;
|
||||
|
||||
namespace API.Tests.Services
|
||||
{
|
||||
public class ImageProviderTest
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("v10.cbz", "v10.expected.jpg")]
|
||||
[InlineData("v10 - with folder.cbz", "v10 - with folder.expected.jpg")]
|
||||
public void GetCoverImageTest(string inputFile, string expectedOutputFile)
|
||||
{
|
||||
var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ImageProvider");
|
||||
var expectedBytes = File.ReadAllBytes(Path.Join(testDirectory, expectedOutputFile));
|
||||
|
||||
Assert.Equal(expectedBytes, ImageProvider.GetCoverImage(Path.Join(testDirectory, inputFile)));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue