Class NSubstituteBuilder
Provides pre- and post-condition checks for requests for substituted instances.
Inheritance
Implements
Inherited Members
Namespace: AutoFixture.AutoNSubstitute
Assembly: AutoFixture.AutoNSubstitute.dll
Syntax
public class NSubstituteBuilder : ISpecimenBuilder
Constructors
| Improve this Doc View SourceNSubstituteBuilder(ISpecimenBuilder)
Initializes a new instance of the NSubstituteBuilder class with an ISpecimenBuilder to decorate.
Declaration
public NSubstituteBuilder(ISpecimenBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenBuilder | builder | The builder which must build mock instances. |
Remarks
builder
is subsequently available through the Builder property.
See Also
| Improve this Doc View SourceNSubstituteBuilder(ISpecimenBuilder, IRequestSpecification)
Initializes a new instance of the NSubstituteBuilder class with an ISpecimenBuilder to decorate.
Declaration
public NSubstituteBuilder(ISpecimenBuilder builder, IRequestSpecification substitutionSpecification)
Parameters
Type | Name | Description |
---|---|---|
ISpecimenBuilder | builder | The builder which must build mock instances. |
IRequestSpecification | substitutionSpecification | A specification that determines whether a substitute should be created for a given request or not. |
Remarks
builder
is subsequently available through the Builder property.
substitutionSpecification
is subsequently available through the SubstitutionSpecification property.
See Also
Properties
| Improve this Doc View SourceBuilder
Gets the decorated builder supplied through the constructor.
Declaration
public ISpecimenBuilder Builder { get; }
Property Value
Type | Description |
---|---|
ISpecimenBuilder |
See Also
| Improve this Doc View SourceSubstitutionSpecification
Gets a specification that determines whether a substitute should be created for a given request.
Declaration
public IRequestSpecification SubstitutionSpecification { get; }
Property Value
Type | Description |
---|---|
IRequestSpecification |
Remarks
By default it only returns true for interfaces and abstract classes, but a different specification can be supplied by using the NSubstituteBuilder(ISpecimenBuilder, IRequestSpecification) overloaded constructor that takes a specification as input. In that case, this property returns the specification supplied to the constructor.
See Also
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 requested specimen if possible; otherwise a NoSpecimen instance. |
Remarks
If the request is not a System.Type or the request does not represent an interface or an abstract class, this method returns a new NoSpecimen; otherwise, it returns a substitute for the requested type.