Class NoSpecimenOutputGuard
Prevents a decorated ISpecimenBuilder from returning a NoSpecimen instance.
Inheritance
Inherited Members
Namespace: AutoFixture.Kernel
Assembly: AutoFixture.dll
Syntax
public class NoSpecimenOutputGuard : ISpecimenBuilderNode, ISpecimenBuilder, IEnumerable<ISpecimenBuilder>, IEnumerable
Constructors
| Improve this Doc View SourceNoSpecimenOutputGuard(ISpecimenBuilder)
Initializes a new instance of the NoSpecimenOutputGuard class with an ISpecimenBuilder to decorate.
Declaration
public NoSpecimenOutputGuard(ISpecimenBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenBuilder | builder | The builder to decorate. |
NoSpecimenOutputGuard(ISpecimenBuilder, IRequestSpecification)
Initializes a new instance of the NoSpecimenOutputGuard class with an ISpecimenBuilder to decorate and an IRequestSpecification that is used to determine whether an exception should be thrown based on the request.
Declaration
public NoSpecimenOutputGuard(ISpecimenBuilder builder, IRequestSpecification specification)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenBuilder | builder | The builder to decorate. |
IRequestSpecification | specification | The specification. |
Properties
| Improve this Doc View SourceBuilder
Gets the decorated builder.
Declaration
public ISpecimenBuilder Builder { get; }
Property Value
Type | Description |
---|---|
ISpecimenBuilder | The ISpecimenBuilder supplied via the constructor. |
See Also
Specification
Gets the specification that is used to determine whether an exception should be thrown for a request that returns a NoSpecimen instance.
Declaration
public IRequestSpecification Specification { get; }
Property Value
Type | Description |
---|---|
IRequestSpecification | The IRequestSpecification supplied via the constructor. |
See Also
Methods
| Improve this Doc View SourceCompose(IEnumerable<ISpecimenBuilder>)
Composes the supplied builders.
Declaration
public 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 by delegating to the decorated Builder.
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 an exception is thrown or a NoSpecimen instance is returned. |
Exceptions
Type | Condition |
---|---|
ObjectCreationException | The decorated Builder returned a NoSpecimen result and
Specification returned true for
|
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 |