using System.IO.Abstractions; using Recyclarr.Config.Parsing.PostProcessing.ConfigMerging; using Recyclarr.TrashGuide; namespace Recyclarr.Tests.Config.Parsing.PostProcessing.ConfigMerging; [TestFixture] public class YamlIncludeResolverTest { [Test] public void Find_and_return_processor() { var processors = new[] { Substitute.For(), Substitute.For() }; processors[1].CanProcess(default!).ReturnsForAnyArgs(true); processors[1].GetPathToConfig(default!, default!).ReturnsForAnyArgs(_ => { var fileInfo = Substitute.For(); fileInfo.Exists.Returns(true); fileInfo.FullName.Returns("the_path"); return fileInfo; }); var sut = new YamlIncludeResolver(processors); var result = sut.GetIncludePath(Substitute.For(), SupportedServices.Radarr); result.FullName.Should().Be("the_path"); } [Test] public void Throw_when_no_matching_processor() { var processors = new[] { Substitute.For(), Substitute.For() }; var sut = new YamlIncludeResolver(processors); var act = () => sut.GetIncludePath(Substitute.For(), SupportedServices.Radarr); act.Should().Throw().WithMessage("*type is not supported*"); } [Test] public void Throw_when_path_does_not_exist() { var processors = new[] { Substitute.For(), Substitute.For() }; processors[1].CanProcess(default!).ReturnsForAnyArgs(true); processors[1].GetPathToConfig(default!, default!).ReturnsForAnyArgs(_ => { var fileInfo = Substitute.For(); fileInfo.Exists.Returns(false); return fileInfo; }); var sut = new YamlIncludeResolver(processors); var act = () => sut.GetIncludePath(Substitute.For(), SupportedServices.Radarr); act.Should().Throw().WithMessage("*does not exist*"); } }