Used to build a flat list of CFs from the guide.pull/92/head
parent
9eebc227c5
commit
2ba2bf299c
@ -0,0 +1,36 @@
|
|||||||
|
using AutoFixture.NUnit3;
|
||||||
|
using CliFx.Infrastructure;
|
||||||
|
using FluentAssertions;
|
||||||
|
using NSubstitute;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using TestLibrary.AutoFixture;
|
||||||
|
using TrashLib.Radarr.CustomFormat;
|
||||||
|
using TrashLib.Radarr.CustomFormat.Guide;
|
||||||
|
using TrashLib.TestLibrary;
|
||||||
|
|
||||||
|
namespace TrashLib.Tests.Radarr.CustomFormat;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
[Parallelizable(ParallelScope.All)]
|
||||||
|
public class CustomFormatListerTest
|
||||||
|
{
|
||||||
|
[Test, AutoMockData]
|
||||||
|
public void Custom_formats_appear_in_console_output(
|
||||||
|
[Frozen] IRadarrGuideService guide,
|
||||||
|
[Frozen(Matching.ImplementedInterfaces)] FakeInMemoryConsole console,
|
||||||
|
CustomFormatLister sut)
|
||||||
|
{
|
||||||
|
var testData = new[]
|
||||||
|
{
|
||||||
|
NewCf.Data("First", "123"),
|
||||||
|
NewCf.Data("Second", "456")
|
||||||
|
};
|
||||||
|
|
||||||
|
guide.GetCustomFormatData().Returns(testData);
|
||||||
|
|
||||||
|
sut.ListCustomFormats();
|
||||||
|
|
||||||
|
console.ReadOutputString().Should().ContainAll(
|
||||||
|
testData.SelectMany(x => new[] {x.Name, x.TrashId}));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
using CliFx.Infrastructure;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using TrashLib.Radarr.CustomFormat.Guide;
|
||||||
|
|
||||||
|
namespace TrashLib.Radarr.CustomFormat;
|
||||||
|
|
||||||
|
[UsedImplicitly]
|
||||||
|
public class CustomFormatLister : ICustomFormatLister
|
||||||
|
{
|
||||||
|
private readonly IConsole _console;
|
||||||
|
private readonly IRadarrGuideService _guide;
|
||||||
|
|
||||||
|
public CustomFormatLister(IConsole console, IRadarrGuideService guide)
|
||||||
|
{
|
||||||
|
_console = console;
|
||||||
|
_guide = guide;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ListCustomFormats()
|
||||||
|
{
|
||||||
|
_console.Output.WriteLine("\nList of Custom Formats in the TRaSH Guides:\n");
|
||||||
|
|
||||||
|
var profilesFromGuide = _guide.GetCustomFormatData();
|
||||||
|
foreach (var profile in profilesFromGuide)
|
||||||
|
{
|
||||||
|
_console.Output.WriteLine($" - {profile.TrashId} # {profile.Name}");
|
||||||
|
}
|
||||||
|
|
||||||
|
_console.Output.WriteLine(
|
||||||
|
"\nThe above Custom Formats are in YAML format and ready to be copied & pasted " +
|
||||||
|
"under the `trash_ids:` property.");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
namespace TrashLib.Radarr.CustomFormat;
|
||||||
|
|
||||||
|
public interface ICustomFormatLister
|
||||||
|
{
|
||||||
|
void ListCustomFormats();
|
||||||
|
}
|
Loading…
Reference in new issue