Exemple #1
0
        public void Parse_options_with_double_dash_in_verbs_scenario()
        {
            // Fixture setup
            var expectedOptions = new Add_Verb {
                Patch = true, FileName = "--strange-fn"
            };
            var sut = new Parser(with => with.EnableDashDash = true);

            // Exercize system
            var result = sut.ParseArguments(
                new[] { "add", "-p", "--", "--strange-fn" },
                typeof(Add_Verb),
                typeof(Commit_Verb),
                typeof(Clone_Verb));

            // Verify outcome
            Assert.IsType <Add_Verb>(((Parsed <object>)result).Value);
            ((Parsed <object>)result).Value.Should().BeEquivalentTo(expectedOptions, o => o.RespectingRuntimeTypes());
            // Teardown
        }
Exemple #2
0
        public void Parse_existing_verb_returns_verb_instance()
        {
            // Fixture setup
            var expected = new Add_Verb {
                Patch = true, FileName = "dummy.bin"
            };

            // Exercize system
            var result = InstanceChooser.Choose(
                new[] { typeof(Add_Verb), typeof(Commit_Verb), typeof(Clone_Verb) },
                new[] { "add", "--patch", "dummy.bin" },
                StringComparer.Ordinal,
                CultureInfo.InvariantCulture,
                Enumerable.Empty <ErrorType>());

            // Verify outcome
            Assert.IsType <Add_Verb>(((Parsed <object>)result).Value);
            expected.ShouldBeEquivalentTo(((Parsed <object>)result).Value);
            // Teardown
        }
Exemple #3
0
 public static void UnParsing_instance_returns_command_line_for_verbs(Add_Verb verb, string result)
 {
     new Parser()
     .FormatCommandLine(verb)
     .Should().BeEquivalentTo(result);
 }