Refactored more archive code into the service and updated documentation now that methods are public.
|
@ -1,6 +1,5 @@
|
|||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using API.Extensions;
|
||||
using API.Interfaces;
|
||||
using API.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
@ -14,9 +13,6 @@ namespace API.Tests.Services
|
|||
private readonly IArchiveService _archiveService;
|
||||
private readonly ILogger<ArchiveService> _logger = Substitute.For<ILogger<ArchiveService>>();
|
||||
|
||||
private readonly string _testDirectory =
|
||||
Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ArchiveService");
|
||||
|
||||
public ArchiveServiceTests()
|
||||
{
|
||||
_archiveService = new ArchiveService(_logger);
|
||||
|
@ -29,9 +25,21 @@ namespace API.Tests.Services
|
|||
[InlineData("file in folder_alt.zip", true)]
|
||||
public void ArchiveNeedsFlatteningTest(string archivePath, bool expected)
|
||||
{
|
||||
var file = Path.Join(_testDirectory, archivePath);
|
||||
var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ArchiveService");
|
||||
var file = Path.Join(testDirectory, archivePath);
|
||||
using ZipArchive archive = ZipFile.OpenRead(file);
|
||||
Assert.Equal(expected, _archiveService.ArchiveNeedsFlattening(archive));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("v10.cbz", "v10.expected.jpg")]
|
||||
[InlineData("v10 - with folder.cbz", "v10 - with folder.expected.jpg")]
|
||||
[InlineData("v10 - nested folder.cbz", "v10 - nested folder.expected.jpg")]
|
||||
public void GetCoverImageTest(string inputFile, string expectedOutputFile)
|
||||
{
|
||||
var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/CoverImageTests");
|
||||
var expectedBytes = File.ReadAllBytes(Path.Join(testDirectory, expectedOutputFile));
|
||||
Assert.Equal(expectedBytes, _archiveService.GetCoverImage(Path.Join(testDirectory, inputFile)));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,23 +9,15 @@ namespace API.Tests.Services
|
|||
{
|
||||
public class ScannerServiceTests
|
||||
{
|
||||
private readonly ScannerService _scannerService;
|
||||
private readonly ILogger<ScannerService> _logger = Substitute.For<ILogger<ScannerService>>();
|
||||
private readonly IUnitOfWork _unitOfWork = Substitute.For<IUnitOfWork>();
|
||||
private readonly string _testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ScannerService");
|
||||
public ScannerServiceTests()
|
||||
{
|
||||
_scannerService = new ScannerService(_unitOfWork, _logger);
|
||||
}
|
||||
// private readonly ScannerService _scannerService;
|
||||
// private readonly ILogger<ScannerService> _logger = Substitute.For<ILogger<ScannerService>>();
|
||||
// private readonly IUnitOfWork _unitOfWork = Substitute.For<IUnitOfWork>();
|
||||
// private readonly string _testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ScannerService");
|
||||
// public ScannerServiceTests()
|
||||
// {
|
||||
// _scannerService = new ScannerService(_unitOfWork, _logger);
|
||||
// }
|
||||
|
||||
[Theory]
|
||||
[InlineData("v10.cbz", "v10.expected.jpg")]
|
||||
[InlineData("v10 - with folder.cbz", "v10 - with folder.expected.jpg")]
|
||||
[InlineData("v10 - nested folder.cbz", "v10 - nested folder.expected.jpg")]
|
||||
public void GetCoverImageTest(string inputFile, string expectedOutputFile)
|
||||
{
|
||||
var expectedBytes = File.ReadAllBytes(Path.Join(_testDirectory, expectedOutputFile));
|
||||
Assert.Equal(expectedBytes, _scannerService.GetCoverImage(Path.Join(_testDirectory, inputFile)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 395 KiB After Width: | Height: | Size: 395 KiB |
Before Width: | Height: | Size: 385 KiB After Width: | Height: | Size: 385 KiB |
Before Width: | Height: | Size: 344 KiB After Width: | Height: | Size: 344 KiB |
Before Width: | Height: | Size: 385 KiB After Width: | Height: | Size: 385 KiB |