コード例 #1
0
        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));
        }
コード例 #2
0
        public static MultiCommandApplicationDocumentation WithCommand(this MultiCommandApplicationDocumentation application, string name, string?helpText = null)
        {
            var command = application.AddCommand(name);

            command.Description = helpText;

            return(application);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        public void GetDocument_returns_expected_document_01()
        {
            var model = m_ApplicationDocumentation.AddCommand("Command1");

            Approve(model);
        }