예제 #1
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 Parser();
            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.");
        }
예제 #2
0
        public void ParseStrictBadInputFailsAndExits_Verbs()
        {
            var options = new OptionsWithVerbsNoHelp();
            var testWriter = new StringWriter();

            Result = Parser.ParseArgumentsStrict(new string[] { "bad", "input" }, options, testWriter);

            ResultShouldBeFalse();

            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().Count.Exactly(8);
            // Verify just significant output
            lines[5].Trim().Should().Equal("add       Add file contents to the index.");
            lines[6].Trim().Should().Equal("commit    Record changes to the repository.");
            lines[7].Trim().Should().Equal("clone     Clone a repository into a new directory.");
        }