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 : ISpecimenCommand

Inheritance

objectAutoPropertiesCommand

Implements

ISpecimenCommand

Inherited Members

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

Specification

Specification that filters properties and files that should be populated.

public IRequestSpecification Specification { get; }

Property Value

IRequestSpecification

Methods

Execute(object, ISpecimenContext)

Assigns anonymous values to properties and fields on a specimen.

public void Execute(object specimen, ISpecimenContext context)

Parameters

specimen object

context ISpecimenContext