Class AutoPropertiesCommand

Namespace: AutoFixture.Kernel
Assembly: AutoFixture.dll

A command that assigns anonymous values to all writable properties and fields of a type.

public class AutoPropertiesCommand : AutoPropertiesCommand<object>, ISpecimenCommand, ISpecifiedSpecimenCommand<object>, IRequestSpecification

Inheritance

objectAutoPropertiesCommand<object>AutoPropertiesCommand

Implements

ISpecimenCommand, ISpecifiedSpecimenCommand<object>, IRequestSpecification

Inherited Members

AutoPropertiesCommand<object>.Execute(object, ISpecimenContext), AutoPropertiesCommand<object>.IsSatisfiedBy(object), AutoPropertiesCommand<object>.GetSpecimenType(object), AutoPropertiesCommand<object>.Execute(object, ISpecimenContext), AutoPropertiesCommand<object>.Specification, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

AutoPropertiesCommand()

Initializes a new instance of the AutoPropertiesCommand class.

public AutoPropertiesCommand()

Remarks

When created without an explicit specimen type, the `AutoPropertiesCommand` will infer the specimen type from the actual specimen instance.

AutoPropertiesCommand(Type)

Initializes a new instance of the AutoPropertiesCommand class with the supplied specimen type.

public AutoPropertiesCommand(Type specimenType)

Parameters

specimenType Type

The specimen type on which properties are assigned.

AutoPropertiesCommand(IRequestSpecification)

Initializes a new instance of the AutoPropertiesCommand class with the supplied specification.

public AutoPropertiesCommand(IRequestSpecification specification)

Parameters

specification IRequestSpecification

A specification that is used as a filter to include properties or fields.

Remarks

Only properties or fields satisfied by specification will get assigned values.

AutoPropertiesCommand(Type, IRequestSpecification)

Initializes a new instance of the AutoPropertiesCommand class with the supplied specimen type and specification.

public AutoPropertiesCommand(Type specimenType, IRequestSpecification specification)

Parameters

specimenType Type

The specimen type on which properties are assigned.

specification IRequestSpecification

A specification that is used as a filter to include properties or fields.

Remarks

Only properties or fields satisfied by specification will get assigned values.

Properties

ExplicitSpecimenType

The explicitly specified Type that should be used to resolve fields and properties to populate for the specimen. <remarks>

Property will return null if no explicit specimen type was specified during the command construction. In this case command uses the runtime type of the generated specimen to resolve its fields and properties.

</remarks>
public Type ExplicitSpecimenType { get; }

Property Value

Type

Methods

GetSpecimenType(object)

Gets the type of the specimen.

protected override Type GetSpecimenType(object specimen)

Parameters

specimen object

The specimen.

Returns

Type

The type of the specimen.

Remarks

This implementation ignores specimen and returns the type parameter of `AutoPropertiesCommand%601`.