Cover Image - First and tests (#170)
* Changed how natural sort works to cover more cases * Changed the name of CoverImage regex for Parser and added more cases. * Changed how we get result from Task.Run() * Defer execution of a loop till we really need it and added another TODO for later this iteration. * Big refactor to cover image code to unify between IOCompression and SharpCompress. Both use methods to find the correct file. This results in one extra loop through entries, but simplifies code signficantly. In addition, new unit tests for the methods that actually do the logic on choosing cover file and first file. * Removed dead code * Added missing doc
This commit is contained in:
parent
9e5bcb8501
commit
6ba00477e7
13 changed files with 169 additions and 99 deletions
|
@ -7,6 +7,8 @@ namespace API.Tests.Comparers
|
|||
{
|
||||
public class NaturalSortComparerTest
|
||||
{
|
||||
private readonly NaturalSortComparer _nc = new NaturalSortComparer();
|
||||
|
||||
[Theory]
|
||||
[InlineData(
|
||||
new[] {"x1.jpg", "x10.jpg", "x3.jpg", "x4.jpg", "x11.jpg"},
|
||||
|
@ -20,10 +22,25 @@ namespace API.Tests.Comparers
|
|||
new[] {"[SCX-Scans]_Vandread_v02_Act02.zip", "[SCX-Scans]_Vandread_v02_Act01.zip",},
|
||||
new[] {"[SCX-Scans]_Vandread_v02_Act01.zip", "[SCX-Scans]_Vandread_v02_Act02.zip",}
|
||||
)]
|
||||
[InlineData(
|
||||
new[] {"Frogman v01 001.jpg", "Frogman v01 ch01 p00 Credits.jpg",},
|
||||
new[] {"Frogman v01 001.jpg", "Frogman v01 ch01 p00 Credits.jpg",}
|
||||
)]
|
||||
[InlineData(
|
||||
new[] {"001.jpg", "10.jpg",},
|
||||
new[] {"001.jpg", "10.jpg",}
|
||||
)]
|
||||
[InlineData(
|
||||
new[] {"10/001.jpg", "10.jpg",},
|
||||
new[] {"10.jpg", "10/001.jpg",}
|
||||
)]
|
||||
[InlineData(
|
||||
new[] {"Batman - Black white vol 1 #04.cbr", "Batman - Black white vol 1 #03.cbr", "Batman - Black white vol 1 #01.cbr", "Batman - Black white vol 1 #02.cbr"},
|
||||
new[] {"Batman - Black white vol 1 #01.cbr", "Batman - Black white vol 1 #02.cbr", "Batman - Black white vol 1 #03.cbr", "Batman - Black white vol 1 #04.cbr"}
|
||||
)]
|
||||
public void TestNaturalSortComparer(string[] input, string[] expected)
|
||||
{
|
||||
NaturalSortComparer nc = new NaturalSortComparer();
|
||||
Array.Sort(input, nc);
|
||||
Array.Sort(input, _nc);
|
||||
|
||||
var i = 0;
|
||||
foreach (var s in input)
|
||||
|
@ -51,10 +68,25 @@ namespace API.Tests.Comparers
|
|||
new[] {"[SCX-Scans]_Vandread_v02_Act02.zip", "[SCX-Scans]_Vandread_v02_Act01.zip","[SCX-Scans]_Vandread_v02_Act07.zip",},
|
||||
new[] {"[SCX-Scans]_Vandread_v02_Act01.zip", "[SCX-Scans]_Vandread_v02_Act02.zip","[SCX-Scans]_Vandread_v02_Act07.zip",}
|
||||
)]
|
||||
[InlineData(
|
||||
new[] {"Frogman v01 001.jpg", "Frogman v01 ch01 p00 Credits.jpg",},
|
||||
new[] {"Frogman v01 001.jpg", "Frogman v01 ch01 p00 Credits.jpg",}
|
||||
)]
|
||||
[InlineData(
|
||||
new[] {"001.jpg", "10.jpg",},
|
||||
new[] {"001.jpg", "10.jpg",}
|
||||
)]
|
||||
[InlineData(
|
||||
new[] {"10/001.jpg", "10.jpg",},
|
||||
new[] {"10.jpg", "10/001.jpg",}
|
||||
)]
|
||||
[InlineData(
|
||||
new[] {"Batman - Black white vol 1 #04.cbr", "Batman - Black white vol 1 #03.cbr", "Batman - Black white vol 1 #01.cbr", "Batman - Black white vol 1 #02.cbr"},
|
||||
new[] {"Batman - Black white vol 1 #01.cbr", "Batman - Black white vol 1 #02.cbr", "Batman - Black white vol 1 #03.cbr", "Batman - Black white vol 1 #04.cbr"}
|
||||
)]
|
||||
public void TestNaturalSortComparerLinq(string[] input, string[] expected)
|
||||
{
|
||||
NaturalSortComparer nc = new NaturalSortComparer();
|
||||
var output = input.OrderBy(c => c, nc);
|
||||
var output = input.OrderBy(c => c, _nc);
|
||||
|
||||
var i = 0;
|
||||
foreach (var s in output)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue