Class BindingCommand<T, TProperty>
Namespace: AutoFixture.Kernel
Assembly: AutoFixture.dll
Encapsulates a command that binds a property or a field to a value.
public class BindingCommand<T, TProperty> : ISpecimenCommand, ISpecifiedSpecimenCommand<T>, IRequestSpecificationType Parameters
T
The type of the specimen on which the property or value will be set.
TProperty
The type of property or field.
Inheritance
object ← BindingCommand<T, TProperty>
Implements
ISpecimenCommand, ISpecifiedSpecimenCommand<T>, IRequestSpecification
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Constructors
BindingCommand(Expression<Func<T, TProperty>>)
Initializes a new instance of the BindingCommand%602 class with
the supplied property picker expression.
public BindingCommand(Expression<Func<T, TProperty>> propertyPicker)Parameters
propertyPicker Expression<Func<T, TProperty>>
An expression that identifies a property or field.
Remarks
This constructor implies that an anonymous value will be assigned to the property or
field identified by propertyPicker.
BindingCommand(Expression<Func<T, TProperty>>, TProperty)
Initializes a new instance of the BindingCommand%602 class with
the supplied property picker expression and the value to be assigned to that property
or field.
public BindingCommand(Expression<Func<T, TProperty>> propertyPicker, TProperty propertyValue)Parameters
propertyPicker Expression<Func<T, TProperty>>
An expression that identifies a property or field.
propertyValue TProperty
The value to assign to the property or field identified by
propertyPicker.
BindingCommand(Expression<Func<T, TProperty>>, Func<ISpecimenContext, TProperty>)
Initializes a new instance of the BindingCommand%602 class with
the supplied property picker expression and a function that creates a value to be
assigned to that property or field.
public BindingCommand(Expression<Func<T, TProperty>> propertyPicker, Func<ISpecimenContext, TProperty> valueCreator)Parameters
propertyPicker Expression<Func<T, TProperty>>
An expression that identifies a property or field.
valueCreator Func<ISpecimenContext, TProperty>
A function that creates a value that will be assigned to the property or field
identified by propertyPicker.
Properties
Member
Gets the member identified by the expression supplied through the constructor.
public MemberInfo Member { get; }Property Value
ValueCreator
Gets the function that creates a value to be assigned to the property or field
identified by Member.
public Func<ISpecimenContext, TProperty> ValueCreator { get; }Property Value
Func<ISpecimenContext, TProperty>
Methods
Execute(T, ISpecimenContext)
Executes the command on the supplied specimen by assigning the property of field the correct value.
[Obsolete("This method is no longer used and will be removed in future versions. Please use the Execute(object, ISpecimenContext) overload instead.")]
public void Execute(T specimen, ISpecimenContext context)Parameters
specimen T
A specimen that should have its property or field assigned.
context ISpecimenContext
An ISpecimenContext which can supply an anonymous value for the
property or field.
Remarks
This method assigns a value to the property or field identified by the expression
supplied to the class' constructor. If no value (or creator) was supplied to the
constructor, context will be used to create the value.
Execute(object, ISpecimenContext)
Executes the command on the supplied specimen by assigning the property of field the correct value.
public void Execute(object specimen, ISpecimenContext context)Parameters
specimen object
context ISpecimenContext
Remarks
This method assigns a value to the property or field identified by
the expression supplied to the class' constructor. If no value (or
creator) was supplied to the constructor,
context will be used to create the value.
IsSatisfiedBy(object)
Evaluates whether a request matches the property or field affected by this command.
[Obsolete("This method is no longer used and will be removed in future versions. Please use this.Member property for specification instead.")]
public bool IsSatisfiedBy(object request)Parameters
request object
The specimen request.
Returns
true if request is a PropertyInfo
or FieldInfo that identifies the property or field affected by this
BindingCommand%602; otherwise, false.