public async Task UninstallTemplates_UnknownNuGet_Should_Return_NotFound() { // Arrange var executor = new Mock <ICommandExecutor>(); executor.Setup(c => c.ExecuteAsync($"{NetCoreTool.Command} new --list", null, -1)) .ReturnsAsync(new CommandResult { ExitCode = 0, Output = @" ------------------- -------- --------- --------- ", } ); executor.Setup(c => c.ExecuteAsync($"{NetCoreTool.Command} new --uninstall My.Templates", null, -1)) .ReturnsAsync(new CommandResult { ExitCode = 0, Output = @" Could not find something to uninstall called 'My.Templates'. ", } ); var controller = new NewController(executor.Object); // Act var result = await controller.UninstallTemplates("My.Templates"); // Assert var notFound = Assert.IsType <NotFoundObjectResult>(result); notFound.Value.Should().Be("No templates with NuGet ID 'My.Templates' installed."); }
public async Task UninstallTemplates_Should_Return_UninstalledTemplates() { // Arrange var executor = new Mock <ICommandExecutor>(); executor.SetupSequence(c => c.ExecuteAsync($"{NetCoreTool.Command} new --list", null, -1)) .ReturnsAsync(new CommandResult { ExitCode = 0, Output = @" ------------------- -------- --------- ---------- A New Template ant smalltalk newstuff My Template myt lang tags My Other Template myot otherlang othertags Other New Template ont bigtalk otherstuff ", } ) .ReturnsAsync(new CommandResult { ExitCode = 0, Output = @" ------------------- -------- --------- --------- My Template myt lang tags My Other Template myot otherlang othertags ", } ); executor.Setup(c => c.ExecuteAsync($"{NetCoreTool.Command} new --uninstall My.Templates", null, -1)) .ReturnsAsync(new CommandResult { ExitCode = 0, Output = "", } ); var controller = new NewController(executor.Object); // Act var result = await controller.UninstallTemplates("My.Templates"); // Assert var ok = Assert.IsType <OkObjectResult>(result); var templates = Assert.IsType <TemplateDictionary>(ok.Value); templates.Count.Should().Be(2); templates["ant"].Name.Should().Be("A New Template"); templates["ant"].Languages.Should().Be("smalltalk"); templates["ant"].Tags.Should().Be("newstuff"); templates["ont"].Name.Should().Be("Other New Template"); templates["ont"].Languages.Should().Be("bigtalk"); templates["ont"].Tags.Should().Be("otherstuff"); }