Exemple #1
0
        public void Parse_strict_bad_input_fails_and_exits_when_get_usage_is_defined()
        {
            var options = new SimpleOptionsForStrict();
            var testWriter = new StringWriter();

            ReflectionUtil.AssemblyFromWhichToPullInformation = Assembly.GetExecutingAssembly();
            var parser = new CommandLineParser();
            var result = parser.ParseArgumentsStrict(new string[] { "--bad", "--input" }, options, testWriter);

            result.Should().BeFalse();

            var helpText = testWriter.ToString();
            Console.WriteLine(helpText);
            var lines = helpText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            // Did we really called user help method?
            lines.Should().HaveCount(n => n == 1);
            // Verify just significant output
            lines[0].Trim().Should().Be("SimpleOptionsForStrict (user defined)");
        }
Exemple #2
0
        public void Parse_strict_bad_input_fails_and_exits()
        {
            var options = new SimpleOptions();
            var testWriter = new StringWriter();

            ReflectionUtil.AssemblyFromWhichToPullInformation = Assembly.GetExecutingAssembly();
            var parser = new CommandLineParser();
            var result = parser.ParseArgumentsStrict(new string[] {"--bad", "--input"}, options, testWriter);

            result.Should().BeFalse();

            var helpText = testWriter.ToString();
            Console.WriteLine(helpText);
            var lines = helpText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            // Did we really produced all help?
            lines.Should().HaveCount(n => n == 8);
            // Verify just significant output
            lines[5].Trim().Should().Be("-s, --string");
            lines[6].Trim().Should().Be("-i");
            lines[7].Trim().Should().Be("--switch");
        }
Exemple #3
0
        public void Parse_strict_bad_input_fails_and_exits_with_verbs()
        {
            var options = new OptionsWithVerbsNoHelp();
            var testWriter = new StringWriter();

            ReflectionUtil.AssemblyFromWhichToPullInformation = Assembly.GetExecutingAssembly();
            var parser = new CommandLineParser();
            var result = parser.ParseArgumentsStrict(new string[] { "bad", "input" }, options, testWriter);

            result.Should().BeFalse();

            var helpText = testWriter.ToString();
            Console.WriteLine(helpText);
            var lines = helpText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            // Did we really produced all help?
            lines.Should().HaveCount(n => n == 8);
            // Verify just significant output
            lines[5].Trim().Should().Be("add       Add file contents to the index.");
            lines[6].Trim().Should().Be("commit    Record changes to the repository.");
            lines[7].Trim().Should().Be("clone     Clone a repository into a new directory.");
        }