refactor: Rename ConfigListCategory enum

pull/201/head
Robert Dailey 2 years ago
parent 579cadb9db
commit ca941ac31d

@ -20,9 +20,9 @@ public class ConfigListCommand : AsyncCommand<ConfigListCommand.CliSettings>
public class CliSettings : BaseCommandSettings public class CliSettings : BaseCommandSettings
{ {
[CommandArgument(0, "[ListCategory]")] [CommandArgument(0, "[ListCategory]")]
[EnumDescription<ConfigListCategory>( [EnumDescription<ConfigCategory>(
"The type of configuration information to list. If not specified, defaults to 'local'.")] "The type of configuration information to list. If not specified, defaults to 'local'.")]
public ConfigListCategory ListCategory { get; [UsedImplicitly] init; } = ConfigListCategory.Local; public ConfigCategory ListCategory { get; [UsedImplicitly] init; } = ConfigCategory.Local;
} }
public ConfigListCommand(ILogger log, ConfigListProcessor processor) public ConfigListCommand(ILogger log, ConfigListProcessor processor)

@ -7,12 +7,12 @@ namespace Recyclarr.Cli.Processors.Config;
public class ConfigListProcessor public class ConfigListProcessor
{ {
private readonly ILogger _log; private readonly ILogger _log;
private readonly IIndex<ConfigListCategory, IConfigLister> _configListers; private readonly IIndex<ConfigCategory, IConfigLister> _configListers;
private readonly IConfigTemplatesRepo _repo; private readonly IConfigTemplatesRepo _repo;
public ConfigListProcessor( public ConfigListProcessor(
ILogger log, ILogger log,
IIndex<ConfigListCategory, IConfigLister> configListers, IIndex<ConfigCategory, IConfigLister> configListers,
IConfigTemplatesRepo repo) IConfigTemplatesRepo repo)
{ {
_log = log; _log = log;
@ -20,9 +20,9 @@ public class ConfigListProcessor
_repo = repo; _repo = repo;
} }
public async Task Process(ConfigListCategory listCategory) public async Task Process(ConfigCategory listCategory)
{ {
if (listCategory == ConfigListCategory.Templates) if (listCategory == ConfigCategory.Templates)
{ {
await _repo.Update(); await _repo.Update();
} }

@ -37,7 +37,7 @@ public class ConfigAutofacModule : Module
builder.RegisterType<ConfigParser>(); builder.RegisterType<ConfigParser>();
// Config Listers // Config Listers
builder.RegisterType<ConfigTemplateLister>().Keyed<IConfigLister>(ConfigListCategory.Templates); builder.RegisterType<ConfigTemplateLister>().Keyed<IConfigLister>(ConfigCategory.Templates);
builder.RegisterType<ConfigLocalLister>().Keyed<IConfigLister>(ConfigListCategory.Local); builder.RegisterType<ConfigLocalLister>().Keyed<IConfigLister>(ConfigCategory.Local);
} }
} }

@ -1,6 +1,6 @@
namespace Recyclarr.TrashLib.Config.Listers; namespace Recyclarr.TrashLib.Config.Listers;
public enum ConfigListCategory public enum ConfigCategory
{ {
Local, Local,
Templates Templates

@ -10,10 +10,10 @@ namespace Recyclarr.Cli.Tests.Processors;
public class ConfigListProcessorTest public class ConfigListProcessorTest
{ {
[Test] [Test]
[InlineAutoMockData(ConfigListCategory.Templates)] [InlineAutoMockData(ConfigCategory.Templates)]
public async Task List_templates_invokes_correct_lister( public async Task List_templates_invokes_correct_lister(
ConfigListCategory category, ConfigCategory category,
[Frozen(Matching.ImplementedInterfaces)] StubAutofacIndex<ConfigListCategory, IConfigLister> configListers, [Frozen(Matching.ImplementedInterfaces)] StubAutofacIndex<ConfigCategory, IConfigLister> configListers,
IConfigLister lister, IConfigLister lister,
ConfigListProcessor sut) ConfigListProcessor sut)
{ {

@ -8,15 +8,15 @@ namespace Recyclarr.TrashLib.Tests.Config;
[Parallelizable(ParallelScope.All)] [Parallelizable(ParallelScope.All)]
public class ConfigAutofacModuleTest : TrashLibIntegrationFixture public class ConfigAutofacModuleTest : TrashLibIntegrationFixture
{ {
private static IEnumerable<ConfigListCategory> AllConfigListCategories() private static IEnumerable<ConfigCategory> AllConfigListCategories()
{ {
return Enum.GetValues<ConfigListCategory>(); return Enum.GetValues<ConfigCategory>();
} }
[TestCaseSource(nameof(AllConfigListCategories))] [TestCaseSource(nameof(AllConfigListCategories))]
public void All_list_category_types_registered(ConfigListCategory category) public void All_list_category_types_registered(ConfigCategory category)
{ {
var sut = Resolve<IIndex<ConfigListCategory, IConfigLister>>(); var sut = Resolve<IIndex<ConfigCategory, IConfigLister>>();
var result = sut.TryGetValue(category, out _); var result = sut.TryGetValue(category, out _);
result.Should().BeTrue(); result.Should().BeTrue();
} }

Loading…
Cancel
Save