|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
using System.IO.Abstractions;
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
using Autofac;
|
|
|
|
|
using Recyclarr.TestLibrary.Autofac;
|
|
|
|
|
using Recyclarr.Tests.TestLibrary;
|
|
|
|
|
using Recyclarr.TrashGuide.CustomFormat;
|
|
|
|
|
|
|
|
|
@ -9,6 +11,12 @@ namespace Recyclarr.IntegrationTests;
|
|
|
|
|
[Parallelizable(ParallelScope.All)]
|
|
|
|
|
public class CustomFormatLoaderIntegrationTest : IntegrationTestFixture
|
|
|
|
|
{
|
|
|
|
|
protected override void RegisterStubsAndMocks(ContainerBuilder builder)
|
|
|
|
|
{
|
|
|
|
|
base.RegisterStubsAndMocks(builder);
|
|
|
|
|
builder.RegisterMockFor<ICustomFormatCategoryParser>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Get_custom_format_json_works()
|
|
|
|
|
{
|
|
|
|
@ -26,4 +34,24 @@ public class CustomFormatLoaderIntegrationTest : IntegrationTestFixture
|
|
|
|
|
NewCf.Data("second", "2")
|
|
|
|
|
}, o => o.Excluding(x => x.Type == typeof(JsonElement)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Categorize_by_file_name()
|
|
|
|
|
{
|
|
|
|
|
var categoryParser = Resolve<ICustomFormatCategoryParser>();
|
|
|
|
|
categoryParser.Parse(default!).ReturnsForAnyArgs(new[]
|
|
|
|
|
{
|
|
|
|
|
new CustomFormatCategoryItem("Streaming Services", "iTunes", "iT")
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Fs.AddFile("it.json", new MockFileData("""{"name":"iT"}"""));
|
|
|
|
|
Fs.AddEmptyFile("collection_of_cfs.md");
|
|
|
|
|
|
|
|
|
|
var sut = Resolve<CustomFormatLoader>();
|
|
|
|
|
|
|
|
|
|
var dir = Fs.CurrentDirectory();
|
|
|
|
|
var results = sut.LoadAllCustomFormatsAtPaths(new[] {dir}, dir.File("collection_of_cfs.md"));
|
|
|
|
|
|
|
|
|
|
results.Should().ContainSingle().Which.Category.Should().Be("Streaming Services");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|