Exemplo n.º 1
0
        public void Create_0()
        {
            List <Argument> args = ArgumentFactory.Create("/", "=",
                                                          new[] { "/debug=on", "house", "/filter", "document.txt", "input" });

            Assert.AreEqual(5, args.Count);

            Assert.IsTrue(args[0] is ArgumentNamed);
            Assert.AreEqual("debug", ((ArgumentNamed)args[0]).Name);
            Assert.AreEqual("on", args[0].Value);
            Assert.AreEqual(0, args[0].Index);

            Assert.IsTrue(args[1] is ArgumentPassed);
            Assert.AreEqual(0, ((ArgumentPassed)args[1]).Order);
            Assert.AreEqual("house", args[1].Value);
            Assert.AreEqual(1, args[1].Index);

            Assert.IsTrue(args[2] is ArgumentNamed);
            Assert.AreEqual("filter", ((ArgumentNamed)args[2]).Name);
            Assert.IsNull(args[2].Value);
            Assert.AreEqual(2, args[2].Index);

            Assert.IsTrue(args[3] is ArgumentPassed);
            Assert.AreEqual(1, ((ArgumentPassed)args[3]).Order);
            Assert.AreEqual("document.txt", args[3].Value);
            Assert.AreEqual(3, args[3].Index);

            Assert.IsTrue(args[4] is ArgumentPassed);
            Assert.AreEqual(2, ((ArgumentPassed)args[4]).Order);
            Assert.AreEqual("input", args[4].Value);
            Assert.AreEqual(4, args[4].Index);
        }
Exemplo n.º 2
0
        public void Create_1()
        {
            ArgumentNamed arg = ArgumentFactory.Create(2, "/", "=", "/debug=on") as ArgumentNamed;

            Assert.IsNotNull(arg);
            Assert.AreEqual("debug", arg.Name);
            Assert.AreEqual("on", arg.Value);
            Assert.AreEqual(2, arg.Index);
        }
Exemplo n.º 3
0
        /// <summary>
        /// </summary>
        /// <param name="pOptions"></param>
        /// <param name="pValidator"></param>
        /// <param name="pArgs"></param>
        /// <param name="pDescs"></param>
        /// <returns></returns>
        private static Request Create(CliOptions pOptions, iValidator pValidator, IEnumerable <string> pArgs,
                                      ICollection <Description> pDescs)
        {
            IEnumerable <Argument> arguments = ArgumentFactory.Create(pOptions.Prefix, pOptions.EqualChar, pArgs);
            Request request = new Request(arguments, pDescs);

            if (pValidator != null)
            {
                request.Valid = pValidator.Validate(pDescs.ToList(), request);
            }
            return(request);
        }
Exemplo n.º 4
0
 public void Create_2()
 {
     Argument arg = ArgumentFactory.Create(2, "/", "=", "/=on");
 }