Class NullComposer<T>
An ICustomizationComposer<T> that does not customize anything, but can still compose an ISpecimenBuilder - typically by returning the instance it is configured to use.
Inheritance
Inherited Members
Namespace: AutoFixture.Dsl
Assembly: AutoFixture.dll
Syntax
public class NullComposer<T> : ICustomizationComposer<T>, IFactoryComposer<T>, IPostprocessComposer<T>, ISpecimenBuilder
Type Parameters
Name | Description |
---|---|
T |
Constructors
| Improve this Doc View SourceNullComposer()
Initializes a new instance of the NullComposer<T> class.
Declaration
public NullComposer()
NullComposer(ISpecimenBuilder)
Initializes a new instance of the NullComposer<T> class with an ISpecimenBuilder that will be returned by the Compose() method.
Declaration
public NullComposer(ISpecimenBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenBuilder | builder |
NullComposer(Func<ISpecimenBuilder>)
Initializes a new instance of the NullComposer<T> class with a function used to implement the Compose() method.
Declaration
public NullComposer(Func<ISpecimenBuilder> factory)
Parameters
Type | Name | Description |
---|---|---|
System.Func<ISpecimenBuilder> | factory |
Methods
| Improve this Doc View SourceCompose()
Composes a new ISpecimenBuilder instance.
Declaration
public ISpecimenBuilder Compose()
Returns
Type | Description |
---|---|
ISpecimenBuilder |
Remarks
Which ISpecimenBuilder is returned depends on how the NullComposer<T> instance was configured through its constructor.
Create(Object, ISpecimenContext)
Creates a new specimen based on a request.
Declaration
public object Create(object request, ISpecimenContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Object | request | The request that describes what to create. |
ISpecimenContext | context | A context that can be used to create other specimens. |
Returns
Type | Description |
---|---|
System.Object | The requested specimen if possible; otherwise a NoSpecimen instance. |
Remarks
The request
can be any object, but will often be a
System.Type or other System.Reflection.MemberInfo instances.
Note to implementers: Implementations are expected to return a NoSpecimen instance if they can't satisfy the request.
Do(Action<T>)
Performs the specified action on a specimen.
Declaration
public IPostprocessComposer<T> Do(Action<T> action)
Parameters
Type | Name | Description |
---|---|---|
System.Action<T> | action | The action to perform. |
Returns
Type | Description |
---|---|
IPostprocessComposer<T> | An IPostprocessComposer<T> which can be used to further customize the post-processing of created specimens. |
FromFactory(ISpecimenBuilder)
Specifies an ISpecimenBuilder that can create specimens of the appropriate type. Mostly for advanced scenarios.
Declaration
public 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
public 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
public 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
public 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
public 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
public 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
public 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. |
OmitAutoProperties()
Disables auto-properties for a type of specimen.
Declaration
public IPostprocessComposer<T> OmitAutoProperties()
Returns
Type | Description |
---|---|
IPostprocessComposer<T> | An IPostprocessComposer<T> which can be used to further customize the post-processing of created specimens. |
With<TProperty>(Expression<Func<T, TProperty>>)
Registers that a writable property or field should be assigned an anonymous value as part of specimen post-processing.
Declaration
public IPostprocessComposer<T> With<TProperty>(Expression<Func<T, TProperty>> propertyPicker)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<T, TProperty>> | propertyPicker | An expression that identifies the property or field that will should have a value assigned. |
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 |
---|---|
TProperty | The type of the property of field. |
With<TProperty>(Expression<Func<T, TProperty>>, TProperty)
Registers that a writable property or field should be assigned a specific value as part of specimen post-processing.
Declaration
public IPostprocessComposer<T> With<TProperty>(Expression<Func<T, TProperty>> propertyPicker, TProperty value)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<T, TProperty>> | propertyPicker | An expression that identifies the property or field that will have
|
TProperty | value | The value to assign to the property or field identified by
|
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 |
---|---|
TProperty | The type of the property of field. |
With<TProperty>(Expression<Func<T, TProperty>>, Func<TProperty>)
Registers that a writable property or field should be assigned generated value as a part of specimen post-processing.
Declaration
public IPostprocessComposer<T> With<TProperty>(Expression<Func<T, TProperty>> propertyPicker, Func<TProperty> valueFactory)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<T, TProperty>> | propertyPicker | An expression that identifies the property or field that will have |
System.Func<TProperty> | valueFactory | The factory of value to assign to the property or field identified by |
Returns
Type | Description |
---|---|
IPostprocessComposer<T> |
Type Parameters
Name | Description |
---|---|
TProperty |
With<TProperty, TInput>(Expression<Func<T, TProperty>>, Func<TInput, TProperty>)
Registers that a writable property or field should be assigned generated value as a part of specimen post-processing.
Declaration
public IPostprocessComposer<T> With<TProperty, TInput>(Expression<Func<T, TProperty>> propertyPicker, Func<TInput, TProperty> valueFactory)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<T, TProperty>> | propertyPicker | An expression that identifies the property or field that will have |
System.Func<TInput, TProperty> | valueFactory | The factory of value to assign to the property or field identified by |
Returns
Type | Description |
---|---|
IPostprocessComposer<T> |
Type Parameters
Name | Description |
---|---|
TProperty | |
TInput |
WithAutoProperties()
Enables auto-properties for a type of specimen.
Declaration
public IPostprocessComposer<T> WithAutoProperties()
Returns
Type | Description |
---|---|
IPostprocessComposer<T> | An IPostprocessComposer<T> which can be used to further customize the post-processing of created specimens. |
Without<TProperty>(Expression<Func<T, TProperty>>)
Registers that a writable property should not be assigned any automatic value as part of specimen post-processing.
Declaration
public IPostprocessComposer<T> Without<TProperty>(Expression<Func<T, TProperty>> propertyPicker)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<T, TProperty>> | propertyPicker | An expression that identifies the property or field to be ignored. |
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 |
---|---|
TProperty | The type of the property or field to ignore. |