Class SpecimenFactory<TInput, T>
Creates a new specimen using a System.Func<T, TResult>.
Inheritance
System.Object
SpecimenFactory<TInput, T>
Implements
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: AutoFixture.Kernel
Assembly: AutoFixture.dll
Syntax
public class SpecimenFactory<TInput, T> : ISpecimenBuilder
Type Parameters
Name | Description |
---|---|
TInput | The type of the parameter provided to the Func. |
T | The type of specimen to create. |
Constructors
| Improve this Doc View SourceSpecimenFactory(Func<TInput, T>)
Initializes a new instance of the SpecimenFactory<TInput, T> class.
Declaration
public SpecimenFactory(Func<TInput, T> factory)
Parameters
Type | Name | Description |
---|---|---|
System.Func<TInput, T> | factory | The func that will create specimens. |
Remarks
The input parameter to factory
will be supplied by the
ISpecimenContext passed to the Create(Object, ISpecimenContext) method.
Properties
| Improve this Doc View SourceFactory
Gets the factory that creates specimens.
Declaration
public Func<TInput, T> Factory { get; }
Property Value
Type | Description |
---|---|
System.Func<TInput, T> |
Methods
| Improve this Doc View SourceCreate(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 specimen created by the Func contained by this instance. |
Remarks
request
is ignored. Instead, the Func contained by this instance is
used to create a specimen. The parameter for the Func is supplied by
context
.