コード例 #1
0
        public void Parse_options_with_double_dash_in_verbs_scenario()
        {
            // Fixture setup
            var expectedOptions = new AddOptions
                {
                    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(AddOptions), typeof(CommitOptions), typeof(CloneOptions));

            // Verify outcome
            Assert.IsType<AddOptions>(result.Value);
            result.Value.ShouldBeEquivalentTo(expectedOptions, o => o.RespectingRuntimeTypes());
            Assert.False(result.Errors.Any());
            // Teardown
        }
コード例 #2
0
                .FormatCommandLine(options)
                .ShouldBeEquivalentTo(result);
        }

        [Theory]
        [MemberData("UnParseDataVerbs")]
コード例 #3
0
        public void Parse_existing_verb_returns_verb_instance()
        {
            // Fixture setup
            var expected = new AddOptions { Patch = true, FileName = "dummy.bin"};

            // Exercize system 
            var result = InstanceChooser.Choose(
                new[] { typeof(AddOptions), typeof(CommitOptions), typeof(CloneOptions) },
                new[] { "add", "--patch", "dummy.bin" },
                StringComparer.Ordinal,
                CultureInfo.InvariantCulture);

            // Verify outcome
            Assert.IsType<AddOptions>(result.Value);
            expected.ShouldHave().AllRuntimeProperties().EqualTo(result.Value);
            // Teardown
        }    
コード例 #4
0
        public void Parse_existing_verb_returns_verb_instance()
        {
            // Fixture setup
            var expected = new AddOptions { Patch = true, FileName = "dummy.bin"};

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

            // Verify outcome
            Assert.IsType<AddOptions>(((Parsed<object>)result).Value);
            expected.ShouldBeEquivalentTo(((Parsed<object>)result).Value);
            // Teardown
        }