Class SpecimenFactory
Creates anonymous variables from ISpecimenContext or ISpecimenBuilder instances.
Inheritance
Inherited Members
Namespace: AutoFixture
Assembly: AutoFixture.dll
Syntax
public static class SpecimenFactory
Methods
| Improve this Doc View SourceCreate<T>(IPostprocessComposer<T>)
Creates an anonymous variable of the requested type.
Declaration
public static T Create<T>(this IPostprocessComposer<T> composer)
Parameters
Type | Name | Description |
---|---|---|
IPostprocessComposer<T> | composer | The composer used to resolve the type request. |
Returns
Type | Description |
---|---|
T | An anonymous object of type |
Type Parameters
Name | Description |
---|---|
T | The type of object to create. |
Remarks
The only purpose of this explicit overload is to support type inferencing.
Create<T>(ISpecimenBuilder)
Creates an anonymous variable of the requested type.
Declaration
public static T Create<T>(this ISpecimenBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenBuilder | builder | The builder used to resolve the type request. |
Returns
Type | Description |
---|---|
T | An anonymous object of type |
Type Parameters
Name | Description |
---|---|
T | The type of object to create. |
Create<T>(ISpecimenContext)
Creates an anonymous variable of the requested type.
Declaration
public static T Create<T>(this ISpecimenContext context)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenContext | context | The context used to resolve the type request. |
Returns
Type | Description |
---|---|
T | An anonymous object of type |
Type Parameters
Name | Description |
---|---|
T | The type of object to create. |
CreateAnonymous<T>(IPostprocessComposer<T>)
Creates an anonymous variable of the requested type.
Declaration
[Obsolete("Please move over to using Create<T>() as this method will be removed in the next release", true)]
public static T CreateAnonymous<T>(this IPostprocessComposer<T> composer)
Parameters
Type | Name | Description |
---|---|---|
IPostprocessComposer<T> | composer | The composer used to resolve the type request. |
Returns
Type | Description |
---|---|
T | An anonymous object of type |
Type Parameters
Name | Description |
---|---|
T | The type of object to create. |
Remarks
Obsolete: "Please move over to using Create<T>(ISpecimenContext) as this method will be removed in the next release.
CreateAnonymous<T>(IFixture)
Creates an anonymous variable of the requested type.
Declaration
[Obsolete("For compatibility to AutoFixture version 2. This method will be removed, please move to using Create<T>()", true)]
public static T CreateAnonymous<T>(this IFixture fixture)
Parameters
Type | Name | Description |
---|---|---|
IFixture | fixture | The fixture used to resolve the type request. |
Returns
Type | Description |
---|---|
T | An anonymous object of type |
Type Parameters
Name | Description |
---|---|
T | The type of object to create. |
CreateAnonymous<T>(ISpecimenContext)
Creates an anonymous variable of the requested type.
Declaration
[Obsolete("Please move over to using Create<T>() as this method will be removed in the next release", true)]
public static T CreateAnonymous<T>(this ISpecimenContext context)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenContext | context | The context used to resolve the type request. |
Returns
Type | Description |
---|---|
T | An anonymous object of type |
Type Parameters
Name | Description |
---|---|
T | The type of object to create. |
Remarks
Obsolete: Please move over to using Create<T>(ISpecimenContext) as this method will be removed in the next release.
CreateMany<T>(IPostprocessComposer<T>)
Creates many anonymous objects.
Declaration
public static IEnumerable<T> CreateMany<T>(this IPostprocessComposer<T> composer)
Parameters
Type | Name | Description |
---|---|---|
IPostprocessComposer<T> | composer | The composer used to resolve the type request. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | A sequence of anonymous object of type |
Type Parameters
Name | Description |
---|---|
T | The type of objects to create. |
Remarks
The CreateMany implementation always returns a new instance of System.Collections.Generic.IEnumerable<T>. Even if IEnumerable<T> is Frozen by the Freeze<T>(IFixture) method or explicitly assigned with the Inject<T>(IFixture, T) method, the CreateMany method returns a new, independent instance of IEnumerable<T>.
However, you can change this behavior, for example by applying the MapCreateManyToEnumerable customization.
The only purpose of this explicit overload is to support type inferencing.
CreateMany<T>(IPostprocessComposer<T>, Int32)
Creates many anonymous objects.
Declaration
public static IEnumerable<T> CreateMany<T>(this IPostprocessComposer<T> composer, int count)
Parameters
Type | Name | Description |
---|---|---|
IPostprocessComposer<T> | composer | The composer used to resolve the type request. |
System.Int32 | count | The number of objects to create. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | A sequence of anonymous objects of type |
Type Parameters
Name | Description |
---|---|
T | The type of objects to create. |
Remarks
The CreateMany implementation always returns a new instance of System.Collections.Generic.IEnumerable<T>. Even if IEnumerable<T> is Frozen by the Freeze<T>(IFixture) method or explicitly assigned with the Inject<T>(IFixture, T) method, the CreateMany method returns a new, independent instance of IEnumerable<T>.
However, you can change this behavior, for example by applying the MapCreateManyToEnumerable customization.
The only purpose of this explicit overload is to support type inferencing.
CreateMany<T>(ISpecimenBuilder)
Creates many anonymous objects.
Declaration
public static IEnumerable<T> CreateMany<T>(this ISpecimenBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenBuilder | builder | The builder used to resolve the type request. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | A sequence of anonymous object of type |
Type Parameters
Name | Description |
---|---|
T | The type of objects to create. |
Remarks
The CreateMany implementation always returns a new instance of System.Collections.Generic.IEnumerable<T>. Even if IEnumerable<T> is Frozen by the Freeze<T>(IFixture) method or explicitly assigned with the Inject<T>(IFixture, T) method, the CreateMany method returns a new, independent instance of IEnumerable<T>.
However, you can change this behavior, for example by applying the MapCreateManyToEnumerable customization.
CreateMany<T>(ISpecimenBuilder, Int32)
Creates many anonymous objects.
Declaration
public static IEnumerable<T> CreateMany<T>(this ISpecimenBuilder builder, int count)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenBuilder | builder | The builder used to resolve the type request. |
System.Int32 | count | The number of objects to create. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | A sequence of anonymous objects of type |
Type Parameters
Name | Description |
---|---|
T | The type of objects to create. |
Remarks
The CreateMany implementation always returns a new instance of System.Collections.Generic.IEnumerable<T>. Even if IEnumerable<T> is Frozen by the Freeze<T>(IFixture) method or explicitly assigned with the Inject<T>(IFixture, T) method, the CreateMany method returns a new, independent instance of IEnumerable<T>.
However, you can change this behavior, for example by applying the MapCreateManyToEnumerable customization.
CreateMany<T>(ISpecimenContext)
Creates many anonymous objects.
Declaration
public static IEnumerable<T> CreateMany<T>(this ISpecimenContext context)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenContext | context | The context used to resolve the type request. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | A sequence of anonymous object of type |
Type Parameters
Name | Description |
---|---|
T | The type of objects to create. |
Remarks
The CreateMany implementation always returns a new instance of System.Collections.Generic.IEnumerable<T>. Even if IEnumerable<T> is Frozen by the Freeze<T>(IFixture) method or explicitly assigned with the Inject<T>(IFixture, T) method, the CreateMany method returns a new, independent instance of IEnumerable<T>.
However, you can change this behavior, for example by applying the MapCreateManyToEnumerable customization.
CreateMany<T>(ISpecimenContext, Int32)
Creates many anonymous objects.
Declaration
public static IEnumerable<T> CreateMany<T>(this ISpecimenContext context, int count)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenContext | context | The context used to resolve the type request. |
System.Int32 | count | The number of objects to create. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | A sequence of anonymous objects of type |
Type Parameters
Name | Description |
---|---|
T | The type of objects to create. |
Remarks
The CreateMany implementation always returns a new instance of System.Collections.Generic.IEnumerable<T>. Even if IEnumerable<T> is Frozen by the Freeze<T>(IFixture) method or explicitly assigned with the Inject<T>(IFixture, T) method, the CreateMany method returns a new, independent instance of IEnumerable<T>.
However, you can change this behavior, for example by applying the MapCreateManyToEnumerable customization.