public void FormattedOutput_ShouldAddOutputOption() { var sw = new StringWriter(); var command = new DummyApiCommandWithFormattedOutputSupport(ClientFactory, RepositoryFactory, FileSystem, CommandOutputProvider); command.GetHelp(sw, new[] { "command" }); sw.ToString().Should().ContainEquivalentOf("--output"); }
public async Task FormattedOutput_FormatSetToJson() { var command = new DummyApiCommandWithFormattedOutputSupport(ClientFactory, RepositoryFactory, FileSystem, CommandOutputProvider); CommandLineArgs.Add("--outputFormat=json"); await command.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); command.PrintJsonOutputCalled.ShouldBeEquivalentTo(true); }
public void FormattedOutput_FormatInvalid() { var command = new DummyApiCommandWithFormattedOutputSupport(ClientFactory, RepositoryFactory, FileSystem, CommandOutputProvider); CommandLineArgs.Add("--helpOutputFormat=blah"); var exception = Assert.ThrowsAsync <CommandException>(async() => await command.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false)); command.PrintJsonOutputCalled.Should().BeFalse(); command.PrintDefaultOutputCalled.Should().BeFalse(); exception.Message.Should().Be("Could not convert string `blah' to type OutputFormat for option `--helpOutputFormat'. Valid values are Default and Json."); }
public async Task FormattedOutput_FormatInvalid() { // arrange DummyApiCommandWithFormattedOutputSupport command = new DummyApiCommandWithFormattedOutputSupport(ClientFactory, RepositoryFactory, FileSystem, CommandOutputProvider); CommandLineArgs.Add("--helpOutputFormat=blah"); // act await command.Execute(CommandLineArgs.ToArray()); // assert command.PrintJsonOutputCalled.ShouldBeEquivalentTo(false); command.PrintDefaultOutputCalled.ShouldBeEquivalentTo(true); }
public async Task PlainTextFormattedOutputHelp_ShouldBeWellFormed() { var command = new DummyApiCommandWithFormattedOutputSupport(ClientFactory, RepositoryFactory, FileSystem, CommandOutputProvider); CommandLineArgs.Add("--help"); await command.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); var logOutput = LogOutput.ToString(); Console.WriteLine(logOutput); logOutput.Should().Contain("--helpOutputFormat=VALUE"); logOutput.Should().Contain("--help"); logOutput.Should().Contain("dummy-command"); logOutput.Should().Contain("this is the command's description"); }
public async Task FormattedOutputHelp_ShouldBeWellFormed() { // arrange DummyApiCommandWithFormattedOutputSupport command = new DummyApiCommandWithFormattedOutputSupport(ClientFactory, RepositoryFactory, FileSystem, CommandOutputProvider); CommandLineArgs.Add("--helpOutputFormat=json"); CommandLineArgs.Add("--help"); // act await command.Execute(CommandLineArgs.ToArray()); // assert var logoutput = LogOutput.ToString(); Console.WriteLine(logoutput); JsonConvert.DeserializeObject(logoutput); logoutput.Should().Contain("--helpOutputFormat=VALUE"); logoutput.Should().Contain("--help"); }