public async Task GetTemplateHelp_Should_Return_Help() { // Arrange var executor = new Mock <ICommandExecutor>(); executor.Setup(c => c.ExecuteAsync($"{NetCoreTool.Command} new mytemplate --help", null, -1)) .ReturnsAsync(new CommandResult { ExitCode = 0, Output = @" Some helpful tips for you ", } ); var controller = new NewController(executor.Object); // Act var result = await controller.GetTemplateHelp("mytemplate"); // Assert var ok = Assert.IsType <OkObjectResult>(result); var help = Assert.IsType <string>(ok.Value); help.Should().Be("Some helpful tips for you"); }
public async Task GetTemplateHelp_UnknownTemplate_Should_Return_NotFound() { // Arrange var executor = new Mock <ICommandExecutor>(); executor.Setup(c => c.ExecuteAsync($"{NetCoreTool.Command} new nosuchtemplate --help", null, -1)) .ReturnsAsync(new CommandResult { ExitCode = 6, Error = @" No templates found matching: 'nosuchtemplate'. ", } ); var controller = new NewController(executor.Object); // Act var result = await controller.GetTemplateHelp("nosuchtemplate"); // Assert var notFound = Assert.IsType <NotFoundObjectResult>(result); notFound.Value.Should().Be("No templates found matching: 'nosuchtemplate'."); }