Class NullComposer<T>
Namespace: AutoFixture.Dsl
Assembly: AutoFixture.dll
An ICustomizationComposer%601 that does not customize anything, but can still
compose an ISpecimenBuilder - typically by returning the instance it is
configured to use.
public class NullComposer<T> : ICustomizationComposer<T>, IFactoryComposer<T>, IPostprocessComposer<T>, ISpecimenBuilderType Parameters
T
Inheritance
Implements
ICustomizationComposer<T>, IFactoryComposer<T>, IPostprocessComposer<T>, ISpecimenBuilder
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Extension Methods
SpecimenFactory.Create<T>(ISpecimenBuilder), SpecimenFactory.Create<T>(IPostprocessComposer<T>), SpecimenFactory.CreateMany<T>(ISpecimenBuilder), SpecimenFactory.CreateMany<T>(IPostprocessComposer<T>), SpecimenFactory.CreateMany<T>(ISpecimenBuilder, int), SpecimenFactory.CreateMany<T>(IPostprocessComposer<T>, 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)
Constructors
NullComposer()
Initializes a new instance of the NullComposer%601 class.
public NullComposer()NullComposer(ISpecimenBuilder)
Initializes a new instance of the NullComposer%601 class with an
ISpecimenBuilder that will be returned by the Compose method.
public NullComposer(ISpecimenBuilder builder)Parameters
builder ISpecimenBuilder
NullComposer(Func<ISpecimenBuilder>)
Initializes a new instance of the NullComposer%601 class with a
function used to implement the Compose method.
public NullComposer(Func<ISpecimenBuilder> factory)Parameters
factory Func<ISpecimenBuilder>
Methods
Compose()
Composes a new ISpecimenBuilder instance.
public ISpecimenBuilder Compose()Returns
Remarks
Which `ISpecimenBuilder` is returned depends on how the `NullComposer%601` instance was configured through its constructor.
Create(object, ISpecimenContext)
Creates a new specimen based on a request.
public object Create(object request, ISpecimenContext context)Parameters
request object
The request that describes what to create.
context ISpecimenContext
A context that can be used to create other specimens.
Returns
The requested specimen if possible; otherwise a NoSpecimen instance.
Remarks
The request can be any object, but will often be a
`Type` or other `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.
public IPostprocessComposer<T> Do(Action<T> action)Parameters
action Action<T>
The action to perform.
Returns
An IPostprocessComposer%601 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.
public IPostprocessComposer<T> FromFactory(ISpecimenBuilder factory)Parameters
factory ISpecimenBuilder
An ISpecimenBuilder that can create specimens of the appropriate type.
Returns
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.
public 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
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.
public 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
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.
public 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
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.
public 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
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.
public 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
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.
public IPostprocessComposer<T> FromSeed(Func<T, T> factory)Parameters
factory Func<T, T>
The factory used to create specimens from seeds.
Returns
An IPostprocessComposer%601 which can be used to further customize the
post-processing of created specimens.
OmitAutoProperties()
Disables auto-properties for a type of specimen.
public IPostprocessComposer<T> OmitAutoProperties()Returns
An IPostprocessComposer%601 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.
public IPostprocessComposer<T> With<TProperty>(Expression<Func<T, TProperty>> propertyPicker)Parameters
propertyPicker Expression<Func<T, TProperty>>
An expression that identifies the property or field that will should have a value assigned.
Returns
An IPostprocessComposer%601 which can be used to further customize the
post-processing of created specimens.
Type Parameters
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.
public IPostprocessComposer<T> With<TProperty>(Expression<Func<T, TProperty>> propertyPicker, TProperty value)Parameters
propertyPicker Expression<Func<T, TProperty>>
An expression that identifies the property or field that will have
value assigned.
value TProperty
The value to assign to the property or field identified by
propertyPicker.
Returns
An IPostprocessComposer%601 which can be used to further customize the
post-processing of created specimens.
Type Parameters
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.
public IPostprocessComposer<T> With<TProperty>(Expression<Func<T, TProperty>> propertyPicker, Func<TProperty> valueFactory)Parameters
propertyPicker Expression<Func<T, TProperty>>
An expression that identifies the property or field that will have valueFactory result assigned.
valueFactory Func<TProperty>
The factory of value to assign to the property or field identified by propertyPicker.
Returns
Type Parameters
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.
public IPostprocessComposer<T> With<TProperty, TInput>(Expression<Func<T, TProperty>> propertyPicker, Func<TInput, TProperty> valueFactory)Parameters
propertyPicker Expression<Func<T, TProperty>>
An expression that identifies the property or field that will have valueFactory result assigned.
valueFactory Func<TInput, TProperty>
The factory of value to assign to the property or field identified by propertyPicker.
Returns
Type Parameters
TProperty
TInput
With<TProperty>(Expression<Func<T, TProperty>>, ISpecimenBuilder)
Registers that a writable property or field should be assigned generated value as a part of specimen post-processing.
public IPostprocessComposer<T> With<TProperty>(Expression<Func<T, TProperty>> propertyPicker, ISpecimenBuilder builder)Parameters
propertyPicker Expression<Func<T, TProperty>>
An expression that identifies the property or field that will have builder result assigned.
builder ISpecimenBuilder
The specimen builder to assign to the property or field identified by propertyPicker.
Returns
An IPostprocessComposer%601 which can be used to further customize the
post-processing of created specimens.
Type Parameters
TProperty
WithAutoProperties()
Enables auto-properties for a type of specimen.
public IPostprocessComposer<T> WithAutoProperties()Returns
An IPostprocessComposer%601 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.
public IPostprocessComposer<T> Without<TProperty>(Expression<Func<T, TProperty>> propertyPicker)Parameters
propertyPicker Expression<Func<T, TProperty>>
An expression that identifies the property or field to be ignored.
Returns
An IPostprocessComposer%601 which can be used to further customize the
post-processing of created specimens.
Type Parameters
TProperty
The type of the property or field to ignore.