|
|
|
@ -2,9 +2,11 @@ using System.IO.Abstractions;
|
|
|
|
|
using System.IO.Abstractions.TestingHelpers;
|
|
|
|
|
using AutoFixture.NUnit3;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using NSubstitute;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using TestLibrary.AutoFixture;
|
|
|
|
|
using TestLibrary.FluentAssertions;
|
|
|
|
|
using TrashLib.Repo;
|
|
|
|
|
using TrashLib.Services.Radarr.CustomFormat.Guide;
|
|
|
|
|
using TrashLib.Startup;
|
|
|
|
@ -41,4 +43,36 @@ public class LocalRepoRadarrGuideServiceTest
|
|
|
|
|
NewCf.Data("second", "2")
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test, AutoMockData]
|
|
|
|
|
public void Trash_properties_are_removed(
|
|
|
|
|
[Frozen(Matching.ImplementedInterfaces)] MockFileSystem fs,
|
|
|
|
|
[Frozen] IAppPaths appPaths,
|
|
|
|
|
[Frozen] IRepoPaths repoPaths,
|
|
|
|
|
LocalRepoRadarrGuideService sut)
|
|
|
|
|
{
|
|
|
|
|
var jsonDir = appPaths.RepoDirectory
|
|
|
|
|
.SubDirectory("docs")
|
|
|
|
|
.SubDirectory("json")
|
|
|
|
|
.SubDirectory("radarr");
|
|
|
|
|
|
|
|
|
|
fs.AddFile(jsonDir.File("first.json").FullName, new MockFileData(@"
|
|
|
|
|
{
|
|
|
|
|
'name':'first',
|
|
|
|
|
'trash_id':'1',
|
|
|
|
|
'trash_foo': 'foo',
|
|
|
|
|
'trash_bar': 'bar',
|
|
|
|
|
'extra': 'e1'
|
|
|
|
|
}"));
|
|
|
|
|
|
|
|
|
|
repoPaths.RadarrCustomFormatPaths.Returns(new[] {jsonDir});
|
|
|
|
|
|
|
|
|
|
var results = sut.GetCustomFormatData();
|
|
|
|
|
|
|
|
|
|
const string expectedExtraJson = @"{'name':'first','extra': 'e1'}";
|
|
|
|
|
|
|
|
|
|
results.Should()
|
|
|
|
|
.ContainSingle().Which.ExtraJson.Should()
|
|
|
|
|
.BeEquivalentTo(JObject.Parse(expectedExtraJson), op => op.Using(new JsonEquivalencyStep()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|