Interface IFactoryComposer<T>

Namespace: AutoFixture.Dsl
Assembly: AutoFixture.dll

Provides statements that can be used to control how specimens are created.

public interface IFactoryComposer<T> : ISpecimenBuilder

Type Parameters

T

The type of specimen.

Implements

ISpecimenBuilder

Extension Methods

SpecimenFactory.Create<T>(ISpecimenBuilder), SpecimenFactory.CreateMany<T>(ISpecimenBuilder), SpecimenFactory.CreateMany<T>(ISpecimenBuilder, int), SpecimenCommand.Do<T>(ISpecimenBuilder, Action<T>), SpecimenCommand.Do<T1, T2>(ISpecimenBuilder, Action<T1, T2>), SpecimenCommand.Do<T1, T2, T3>(ISpecimenBuilder, Action<T1, T2, T3>), SpecimenCommand.Do<T1, T2, T3, T4>(ISpecimenBuilder, Action<T1, T2, T3, T4>), SpecimenQuery.Get<T, TResult>(ISpecimenBuilder, Func<T, TResult>), SpecimenQuery.Get<T1, T2, TResult>(ISpecimenBuilder, Func<T1, T2, TResult>), SpecimenQuery.Get<T1, T2, T3, TResult>(ISpecimenBuilder, Func<T1, T2, T3, TResult>), SpecimenQuery.Get<T1, T2, T3, T4, TResult>(ISpecimenBuilder, Func<T1, T2, T3, T4, TResult>), CustomizationExtensions.ToCustomization(ISpecimenBuilder)

Methods

FromFactory(ISpecimenBuilder)

Specifies an ISpecimenBuilder that can create specimens of the appropriate type. Mostly for advanced scenarios.

IPostprocessComposer<T> FromFactory(ISpecimenBuilder factory)

Parameters

factory ISpecimenBuilder

An ISpecimenBuilder that can create specimens of the appropriate type.

Returns

IPostprocessComposer<T>

An IPostprocessComposer%601 which can be used to further customize the post-processing of created specimens.

Remarks

This method is mostly intended for advanced scenarios where a more loosely coupled strategy is desired to create specimens, but the advantages of the strongly typed `IPostprocessComposer%601` are still desired for post-processing.

One possible scenario is for post-processing of interfaces or abstract types where auto-mocking is desired to create the instance. This method makes it possible to supply an auto-mocking `ISpecimenBuilder`.

factory must be able to create specimens of the requested type, or exceptions may be thrown.

FromFactory(Func<T>)

Specifies that an anonymous object should be created in a particular way; often by using a constructor.

IPostprocessComposer<T> FromFactory(Func<T> factory)

Parameters

factory Func<T>

A function that will be used to create the object. This will often be a constructor.

Returns

IPostprocessComposer<T>

An IPostprocessComposer%601 which can be used to further customize the post-processing of created specimens.

FromFactory<TInput>(Func<TInput, T>)

Specifies that a specimen should be created in a particular way, using a single input parameter for the factory.

IPostprocessComposer<T> FromFactory<TInput>(Func<TInput, T> factory)

Parameters

factory Func<TInput, T>

A function that will be used to create the object. This will often be a constructor that takes a single constructor argument of type TInput.

Returns

IPostprocessComposer<T>

An IPostprocessComposer%601 which can be used to further customize the post-processing of created specimens.

Type Parameters

TInput

The type of input parameter to use when invoking factory.

FromFactory<TInput1, TInput2>(Func<TInput1, TInput2, T>)

Specifies that a specimen should be created in a particular way, using two input parameters for the construction.

IPostprocessComposer<T> FromFactory<TInput1, TInput2>(Func<TInput1, TInput2, T> factory)

Parameters

factory Func<TInput1, TInput2, T>

A function that will be used to create the object. This will often be a constructor that takes two constructor arguments of type TInput1 and TInput2.

Returns

IPostprocessComposer<T>

An IPostprocessComposer%601 which can be used to further customize the post-processing of created specimens.

Type Parameters

TInput1

The type of the first input parameter to use when invoking factory.

TInput2

The type of the second input parameter to use when invoking factory.

FromFactory<TInput1, TInput2, TInput3>(Func<TInput1, TInput2, TInput3, T>)

Specifies that a specimen should be created in a particular way, using three input parameters for the construction.

IPostprocessComposer<T> FromFactory<TInput1, TInput2, TInput3>(Func<TInput1, TInput2, TInput3, T> factory)

Parameters

factory Func<TInput1, TInput2, TInput3, T>

A function that will be used to create the object. This will often be a constructor that takes three constructor arguments of type TInput1, TInput2 and TInput3.

Returns

IPostprocessComposer<T>

An IPostprocessComposer%601 which can be used to further customize the post-processing of created specimens.

Type Parameters

TInput1

The type of the first input parameter to use when invoking factory.

TInput2

The type of the second input parameter to use when invoking factory.

TInput3

The type of the third input parameter to use when invoking factory.

FromFactory<TInput1, TInput2, TInput3, TInput4>(Func<TInput1, TInput2, TInput3, TInput4, T>)

Specifies that a specimen should be created in a particular way, using four input parameters for the construction.

IPostprocessComposer<T> FromFactory<TInput1, TInput2, TInput3, TInput4>(Func<TInput1, TInput2, TInput3, TInput4, T> factory)

Parameters

factory Func<TInput1, TInput2, TInput3, TInput4, T>

A function that will be used to create the object. This will often be a constructor that takes three constructor arguments of type TInput1, TInput2, TInput3 and TInput4.

Returns

IPostprocessComposer<T>

An IPostprocessComposer%601 which can be used to further customize the post-processing of created specimens.

Type Parameters

TInput1

The type of the first input parameter to use when invoking factory.

TInput2

The type of the second input parameter to use when invoking factory.

TInput3

The type of the third input parameter to use when invoking factory.

TInput4

The type of the fourth input parameter to use when invoking factory.

FromSeed(Func<T, T>)

Specifies a function that defines how to create a specimen from a seed.

IPostprocessComposer<T> FromSeed(Func<T, T> factory)

Parameters

factory Func<T, T>

The factory used to create specimens from seeds.

Returns

IPostprocessComposer<T>

An IPostprocessComposer%601 which can be used to further customize the post-processing of created specimens.