Parser Enhancement: Fallback to Folder name (#129)

* More cases for parsing regex

* Implemented GetFoldersTillRoot for falling back on parsing when we can't get anything from the filename.

* Implemented a fallback strategy. Not tested on large libraries yet.

* Fallback tested and working great.

* Removed a test case that won't pass and added some trims
This commit is contained in:
Joseph Milazzo 2021-03-29 17:37:35 -05:00 committed by GitHub
parent d9246b7351
commit a0deafe75b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 94 additions and 10 deletions

View file

@ -74,5 +74,17 @@ namespace API.Tests.Services
Assert.DoesNotContain(dirs, s => s.Contains("regex"));
}
[Theory]
[InlineData("C:/Manga/", "C:/Manga/Love Hina/Specials/Omake/", "Omake,Specials,Love Hina")]
[InlineData("C:/Manga/", "C:/Manga/Love Hina/Specials/Omake", "Omake,Specials,Love Hina")]
[InlineData("C:/Manga", "C:/Manga/Love Hina/Specials/Omake/", "Omake,Specials,Love Hina")]
[InlineData("C:/Manga", @"C:\Manga\Love Hina\Specials\Omake\", "Omake,Specials,Love Hina")]
[InlineData(@"/manga/", @"/manga/Love Hina/Specials/Omake/", "Omake,Specials,Love Hina")]
public void GetFoldersTillRoot_Test(string rootPath, string fullpath, string expectedArray)
{
var expected = expectedArray.Split(",");
Assert.Equal(expected, DirectoryService.GetFoldersTillRoot(rootPath, fullpath));
}
}
}