Beispiel #1
0
        public void Properties()
        {
            var arg = new Arg(optTable.GetOption(1), "opt1=", 0, "value1");

            Assert.False(arg.IsClaimed);
            Assert.Equal(0, arg.Index);
            Assert.Equal("opt1=", arg.Spelling);
            Assert.Equal("value1", arg.Value);
            Assert.Equal(new[] { "value1" }, arg.Values.AsEnumerable());
        }
Beispiel #2
0
        public void GetOption()
        {
            var options = new[] {
                new TestOption(1, "opt1"),
                new TestOption(2, "opt2")
            };

            var optTable = new OptTable(options);

            Assert.Equal(options[0], optTable.GetOption(1));
            Assert.Equal(options[1], optTable.GetOption(2));
            Assert.Null(optTable.GetOption(3));
        }
Beispiel #3
0
        public static Arg MakeArg(
            this OptTable optTable, int id, string spelling, int index, string value = null)
        {
            Option option = optTable.GetOption(id);

            if (option is JoinedOption) // FIXME
            {
                value = value ?? string.Empty;
            }
            if (value != null)
            {
                return(new Arg(option, spelling, index, value));
            }
            return(new Arg(option, spelling, index));
        }
Beispiel #4
0
        public static Arg MakeArg(
            this OptTable optTable, int id, string spelling, int index, params string[] values)
        {
            values = values ?? new string[1];

            Option option = optTable.GetOption(id);

            if (option is JoinedOption) // FIXME
            {
                values[0] = values[0] ?? string.Empty;
            }
            if (values.Length > 1)
            {
                return(new Arg(option, spelling, index, values));
            }
            if (values[0] != null)
            {
                return(new Arg(option, spelling, index, values[0]));
            }
            return(new Arg(option, spelling, index));
        }
        private Arg CreateArg(OptSpecifier pos)
        {
            var option = optTable.GetOption(pos);

            return(new Arg(option, option.PrefixedName, 0));
        }
Beispiel #6
0
        public void get_Item()
        {
            var args = new[] {
                new Arg(optTable.GetOption(OptA), "-a", 0),
                new Arg(optTable.GetOption(OptB), "-b", 1),
                new Arg(optTable.GetOption(OptA), "-a", 2),
            };
            var al = CreateArgumentList(args);

            Assert.Same(args[0], al[0]);
            Assert.Same(args[1], al[1]);
            Assert.Same(args[2], al[2]);
        }