Class DisposableTracker
Tracks all disposable specimens created by a decorated ISpecimenBuilder to be able to dispose them when signalled.
Inheritance
Implements
Inherited Members
Namespace: AutoFixture.Kernel
Assembly: AutoFixture.dll
Syntax
public class DisposableTracker : ISpecimenBuilderNode, ISpecimenBuilder, IEnumerable<ISpecimenBuilder>, IEnumerable, IDisposable
Remarks
The DisposableTracker examines all specimens created by a decorated ISpecimenBuilder. All specimens that implement System.IDisposable are tracked so that they can be deterministically disposed. This happens when Dispose() is invoked on the instance.
Constructors
| Improve this Doc View SourceDisposableTracker(ISpecimenBuilder)
Initializes a new instance of the DisposableTracker class.
Declaration
public DisposableTracker(ISpecimenBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenBuilder | builder | The decorated builder. |
Remarks
After initialization, builder
is available through the
Builder property.
Properties
| Improve this Doc View SourceBuilder
Gets the decorated builder.
Declaration
public ISpecimenBuilder Builder { get; }
Property Value
Type | Description |
---|---|
ISpecimenBuilder |
Remarks
This property exposes the decorated builder originally supplied to the constructor.
See Also
| Improve this Doc View SourceDisposables
Gets the disposable specimens currently tracked by this instance.
Declaration
public IEnumerable<IDisposable> Disposables { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.IDisposable> |
Remarks
Items are added to this list by the Create(Object, ISpecimenContext) method.
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 new ISpecimenBuilderNode instance containing
|
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 specimen created by the decorated builder. |
Remarks
This method delegates creation of specimens to the decorated Builder. However, before specimens are returned they are examined and tracked in the Disposables list if they implement System.IDisposable. They can subsequently be disposed by invoking the Dispose() method on the instance.
Dispose()
Disposes all items in the Disposables list and removes them from the list.
Declaration
public void Dispose()
Dispose(Boolean)
Disposes all items in the Disposables list and removes them from the list.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | true to release both managed and unmanaged resources; false to release only unmanaged resources. |
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<ISpecimenBuilder> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<ISpecimenBuilder> | A System.Collections.Generic.IEnumerator<T> that can be used to iterate through the collection. |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |