Example #1
0
        public void IsFalse_TrueValue_ArgumentException()
        {
            var ex = Assert.Throws <ArgumentException>(
                () => ParameterValidation.IsFalse(true, "Message", TestParameterName));

            Assert.That(ex.ParamName, Is.EqualTo(TestParameterName));
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExampleAttribute"/> class.
        /// </summary>
        /// <param name="name">the name of an <see cref="IExample"/> specified by this
        /// <see cref="ExampleAttribute"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="name"/> is
        /// <see langword="null"/>.</exception>
        /// <exception cref="ArgumentException"><paramref name="name"/> is empty.</exception>
        public ExampleAttribute(string name)
        {
            ParameterValidation.IsNotNull(name, nameof(name));
            ParameterValidation.IsNotEmpty(name, nameof(name));
            ParameterValidation.IsFalse(
                name.Contains(" "),
                "Value cannot contain spaces.",
                nameof(name));

            this.Name = name;
        }
        public CommandParameterAttribute(
            int index,
            string name,
            Type resourceType,
            string helpTextResourceName)
        {
            ParameterValidation.IsGreaterThanOrEqualTo(index, 0, nameof(index));
            ParameterValidation.IsNotNull(name, nameof(name));
            ParameterValidation.IsNotEmpty(name, nameof(name));
            ParameterValidation.IsFalse(
                name.Contains(" "),
                "Value cannot contain spaces.",
                nameof(name));
            ParameterValidation.IsNotNull(resourceType, nameof(resourceType));
            ParameterValidation.IsNotNull(helpTextResourceName, nameof(helpTextResourceName));
            ParameterValidation.IsNotEmpty(helpTextResourceName, nameof(helpTextResourceName));

            this.Index    = index;
            this.Name     = name;
            this.HelpText =
                ResourceTypeResolver.ResolveResource <string>(resourceType, helpTextResourceName);
        }
        public CommandAttribute(
            string group,
            string name,
            Type resourceType,
            string helpTextResourceName)
        {
            ParameterValidation.IsNotNull(group, nameof(group));
            ParameterValidation.IsNotEmpty(group, nameof(group));
            ParameterValidation.IsNotNull(name, nameof(name));
            ParameterValidation.IsNotEmpty(name, nameof(name));
            ParameterValidation.IsFalse(
                name.Contains(" "),
                "Value cannot contain spaces.",
                nameof(name));
            ParameterValidation.IsNotNull(resourceType, nameof(resourceType));
            ParameterValidation.IsNotNull(helpTextResourceName, nameof(helpTextResourceName));
            ParameterValidation.IsNotEmpty(helpTextResourceName, nameof(helpTextResourceName));

            this.Group    = group;
            this.Name     = name;
            this.HelpText =
                ResourceTypeResolver.ResolveResource <string>(resourceType, helpTextResourceName);
        }
Example #5
0
 public void IsFalse_FalseValue_DoesNotThrow()
 {
     Assert.DoesNotThrow(
         () => ParameterValidation.IsFalse(false, "Message", TestParameterName));
 }