From 91db02375ae598a563acb283b06f3c77fb7b118e Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Mon, 27 Dec 2021 22:23:15 -0600 Subject: [PATCH] (#499) Add specs for template service list noop Add tests to ensure that the template service list noop function outputs the correct log messages. --- .../services/TemplateServiceSpecs.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs index 6c47da2c2b..7f9f2802be 100644 --- a/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs @@ -824,5 +824,42 @@ public void should_use_template_name_from_command_line_option() config.NewCommand.TemplateName.ShouldEqual("zip"); } } + + public class when_list_noop_is_called : TemplateServiceSpecsBase + { + private Action because; + private readonly ChocolateyConfiguration config = new ChocolateyConfiguration(); + + public override void Because() + { + because = () => service.list_noop(config); + } + + public override void BeforeEachSpec() + { + MockLogger.reset(); + } + + [Fact] + public void should_log_template_location_if_no_template_name() + { + because(); + + var infos = MockLogger.MessagesFor(LogLevel.Info); + infos.Count.ShouldEqual(1); + infos[0].ShouldEqual("Would have listed templates in {0}".format_with(ApplicationParameters.TemplatesLocation)); + } + + [Fact] + public void should_log_template_name_if_template_name() + { + config.TemplateCommand.Name = "msi"; + because(); + + var infos = MockLogger.MessagesFor(LogLevel.Info); + infos.Count.ShouldEqual(1); + infos[0].ShouldEqual("Would have listed information about {0}".format_with(config.TemplateCommand.Name)); + } + } } }