Class RecursionGuard
Base class for recursion handling. Tracks requests and reacts when a recursion point in the specimen creation process is detected.
Inheritance
Inherited Members
Namespace: AutoFixture.Kernel
Assembly: AutoFixture.dll
Syntax
public class RecursionGuard : ISpecimenBuilderNode, ISpecimenBuilder, IEnumerable<ISpecimenBuilder>, IEnumerable
Constructors
| Improve this Doc View SourceRecursionGuard(ISpecimenBuilder)
Initializes a new instance of the RecursionGuard class.
Declaration
[Obsolete("This constructor overload is obsolete and will be removed in a future version of AutoFixture. Please use RecursionGuard(ISpecimenBuilder, IRecursionHandler) instead.", true)]
public RecursionGuard(ISpecimenBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenBuilder | builder |
RecursionGuard(ISpecimenBuilder, IRecursionHandler)
Initializes a new instance of the RecursionGuard class.
Declaration
public RecursionGuard(ISpecimenBuilder builder, IRecursionHandler recursionHandler)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenBuilder | builder | |
IRecursionHandler | recursionHandler |
RecursionGuard(ISpecimenBuilder, IRecursionHandler, IEqualityComparer)
Initializes a new instance of the RecursionGuard class.
Declaration
[Obsolete("This constructor overload is obsolete and will be removed in a future version of AutoFixture. Please use RecursionGuard(ISpecimenBuilder, IRecursionHandler, IEqualityComparer, int) instead.", true)]
public RecursionGuard(ISpecimenBuilder builder, IRecursionHandler recursionHandler, IEqualityComparer comparer)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenBuilder | builder | |
IRecursionHandler | recursionHandler | |
System.Collections.IEqualityComparer | comparer |
RecursionGuard(ISpecimenBuilder, IRecursionHandler, IEqualityComparer, Int32)
Initializes a new instance of the RecursionGuard class.
Declaration
public RecursionGuard(ISpecimenBuilder builder, IRecursionHandler recursionHandler, IEqualityComparer comparer, int recursionDepth)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenBuilder | builder | |
IRecursionHandler | recursionHandler | |
System.Collections.IEqualityComparer | comparer | |
System.Int32 | recursionDepth |
RecursionGuard(ISpecimenBuilder, IRecursionHandler, Int32)
Initializes a new instance of the RecursionGuard class.
Declaration
public RecursionGuard(ISpecimenBuilder builder, IRecursionHandler recursionHandler, int recursionDepth)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenBuilder | builder | |
IRecursionHandler | recursionHandler | |
System.Int32 | recursionDepth |
RecursionGuard(ISpecimenBuilder, IEqualityComparer)
Initializes a new instance of the RecursionGuard class.
Declaration
[Obsolete("This constructor overload is obsolete and will be removed in a future version of AutoFixture. Please use RecursionGuard(ISpecimenBuilder, IRecursionHandler, IEqualityComparer, int) instead.", true)]
public RecursionGuard(ISpecimenBuilder builder, IEqualityComparer comparer)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenBuilder | builder | |
System.Collections.IEqualityComparer | comparer |
Properties
| Improve this Doc View SourceBuilder
Gets the decorated builder supplied via the constructor.
Declaration
public ISpecimenBuilder Builder { get; }
Property Value
Type | Description |
---|---|
ISpecimenBuilder |
Comparer
Gets the comparer supplied via the constructor.
Declaration
public IEqualityComparer Comparer { get; }
Property Value
Type | Description |
---|---|
System.Collections.IEqualityComparer |
RecordedRequests
Gets the recorded requests so far.
Declaration
protected IEnumerable RecordedRequests { get; }
Property Value
Type | Description |
---|---|
System.Collections.IEnumerable |
RecursionDepth
The recursion depth at which the request will be treated as a recursive request.
Declaration
public int RecursionDepth { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
RecursionHandler
Gets the recursion handler originally supplied as a constructor argument.
Declaration
public IRecursionHandler RecursionHandler { get; }
Property Value
Type | Description |
---|---|
IRecursionHandler |
Methods
| Improve this Doc View SourceCompose(IEnumerable<ISpecimenBuilder>)
Composes the supplied builders.
Declaration
public virtual ISpecimenBuilderNode Compose(IEnumerable<ISpecimenBuilder> builders)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<ISpecimenBuilder> | builders | The builders to compose. |
Returns
Type | Description |
---|---|
ISpecimenBuilderNode | A ISpecimenBuilderNode instance. |
Remarks
Note to implementers:
The intent of this method is to compose the supplied
builders
into a new instance of the type
implementing ISpecimenBuilderNode. Thus, the
concrete return type is expected to the same type as the type
implementing the method. However, it is not considered a failure to
deviate from this idiom - it would just not be a mainstream
implementation.
The returned instance is normally expected to contain the builders supplied as an argument, but again this is not strictly required. The implementation may decide to filter the sequence or add to it during composition.
Create(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 requested specimen if possible; otherwise a NoSpecimen instance. |
Remarks
The request
can be any object, but will often be a
System.Type or other System.Reflection.MemberInfo instances.
Note to implementers: Implementations are expected to return a NoSpecimen instance if they can't satisfy the request.
GetEnumerator()
Declaration
public virtual IEnumerator<ISpecimenBuilder> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<ISpecimenBuilder> |
HandleRecursiveRequest(Object)
Handles a request that would cause recursion.
Declaration
[Obsolete("This method will be removed in a future version of AutoFixture. Use IRecursionHandler.HandleRecursiveRequest instead.", true)]
public virtual object HandleRecursiveRequest(object request)
Parameters
Type | Name | Description |
---|---|---|
System.Object | request |
Returns
Type | Description |
---|---|
System.Object |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |