/// <summary> /// Initializes a new instance of the <see cref="ParameterAttribute"/> class. /// </summary> /// <param name="parameterName">The name of the parameter to apply a known value to.</param> /// <exception cref="ArgumentNullException"><paramref name="parameterName"/> is /// <see langword="null"/>.</exception> /// <exception cref="ArgumentException"><paramref name="parameterName"/> is empty. /// </exception> public ParameterAttribute(string parameterName) { ParameterValidation.IsNotNull(parameterName, nameof(parameterName)); ParameterValidation.IsNotEmpty(parameterName, nameof(parameterName)); this.ParameterName = parameterName; }
public void IsNotEmpty_EmptyValue_ArgumentNullException() { var ex = Assert.Throws <ArgumentException>( () => ParameterValidation.IsNotEmpty(string.Empty, TestParameterName)); Assert.That(ex.ParamName, Is.EqualTo(TestParameterName)); }
/// <summary> /// Initializes a new instance of the <see cref="ParameterAttribute"/> class. /// </summary> /// <param name="parameterName">The name of the parameter to apply a known value to.</param> /// <param name="specimenValue">The value to apply to the parameter.</param> /// <exception cref="ArgumentNullException"><paramref name="parameterName"/>, or /// <paramref name="specimenValue"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentException"><paramref name="parameterName"/> is empty. /// </exception> public ParameterAttribute(string parameterName, object specimenValue) { ParameterValidation.IsNotNull(parameterName, nameof(parameterName)); ParameterValidation.IsNotEmpty(parameterName, nameof(parameterName)); ParameterValidation.IsNotNull(specimenValue, nameof(specimenValue)); this.ParameterName = parameterName; this.SpecimenValue = specimenValue; }
/// <summary> /// Removes a message from this <see cref="MessageBoard"/>. /// </summary> /// <param name="message">The message to remove from this <see cref="MessageBoard"/>. /// </param> /// <exception cref="ArgumentNullException"><paramref name="message"/> is /// <see langword="null"/>.</exception> /// <exception cref="ArgumentException"><paramref name="message"/> is empty.</exception> public void RemoveMessage(string message) { ParameterValidation.IsNotNull(message, nameof(message)); ParameterValidation.IsNotEmpty(message, nameof(message)); if (this.messages.Remove(message)) { this.Notify(); } }
/// <summary> /// Initializes a new instance of the <see cref="ParameterCustomization"/> class. /// </summary> /// <param name="declaringType">The <see cref="Type"/> of the object that contains the /// parameter to apply a known value to.</param> /// <param name="parameterName">The name of the parameter to apply a known value to.</param> /// <exception cref="ArgumentNullException"><paramref name="declaringType"/>, or /// <paramref name="parameterName"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentException"><paramref name="parameterName"/> is empty. /// </exception> public ParameterCustomization( Type declaringType, string parameterName) { ParameterValidation.IsNotNull(declaringType, nameof(declaringType)); ParameterValidation.IsNotNull(parameterName, nameof(parameterName)); ParameterValidation.IsNotEmpty(parameterName, nameof(parameterName)); this.DeclaringType = declaringType; this.ParameterName = parameterName; }
/// <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; }
/// <summary> /// Initializes a new instance of the <see cref="ParameterSpecimenBuilder"/> class. /// </summary> /// <param name="declaringType">The <see cref="Type"/> of the object that contains the /// parameter to apply a known value to.</param> /// <param name="parameterName">The name of the parameter to apply a known value to.</param> /// <exception cref="ArgumentNullException"><paramref name="declaringType"/>, or /// <paramref name="parameterName"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentException"><paramref name="parameterName"/> is empty. /// </exception> public ParameterSpecimenBuilder( Type declaringType, string parameterName) { ParameterValidation.IsNotNull(declaringType, nameof(declaringType)); ParameterValidation.IsNotNull(parameterName, nameof(parameterName)); ParameterValidation.IsNotEmpty(parameterName, nameof(parameterName)); this.DeclaringType = declaringType; this.ParameterName = parameterName; }
/// <summary> /// Resolves an instance of <see cref="ICommand"/> from the specified command group and /// <see cref="ParsedCommand"/>. /// </summary> /// <param name="commandGroup">The command group name the <see cref="ICommand"/> to resolve /// is part of.</param> /// <param name="parsedCommand">The <see cref="ParsedCommand"/> that describes the /// <see cref="ICommand"/> to resolve.</param> /// <returns>The created instance of <see cref="ICommand"/>.</returns> /// <exception cref="ArgumentNullException"><paramref name="commandGroup"/>, or /// <paramref name="parsedCommand"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentException"><paramref name="commandGroup"/> is empty. /// </exception> /// <exception cref="CommandResolveException">The arguments of /// <paramref name="parsedCommand"/> could not be resolved.</exception> /// <exception cref="CommandNotFoundException">An <see cref="ICommand"/> described by /// <paramref name="parsedCommand"/> could not be found.</exception> public ICommand Resolve( string commandGroup, ParsedCommand parsedCommand) { ParameterValidation.IsNotNull(commandGroup, nameof(commandGroup)); ParameterValidation.IsNotEmpty(commandGroup, nameof(commandGroup)); ParameterValidation.IsNotNull(parsedCommand, nameof(parsedCommand)); var commandMeta = this.ResolveCommandMeta(commandGroup, parsedCommand); MatchArguments(commandMeta, parsedCommand); return(commandMeta.Value); }
/// <summary> /// Initializes a new instance of the <see cref="ExceptionBehaviorExpectation{T}"/> class. /// </summary> /// <param name="specimenBuilder">The anonymous object creation service used to workaround /// a problem with guard clause assertions.</param> /// <param name="guardClauseExtensions">An instance of helper extensions for the /// <see cref="GuardClauseAssertion"/> class.</param> /// <param name="parameterName">The name of the parameter to apply a known value to.</param> /// <param name="values">The values to apply to the parameter to assert the guard clause. /// </param> /// <exception cref="ArgumentNullException"><paramref name="specimenBuilder"/>, /// <paramref name="guardClauseExtensions"/>, <paramref name="parameterName"/>, or /// <paramref name="values"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentException"><paramref name="parameterName"/> is empty. /// </exception> /// <exception cref="ArgumentException"><paramref name="values"/> is empty.</exception> public ExceptionBehaviorExpectation( ISpecimenBuilder specimenBuilder, IGuardClauseExtensions guardClauseExtensions, string parameterName, params object[] values) { ParameterValidation.IsNotNull(specimenBuilder, nameof(specimenBuilder)); ParameterValidation.IsNotNull(guardClauseExtensions, nameof(guardClauseExtensions)); ParameterValidation.IsNotNull(parameterName, nameof(parameterName)); ParameterValidation.IsNotEmpty(parameterName, nameof(parameterName)); ParameterValidation.IsNotNull(values, nameof(values)); if (values.Length == 0) { throw new ArgumentException("Collection must not be empty.", nameof(values)); } this.specimenBuilder = specimenBuilder; this.ParameterName = parameterName; this.Values = values; this.guardClauseExtensions = guardClauseExtensions; }
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); }
public void IsNotEmpty_NotEmptyValue_DoesNotThrow() { Assert.DoesNotThrow( () => ParameterValidation.IsNotEmpty("Not Empty.", TestParameterName)); }