public void ReferenceIsUsedForProperties()
        {
            var reference = new OptionArgument("default", false, 123);
            var alias     = new AliasArgument(reference);

            Assert.AreEqual("default", alias.DefaultValue);
            Assert.AreEqual(false, alias.IsRequired);
            Assert.AreEqual(123, alias.Position);
            Assert.AreEqual(reference.Processor, alias.Processor);
            Assert.AreEqual(reference.SupportsMultipleValues, alias.SupportsMultipleValues);
        }
Exemple #2
0
        public void CustomValidatorTest()
        {
            CommandLineArgs args   = new CommandLineArgs();
            OptionArgument  option = new OptionArgument("123", true)
            {
                Validator = v => v.Equals("test")
            };

            args.RegisterArgument("option", option);

            Assert.IsFalse(args.Validate("/option=123"));
            Assert.IsTrue(args.Validate("/option=test"));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="OptionAttribute"/> class.
 /// </summary>
 /// <param name="longName">The long name of the option. The long name may not contain ':' or '=' characters.</param>
 /// <param name="shortName">The short name of the option, if any. The short name may not be ':' or '='.</param>
 /// <param name="argument">A value indicating whether this option takes an argument.</param>
 public OptionAttribute(string longName, char shortName, OptionArgument argument = OptionArgument.Required)
 {
     this.LongName  = longName;
     this.ShortName = shortName;
     this.Argument  = argument;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="OptionAttribute"/> class.
 /// </summary>
 /// <param name="shortName">The short name of the option, if any. The short name may not be ':' or '='.</param>
 /// <param name="argument">A value indicating whether this option takes an argument.</param>
 public OptionAttribute(char shortName, OptionArgument argument = OptionArgument.Required)
 {
     this.ShortName = shortName;
     this.Argument  = argument;
 }
 /// <param name="longName">The long name of the option. The long name may not contain ':' or '=' characters.</param>
 /// <param name="argument">Whether this option takes an argument.</param>
 public OptionAttribute(string longName, OptionArgument argument = OptionArgument.Required)
 {
     LongName = longName;
     Argument = argument;
 }