public void AddCommand_throws_InvaldModelException_if_command_with_the_same_name_already_exists(string commandName1, string commandName2) { // ARRANGE var sut = new MultiCommandApplicationDocumentation("app", "1.0"); _ = sut.AddCommand(commandName1); // ACT / ASSERT Assert.Throws <InvalidModelException>(() => sut.AddCommand(commandName2)); }
public static MultiCommandApplicationDocumentation WithCommand(this MultiCommandApplicationDocumentation application, string name, string?helpText = null) { var command = application.AddCommand(name); command.Description = helpText; return(application); }
public void AddCommand_throws_InvaldModelException_if_command_name_is_null_or_whitespace(string commandName) { // ARRANGE var sut = new MultiCommandApplicationDocumentation("app", "1.0"); // ACT / ASSERT Assert.Throws <InvalidModelException>(() => sut.AddCommand(commandName)); }
public void Name_and_short_name_must_not_be_both_null_or_empty(string invalidName) { // ARRANGE var application = new MultiCommandApplicationDocumentation("app", "1.2.3"); var command = application.AddCommand("command"); // ACT / ASSERT Assert.Throws <ArgumentException>(() => new SwitchParameterDocumentation(application, command, invalidName, invalidName)); }
private void LoadCommands(MultiCommandApplicationDocumentation applicationDocumentation, AssemblyDefinition assembly) { var commandTypes = assembly.MainModule .GetAllTypes() .Where(x => !x.IsAbstract) .WithAttribute(CommandLineParserTypeNames.VerbAttributeFullName) .Where(x => !x.GetAttribute(CommandLineParserTypeNames.VerbAttributeFullName).GetPropertyValueOrDefault <bool>(s_Hidden)); foreach (var commandType in commandTypes) { var verbAttribute = commandType.GetAttribute(CommandLineParserTypeNames.VerbAttributeFullName); var name = (string)verbAttribute.ConstructorArguments.First(x => x.Type.FullName == SystemTypeNames.StringFullName).Value; var commandDocumentation = applicationDocumentation.AddCommand(name); commandDocumentation.Description = verbAttribute.GetPropertyValueOrDefault <string>(s_HelpText); LoadOptions(commandDocumentation, commandType); LoadValues(commandDocumentation, commandType); } }
public void GetDocument_returns_expected_document_01() { var model = m_ApplicationDocumentation.AddCommand("Command1"); Approve(model); }