Interface IFactoryComposer<T>
Provides statements that can be used to control how specimens are created.
Inherited Members
Namespace: AutoFixture.Dsl
Assembly: AutoFixture.dll
Syntax
public interface IFactoryComposer<T> : ISpecimenBuilder
Type Parameters
Name | Description |
---|---|
T | The type of specimen. |
Methods
| Improve this Doc View SourceFromFactory(ISpecimenBuilder)
Specifies an ISpecimenBuilder that can create specimens of the appropriate type. Mostly for advanced scenarios.
Declaration
IPostprocessComposer<T> FromFactory(ISpecimenBuilder factory)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenBuilder | factory | An ISpecimenBuilder that can create specimens of the appropriate type. |
Returns
Type | Description |
---|---|
IPostprocessComposer<T> | An IPostprocessComposer<T> 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<T> 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.
Declaration
IPostprocessComposer<T> FromFactory(Func<T> factory)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T> | factory | A function that will be used to create the object. This will often be a constructor. |
Returns
Type | Description |
---|---|
IPostprocessComposer<T> | An IPostprocessComposer<T> 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.
Declaration
IPostprocessComposer<T> FromFactory<TInput>(Func<TInput, T> factory)
Parameters
Type | Name | Description |
---|---|---|
System.Func<TInput, T> | factory | A function that will be used to create the object. This will often be a constructor
that takes a single constructor argument of type |
Returns
Type | Description |
---|---|
IPostprocessComposer<T> | An IPostprocessComposer<T> which can be used to further customize the post-processing of created specimens. |
Type Parameters
Name | Description |
---|---|
TInput | The type of input parameter to use when invoking |
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.
Declaration
IPostprocessComposer<T> FromFactory<TInput1, TInput2>(Func<TInput1, TInput2, T> factory)
Parameters
Type | Name | Description |
---|---|---|
System.Func<TInput1, TInput2, T> | factory | A function that will be used to create the object. This will often be a constructor
that takes two constructor arguments of type |
Returns
Type | Description |
---|---|
IPostprocessComposer<T> | An IPostprocessComposer<T> which can be used to further customize the post-processing of created specimens. |
Type Parameters
Name | Description |
---|---|
TInput1 | The type of the first input parameter to use when invoking |
TInput2 | The type of the second input parameter to use when invoking |
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.
Declaration
IPostprocessComposer<T> FromFactory<TInput1, TInput2, TInput3>(Func<TInput1, TInput2, TInput3, T> factory)
Parameters
Type | Name | Description |
---|---|---|
System.Func<TInput1, TInput2, TInput3, T> | factory | A function that will be used to create the object. This will often be a constructor
that takes three constructor arguments of type |
Returns
Type | Description |
---|---|
IPostprocessComposer<T> | An IPostprocessComposer<T> which can be used to further customize the post-processing of created specimens. |
Type Parameters
Name | Description |
---|---|
TInput1 | The type of the first input parameter to use when invoking |
TInput2 | The type of the second input parameter to use when invoking |
TInput3 | The type of the third input parameter to use when invoking |
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.
Declaration
IPostprocessComposer<T> FromFactory<TInput1, TInput2, TInput3, TInput4>(Func<TInput1, TInput2, TInput3, TInput4, T> factory)
Parameters
Type | Name | Description |
---|---|---|
System.Func<TInput1, TInput2, TInput3, TInput4, T> | factory | A function that will be used to create the object. This will often be a constructor
that takes three constructor arguments of type |
Returns
Type | Description |
---|---|
IPostprocessComposer<T> | An IPostprocessComposer<T> which can be used to further customize the post-processing of created specimens. |
Type Parameters
Name | Description |
---|---|
TInput1 | The type of the first input parameter to use when invoking |
TInput2 | The type of the second input parameter to use when invoking |
TInput3 | The type of the third input parameter to use when invoking |
TInput4 | The type of the fourth input parameter to use when invoking |
FromSeed(Func<T, T>)
Specifies a function that defines how to create a specimen from a seed.
Declaration
IPostprocessComposer<T> FromSeed(Func<T, T> factory)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, T> | factory | The factory used to create specimens from seeds. |
Returns
Type | Description |
---|---|
IPostprocessComposer<T> | An IPostprocessComposer<T> which can be used to further customize the post-processing of created specimens. |