Class SpecimenFactory
Namespace: AutoFixture
Assembly: AutoFixture.dll
Creates anonymous variables from ISpecimenContext or
ISpecimenBuilder instances.
public static class SpecimenFactoryInheritance
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Methods
Create<T>(ISpecimenContext)
Creates an anonymous variable of the requested type.
public static T Create<T>(this ISpecimenContext context)Parameters
context ISpecimenContext
The context used to resolve the type request.
Returns
T
An anonymous object of type T.
Type Parameters
T
The type of object to create.
Create<T>(ISpecimenBuilder)
Creates an anonymous variable of the requested type.
public static T Create<T>(this ISpecimenBuilder builder)Parameters
builder ISpecimenBuilder
The builder used to resolve the type request.
Returns
T
An anonymous object of type T.
Type Parameters
T
The type of object to create.
Create<T>(IPostprocessComposer<T>)
Creates an anonymous variable of the requested type.
public static T Create<T>(this IPostprocessComposer<T> composer)Parameters
composer IPostprocessComposer<T>
The composer used to resolve the type request.
Returns
T
An anonymous object of type T.
Type Parameters
T
The type of object to create.
Remarks
The only purpose of this explicit overload is to support type inferencing.
CreateMany<T>(ISpecimenBuilder)
Creates many anonymous objects.
public static IEnumerable<T> CreateMany<T>(this ISpecimenBuilder builder)Parameters
builder ISpecimenBuilder
The builder used to resolve the type request.
Returns
IEnumerable<T>
A sequence of anonymous object of type T.
Type Parameters
T
The type of objects to create.
Remarks
The CreateMany implementation always returns a new instance of `IEnumerable%601`. Even if IEnumerable<T> is Frozen by the `IFixture)` method or explicitly assigned with the `IFixture%2c%60%600)` method, the CreateMany method returns a new, independent instance of IEnumerable<T>.
CreateMany<T>(ISpecimenContext)
Creates many anonymous objects.
public static IEnumerable<T> CreateMany<T>(this ISpecimenContext context)Parameters
context ISpecimenContext
The context used to resolve the type request.
Returns
IEnumerable<T>
A sequence of anonymous object of type T.
Type Parameters
T
The type of objects to create.
Remarks
The CreateMany implementation always returns a new instance of `IEnumerable%601`. Even if IEnumerable<T> is Frozen by the `IFixture)` method or explicitly assigned with the `IFixture%2c%60%600)` method, the CreateMany method returns a new, independent instance of IEnumerable<T>.
CreateMany<T>(IPostprocessComposer<T>)
Creates many anonymous objects.
public static IEnumerable<T> CreateMany<T>(this IPostprocessComposer<T> composer)Parameters
composer IPostprocessComposer<T>
The composer used to resolve the type request.
Returns
IEnumerable<T>
A sequence of anonymous object of type T.
Type Parameters
T
The type of objects to create.
Remarks
The CreateMany implementation always returns a new instance of `IEnumerable%601`. Even if IEnumerable<T> is Frozen by the `IFixture)` method or explicitly assigned with the `IFixture%2c%60%600)` method, the CreateMany method returns a new, independent instance of IEnumerable<T>.
The only purpose of this explicit overload is to support type inferencing.
CreateMany<T>(ISpecimenBuilder, int)
Creates many anonymous objects.
public static IEnumerable<T> CreateMany<T>(this ISpecimenBuilder builder, int count)Parameters
builder ISpecimenBuilder
The builder used to resolve the type request.
count int
The number of objects to create.
Returns
IEnumerable<T>
A sequence of anonymous objects of type T.
Type Parameters
T
The type of objects to create.
Remarks
The CreateMany implementation always returns a new instance of `IEnumerable%601`. Even if IEnumerable<T> is Frozen by the `IFixture)` method or explicitly assigned with the `IFixture%2c%60%600)` method, the CreateMany method returns a new, independent instance of IEnumerable<T>.
CreateMany<T>(ISpecimenContext, int)
Creates many anonymous objects.
public static IEnumerable<T> CreateMany<T>(this ISpecimenContext context, int count)Parameters
context ISpecimenContext
The context used to resolve the type request.
count int
The number of objects to create.
Returns
IEnumerable<T>
A sequence of anonymous objects of type T.
Type Parameters
T
The type of objects to create.
Remarks
The CreateMany implementation always returns a new instance of `IEnumerable%601`. Even if IEnumerable<T> is Frozen by the `IFixture)` method or explicitly assigned with the `IFixture%2c%60%600)` method, the CreateMany method returns a new, independent instance of IEnumerable<T>.
CreateMany<T>(IPostprocessComposer<T>, int)
Creates many anonymous objects.
public static IEnumerable<T> CreateMany<T>(this IPostprocessComposer<T> composer, int count)Parameters
composer IPostprocessComposer<T>
The composer used to resolve the type request.
count int
The number of objects to create.
Returns
IEnumerable<T>
A sequence of anonymous objects of type T.
Type Parameters
T
The type of objects to create.
Remarks
The CreateMany implementation always returns a new instance of `IEnumerable%601`. Even if IEnumerable<T> is Frozen by the `IFixture)` method or explicitly assigned with the `IFixture%2c%60%600)` method, the CreateMany method returns a new, independent instance of IEnumerable<T>.
The only purpose of this explicit overload is to support type inferencing.