Skip to content

Commit

Permalink
(chocolatey#499) Add specs for template service list noop
Browse files Browse the repository at this point in the history
Add tests to ensure that the template service list noop function outputs
the correct log messages.
  • Loading branch information
TheCakeIsNaOH authored and gep13 committed Jan 10, 2022
1 parent 09b85d0 commit a8d08a8
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
}

0 comments on commit a8d08a8

Please sign in to comment.