示例#1
0
        public void IsVerbalParameter_ArgumentProcessorSettingWithAttribute_ResultAsExpected(Type type, Boolean expected)
        {
            ParameterObjectAttribute attribute = null;

            if (type == typeof(SwitchParameterAttribute))
            {
                attribute = new SwitchParameterAttribute();
            }
            else if (type == typeof(OptionParameterAttribute))
            {
                attribute = new OptionParameterAttribute();
            }
            else if (type == typeof(VerbalParameterAttribute))
            {
                attribute = new VerbalParameterAttribute();
            }
            else if (type == typeof(UnsupportedParameterAttribute))
            {
                attribute = new UnsupportedParameterAttribute();
            }

            ArgumentProcessorSetting setting = new ArgumentProcessorSetting(new TestPropertyInfo(typeof(Object)), attribute);

            Assert.That(setting.IsVerbalParameter(), Is.EqualTo(expected));
        }
示例#2
0
        public void DefaultValue_HasChanged_HasDefaultValueIsTrue()
        {
            OptionParameterAttribute attribute = new OptionParameterAttribute()
            {
                DefaultValue = null
            };

            Assert.That(attribute.HasDefaultValue, Is.True);
        }
示例#3
0
        public void Delimiter_SetProperty_ResultIsEqual(String actual, String expected)
        {
            OptionParameterAttribute attribute = new OptionParameterAttribute()
            {
                Delimiter = actual
            };

            Assert.That(attribute.Delimiter, Is.EqualTo(expected));
        }
示例#4
0
        public void Separator_SetProperty_ResultIsEqual(Char actual, Char expected)
        {
            OptionParameterAttribute attribute = new OptionParameterAttribute()
            {
                Separator = actual
            };

            Assert.That(attribute.Separator, Is.EqualTo(expected));
        }
示例#5
0
        public void OptionParameter_Construction_ResultAsExpected()
        {
            OptionParameterAttribute attribute = new OptionParameterAttribute();

            Assert.That(attribute.Separator, Is.EqualTo(ParameterSeparators.DefaultSeparator));
            Assert.That(attribute.Delimiter, Is.EqualTo(ArgumentDelimiters.DefaultDelimiter));
            Assert.That(attribute.DefaultValue, Is.Null);
            Assert.That(attribute.HasDefaultValue, Is.False);
        }
        private static string GetArgumentName(OptionParameterAttribute optionParameter)
        {
            var argName = optionParameter.ShortName != null
                ? $"-{optionParameter.ShortName} "
                : string.Empty;

            if (!string.IsNullOrEmpty(optionParameter.LongName))
            {
                argName += $"--{optionParameter.LongName} ";
            }

            if (!string.IsNullOrEmpty(optionParameter.Name))
            {
                argName += $"<{optionParameter.Name.ToUpper()}>";
            }

            return(argName.Trim());
        }
 public OptionParameterProperty(PropertyInfo propertyInfo, OptionParameterAttribute optionParameterAttribute)
     : base(propertyInfo, optionParameterAttribute)
 {
     _optionParameterAttribute = optionParameterAttribute;
 }
示例#8
0
        public void DefaultValue_NotChanged_HasDefaultValueIsFalse()
        {
            OptionParameterAttribute attribute = new OptionParameterAttribute();

            Assert.That(attribute.HasDefaultValue, Is.False);
        }
示例#9
0
        public void Separator_SetProperty_ThrowsException(Char actual)
        {
            OptionParameterAttribute attribute = new OptionParameterAttribute();

            Assert.That(() => { attribute.Separator = actual; }, Throws.InstanceOf <OptionAttributeException>());
        }