Moved the test data around so more tests can use it properly. Added a IsValidArchive that is re-usable for all archive methods.
|
@ -25,11 +25,25 @@ namespace API.Tests.Services
|
|||
[InlineData("file in folder_alt.zip", true)]
|
||||
public void ArchiveNeedsFlatteningTest(string archivePath, bool expected)
|
||||
{
|
||||
var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ArchiveService");
|
||||
var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ArchiveService/Archives");
|
||||
var file = Path.Join(testDirectory, archivePath);
|
||||
using ZipArchive archive = ZipFile.OpenRead(file);
|
||||
Assert.Equal(expected, _archiveService.ArchiveNeedsFlattening(archive));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("non existant file.zip", false)]
|
||||
[InlineData("wrong extension.rar", false)]
|
||||
[InlineData("empty.zip", false)]
|
||||
[InlineData("flat file.zip", true)]
|
||||
[InlineData("file in folder in folder.zip", true)]
|
||||
[InlineData("file in folder.zip", true)]
|
||||
[InlineData("file in folder_alt.zip", true)]
|
||||
public void IsValidArchiveTest(string archivePath, bool expected)
|
||||
{
|
||||
var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ArchiveService/Archives");
|
||||
Assert.Equal(expected, _archiveService.IsValidArchive(Path.Join(testDirectory, archivePath)));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("v10.cbz", "v10.expected.jpg")]
|
||||
|
@ -37,7 +51,7 @@ namespace API.Tests.Services
|
|||
[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 testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ArchiveService/CoverImages");
|
||||
var expectedBytes = File.ReadAllBytes(Path.Join(testDirectory, expectedOutputFile));
|
||||
Assert.Equal(expectedBytes, _archiveService.GetCoverImage(Path.Join(testDirectory, inputFile)));
|
||||
}
|
||||
|
|
BIN
API.Tests/Services/Test Data/ArchiveService/Archives/empty.zip
Normal file
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 |