コード例 #1
0
        public void Accept_Returns_Null_On_UnhandledInput(string[] input, int index)
        {
            var option = new JoinedOrSeparateOption(1, "-", "foo");

            int idx = 0;
            var arg = option.Accept(input, ref idx);

            Assert.Equal(index, idx);
            Assert.Null(arg);
        }
コード例 #2
0
        public void ConstructMinimal()
        {
            var option = new JoinedOrSeparateOption(1, "-", "foo");

            Assert.Equal(1, option.Id);
            Assert.Equal("-", option.Prefix);
            Assert.Equal("foo", option.Name);
            Assert.Null(option.HelpText);
            Assert.Null(option.MetaVar);
            Assert.Null(option.Alias);
            Assert.Null(option.Group);
            Assert.Same(option, option.UnaliasedOption);
        }
コード例 #3
0
        public void Alias(string[] input, string spelling)
        {
            var option   = new JoinedOrSeparateOption(1, new[] { "-", "/", "--" }, "qux");
            var option2  = new JoinedOrSeparateOption(2, new[] { "-", "/", "--" }, "foo", aliasId: 1);
            var optTable = new OptTable(new[] { option, option2 });

            int idx = 0;
            var arg = option2.Accept(input, ref idx);

            Assert.NotNull(arg);
            Assert.Equal(1, arg.Option.Id);
            Assert.Equal(spelling, arg.Spelling);
            Assert.Equal("bar", arg.Value);
        }
コード例 #4
0
        public void Accept(string[] input, string value, int argCount)
        {
            var option = new JoinedOrSeparateOption(1, "-", "foo");

            int idx = 0;
            var arg = option.Accept(input, ref idx);

            Assert.Equal(argCount, idx);
            Assert.NotNull(arg);
            Assert.Same(option, arg.Option);
            Assert.Equal(0, arg.Index);
            Assert.False(arg.IsClaimed);
            Assert.Equal("-foo", arg.Spelling);
            Assert.Equal(value, arg.Value);
        }
コード例 #5
0
        public void ConstructOptional()
        {
            var option = new JoinedOrSeparateOption(
                1, "-", "foo", helpText: "help", aliasId: 2, groupId: 3,
                metaVar: "meta");

            Assert.Equal(1, option.Id);
            Assert.Equal("-", option.Prefix);
            Assert.Equal("foo", option.Name);
            Assert.Equal("help", option.HelpText);
            Assert.Equal("meta", option.MetaVar);
            Assert.Null(option.Alias);
            Assert.Null(option.Group);
            Assert.Same(option, option.UnaliasedOption);

            var option2 = new JoinedOrSeparateOption(2, "-", "bar");
            var option3 = new JoinedOrSeparateOption(3, "-", "qux");

            var optTable = new OptTable(new[] { option, option2, option3 });

            Assert.Same(option2, option.Alias);
            Assert.Same(option3, option.Group);
        }