Interface IFixture
Provides object creation services.
Inherited Members
Namespace: AutoFixture
Assembly: AutoFixture.dll
Syntax
public interface IFixture : ISpecimenBuilder
Properties
| Improve this Doc View SourceBehaviors
Gets the behaviors that are applied as Decorators around other parts of a Fixture. is invoked.
Declaration
IList<ISpecimenBuilderTransformation> Behaviors { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IList<ISpecimenBuilderTransformation> |
Customizations
Gets the customizations that intercept the request handling by the core.
Declaration
IList<ISpecimenBuilder> Customizations { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IList<ISpecimenBuilder> |
Remarks
Any ISpecimenBuilder in this list are invoked before predefined builders giving them a chance to intercept a request and resolve it.
Customize<T>(Func<ICustomizationComposer<T>, ISpecimenBuilder>) places resulting customizations in this list.
See Also
| Improve this Doc View SourceOmitAutoProperties
Gets or sets if writable properties should generally be assigned a value when generating an anonymous object.
Declaration
bool OmitAutoProperties { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
RepeatCount
Gets or sets a number that controls how many objects are created when a Fixture creates more than one anonymous objects.
Declaration
int RepeatCount { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
See Also
ResidueCollectors
Gets the residue collectors that can be used to handle requests that neither the Customizations nor the predefined builders could handle.
Declaration
IList<ISpecimenBuilder> ResidueCollectors { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IList<ISpecimenBuilder> |
Remarks
These ISpecimenBuilder instances will be invoked if no previous builder could resolve a request. This gives you the opportunity to define fallback strategies to deal with unresolved requests.
Methods
| Improve this Doc View SourceBuild<T>()
Customizes the creation algorithm for a single object, effectively turning off all Customizations on the IFixture.
Declaration
ICustomizationComposer<T> Build<T>()
Returns
Type | Description |
---|---|
ICustomizationComposer<T> | A ICustomizationComposer<T> that can be used to customize the creation algorithm before creating the object. |
Type Parameters
Name | Description |
---|---|
T | The type of object for which the algorithm should be customized. |
Remarks
The Build method kicks off a Fluent API which is usually completed by invoking Create<T>(IPostprocessComposer<T>) on the method chain.
Note that the Build method chain is best understood as a one-off Customization. It bypasses all Customizations on the Fixture instance. Instead, it allows fine-grained control when building a specific specimen. However, in most cases, adding a convention-based ICustomization is a better, more flexible option.
Customize(ICustomization)
Applies a customization.
Declaration
IFixture Customize(ICustomization customization)
Parameters
Type | Name | Description |
---|---|---|
ICustomization | customization | The customization to apply. |
Returns
Type | Description |
---|---|
IFixture | An IFixture where the customization is applied. |
Remarks
Note to implementers: the returned IFixture is expected to have
customization
applied. Whether the return value is the same instance
as the current instance, or a copy is unspecified.
Customize<T>(Func<ICustomizationComposer<T>, ISpecimenBuilder>)
Customizes the creation algorithm for all objects of a given type.
Declaration
void Customize<T>(Func<ICustomizationComposer<T>, ISpecimenBuilder> composerTransformation)
Parameters
Type | Name | Description |
---|---|---|
System.Func<ICustomizationComposer<T>, ISpecimenBuilder> | composerTransformation | A function that customizes a given ICustomizationComposer<T> and returns the modified composer. |
Type Parameters
Name | Description |
---|---|
T | The type of object to customize. |
Remarks
The resulting ISpecimenBuilder is added to Customizations.