Esempio n. 1
0
        public void TestEnumValues()
        {
            CommandLineEnumArgument enumArg;

            enumArg = new CommandLineEnumArgument(false, typeof(TestOption));
            PrivateInvoke.InvokeNonPublicMethod(enumArg, "SetStringValue", "yes");
            Assert.That((TestOption)enumArg.Value, Is.EqualTo(TestOption.yes));

            enumArg = new CommandLineEnumArgument(false, typeof(IncrementalTestOptions));
            PrivateInvoke.InvokeNonPublicMethod(enumArg, "SetStringValue", "no");
            Assert.That((IncrementalTestOptions)enumArg.Value, Is.EqualTo(IncrementalTestOptions.no));
        }
Esempio n. 2
0
 public void TestEnumInvalid()
 {
     try
     {
         CommandLineEnumArgument enumArg = new CommandLineEnumArgument(false, typeof(IncrementalTestOptions));
         PrivateInvoke.InvokeNonPublicMethod(enumArg, "SetStringValue", "invalidvalue");
     }
     catch (InvalidCommandLineArgumentValueException e)
     {
         Assert.That(e.Message.IndexOf("Use one of") >= 0, Is.True);
         throw e;
     }
 }
Esempio n. 3
0
        private CommandLineParser CreateParser(
            out CommandLineStringArgument argSourceDir,
            out CommandLineStringArgument argDestinationDir,
            out CommandLineFlagArgument argCopyBinary,
            out CommandLineEnumArgument argEnumOption)
        {
            CommandLineParser parser = new CommandLineParser();

            argSourceDir             = new CommandLineStringArgument(true);
            argSourceDir.Placeholder = "source-directory";
            argSourceDir.Description = "Directory to copy from";
            parser.Arguments.Add(argSourceDir);

            argDestinationDir             = new CommandLineStringArgument(true);
            argDestinationDir.Placeholder = "destination-directory";
            argDestinationDir.Description = "This is the directory to copy to. This is the directory to copy to. This is the directory to copy to. This is the directory to copy to. This is the directory to copy to. This is the directory to copy to. This is the directory to copy to. This is the directory to copy to.";
            parser.Arguments.Add(argDestinationDir);

            argCopyBinary             = new CommandLineFlagArgument("b", true);
            argCopyBinary.Description = "binary copy on (+, default) or off (-)";
            parser.Arguments.Add(argCopyBinary);

            argEnumOption             = new CommandLineEnumArgument("rep", true, typeof(TestOption));
            argEnumOption.Description = "replace target";
            parser.Arguments.Add(argEnumOption);

            CommandLineModeArgument modeGroup = new CommandLineModeArgument(true, typeof(TestMode));

            foreach (CommandLineModeFlagArgument flag in modeGroup.Parts)
            {
                parser.Arguments.Add(flag);
            }
            parser.Arguments.Add(modeGroup);

            return(parser);
        }