コード例 #1
0
        public void ParseCommandline_ValidInput()
        {
            //string command = "cmd -v --version -s OLD --length=20 -- -my-file your-file";
            string command = "cmd -v  -s OLD --length=20 -- -my-file your-file";

            var expected_plainArgs = new List <string>()
            {
                "OLD", "-my-file", "your-file"
            };
            ParseResult expected = new ParseResult(db);

            foreach (var arg in expected_plainArgs)
            {
                expected.AddPlainArgument(arg);
            }
            expected.CommandName = "cmd";
            expected.AddParsedOption(new OptionParsed("v", null, true, null));
            //.AddParsedOption(new OptionParsed("version", null, false, null));
            expected.AddParsedOption(new OptionParsed("s", null, true, null));
            expected.AddParsedOption(new OptionParsed("length", "20", false, new IntegerParser()));

            ParseResult result = Parser.ParseCommandLine(command, db);

            Assert.AreEqual(expected.CommandName, result.CommandName);
            CollectionAssert.AreEqual(expected_plainArgs, result.PlainArguments.ToList());
            CollectionAssert.AreEqual(expected.ParsedOptions.ToList(), result.ParsedOptions.ToList());
            Assert.AreEqual(expected, result);
        }