Exemple #1
0
        public void Parse_Test()
        {
            string Argument_Destination   = "destination";
            string Argument_Source        = "source";
            string Argument_Archive       = "archive";
            string Argument_Length        = "length";
            string Argument_LastWriteTime = "lastwritetime";
            string Argument_CleanArchive  = "cleanarchive";

            Parser arg = new Parser();

            arg.AddArguments(new ValueParameter(Argument_Destination, "目标路径", true, (ShortPrefix)'d', (LongOrSplitPrefix)"dest"),
                             new ValueParameter(Argument_Source, "被比对路径", true, (ShortPrefix)'s', (LongOrSplitPrefix)"source"),
                             new DefinitionParameter(Argument_Length, "按文件长度是否一致来进行同步", (LongPrefix)"len", (ShortPrefix)'l'),
                             new DefinitionParameter(Argument_LastWriteTime, "按最后修改时间是否一致来进行同步", (LongPrefix)"time", (ShortPrefix)'t'),
                             new DefinitionParameter(Argument_CleanArchive, "是否清除存档标识", (LongPrefix)"clean", (ShortPrefix)'c'),
                             new DefinitionParameter(Argument_Archive, "按是否存档来进行同步", (LongPrefix)"archive", (ShortPrefix)'a'))
            ;
            arg.Parse(new string[] {
                "mwwtools", "io", "synch", @"/s", @"c:\a", @"/dest:c:\b", "/length", "-t"
            });

            Assert.IsTrue(arg.GetEntity <ValueParameter>(Argument_Source).Defined);
            Assert.IsFalse(arg.GetEntity <DefinitionParameter>(Argument_Archive).Defined);
            Assert.IsTrue(arg.GetEntity <DefinitionParameter>(Argument_LastWriteTime).Defined);
        }
Exemple #2
0
        public void ErrorTest()
        {
            Parser target = new Parser();
            IParameterEntity[] args = new IParameterEntity[]{
                new DefinitionParameter("char", "测试", (LongOrSplitPrefix)"char", (ShortPrefix)'c'),
                new ValueParameter("better", "好的", true, (LongOrSplitPrefix)"bet",(ShortPrefix)'b'),
                new EnumParameter<MyEnum>("em", MyEnum.B, (LongOrSplitPrefix)"enum", (ShortPrefix)'e')
            };

            target.AddArguments(args);

            target.Parse(new string[] { });
        }
Exemple #3
0
        public void ErrorTest()
        {
            Parser target = new Parser();

            IParameterEntity[] args = new IParameterEntity[] {
                new DefinitionParameter("char", "测试", (LongOrSplitPrefix)"char", (ShortPrefix)'c'),
                new ValueParameter("better", "好的", true, (LongOrSplitPrefix)"bet", (ShortPrefix)'b'),
                new EnumParameter <MyEnum>("em", MyEnum.B, (LongOrSplitPrefix)"enum", (ShortPrefix)'e')
            };

            target.AddArguments(args);

            target.Parse(new string[] { });
        }
Exemple #4
0
        public void Parse_Test1()
        {
            var args = new IParameterEntity[] {
                new DefinitionParameter("char", "测试", (LongOrSplitPrefix)"char", (ShortPrefix)'c'),
                new ValueParameter("better", "好的", true, (LongOrSplitPrefix)"bet", (ShortPrefix)'b'),
                new EnumParameter <MyEnum>("em", MyEnum.B, (LongOrSplitPrefix)"enum", (ShortPrefix)'e')
            };
            Parser target = new Parser();

            target.AddArguments(args);

            string[] argStrings = new string[] { "-char", "cvalue", "/bet:bvalue", "--enum", "c" };
            target.Parse(argStrings);
            Assert.AreEqual(false, (target.GetEntity <DefinitionParameter>("char").Defined));
            Assert.AreEqual("bvalue", (target.GetEntity <ValueParameter>("better").Value));
            Assert.AreEqual(MyEnum.C, (target.GetEntity <EnumParameter <MyEnum> >("em").Value));
        }
Exemple #5
0
        public void DefaultValue_Test()
        {
            ValueParameter av = new ValueParameter("av", "tt", true);
            ValueParameter bv = new ValueParameter("bv", "bv", "ttbv");

            Parser arg = new Parser();

            arg.AddArguments(av, bv)
            ;
            arg.Parse(new string[] {
                "mwwtools", "io", "synch", @"/a", @"tt"
            });

            Assert.IsTrue(av.Defined);
            Assert.AreEqual("tt", av.Value);
            Assert.IsTrue(bv.Defined);
            Assert.AreEqual("ttbv", bv.Value);
        }
        public void DefaultValue_Test()
        {
            ValueParameter av = new ValueParameter("av", "tt", true);
            ValueParameter bv = new ValueParameter("bv", "bv", "ttbv");

            Parser arg = new Parser();

            arg.AddArguments(av, bv)
               ;
            arg.Parse(new string[] {
                "mwwtools" ,"io" ,"synch" ,@"/a", @"tt"
            });

            Assert.IsTrue(av.Defined);
            Assert.AreEqual("tt", av.Value);
            Assert.IsTrue(bv.Defined);
            Assert.AreEqual("ttbv", bv.Value);
        }
 protected override void InitArgument(Parser parser) {
     parser.AddArguments(ArgSourceFile, ArgDictXFile);
 }
Exemple #8
0
        public void Parse_Test()
        {
            string Argument_Destination = "destination";
            string Argument_Source = "source";
            string Argument_Archive = "archive";
            string Argument_Length = "length";
            string Argument_LastWriteTime = "lastwritetime";
            string Argument_CleanArchive = "cleanarchive";

            Parser arg = new Parser();

            arg.AddArguments(new ValueParameter(Argument_Destination, "目标路径", true, (ShortPrefix)'d', (LongOrSplitPrefix)"dest"),
               new ValueParameter(Argument_Source, "被比对路径", true, (ShortPrefix)'s', (LongOrSplitPrefix)"source"),
               new DefinitionParameter(Argument_Length, "按文件长度是否一致来进行同步", (LongPrefix)"len", (ShortPrefix)'l'),
               new DefinitionParameter(Argument_LastWriteTime, "按最后修改时间是否一致来进行同步", (LongPrefix)"time", (ShortPrefix)'t'),
               new DefinitionParameter(Argument_CleanArchive, "是否清除存档标识", (LongPrefix)"clean", (ShortPrefix)'c'),
               new DefinitionParameter(Argument_Archive, "按是否存档来进行同步", (LongPrefix)"archive", (ShortPrefix)'a'))
               ;
            arg.Parse(new string[] {
                "mwwtools" ,"io" ,"synch" ,@"/s", @"c:\a" ,@"/dest:c:\b" ,"/length" ,"-t"
            });

            Assert.IsTrue(arg.GetEntity<ValueParameter>(Argument_Source).Defined);
            Assert.IsFalse(arg.GetEntity<DefinitionParameter>(Argument_Archive).Defined);
            Assert.IsTrue(arg.GetEntity<DefinitionParameter>(Argument_LastWriteTime).Defined);
        }
Exemple #9
0
        public void Parse_Test1()
        {
            var args = new IParameterEntity[]{
                new DefinitionParameter("char", "测试", (LongOrSplitPrefix)"char", (ShortPrefix)'c'),
                new ValueParameter("better", "好的", true, (LongOrSplitPrefix)"bet",(ShortPrefix)'b'),
                new EnumParameter<MyEnum>("em", MyEnum.B, (LongOrSplitPrefix)"enum", (ShortPrefix)'e')
            };
            Parser target = new Parser();
            target.AddArguments(args);

            string[] argStrings = new string[] { "-char", "cvalue", "/bet:bvalue", "--enum", "c" };
            target.Parse(argStrings);
            Assert.AreEqual(false, (target.GetEntity<DefinitionParameter>("char").Defined));
            Assert.AreEqual("bvalue", (target.GetEntity<ValueParameter>("better").Value));
            Assert.AreEqual(MyEnum.C, (target.GetEntity<EnumParameter<MyEnum>>("em").Value));
        }
 public void Set(Parser parser, PropertyInfo property)
 {
     parser.AddArguments(CreateParameter(property));
 }
 protected override void InitArgument(Parser parser)
 {
     parser.AddArguments(ArgCharacter);
 }