Class NSubstituteBuilder
Namespace: AutoFixture.AutoNSubstitute
Assembly: AutoFixture.AutoNSubstitute.dll
Provides pre- and post-condition checks for requests for substituted instances.
public class NSubstituteBuilder : ISpecimenBuilderInheritance
Implements
ISpecimenBuilder
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Constructors
NSubstituteBuilder(ISpecimenBuilder)
Initializes a new instance of the NSubstituteBuilder class with an
ISpecimenBuilder to decorate.
public NSubstituteBuilder(ISpecimenBuilder builder)Parameters
builder ISpecimenBuilder
The builder which must build mock instances.
Remarks
builder is subsequently available through the Builder property.
See Also
NSubstituteBuilder(ISpecimenBuilder, IRequestSpecification)
Initializes a new instance of the NSubstituteBuilder class with an
ISpecimenBuilder to decorate.
public NSubstituteBuilder(ISpecimenBuilder builder, IRequestSpecification substitutionSpecification)Parameters
builder ISpecimenBuilder
The builder which must build mock instances.
substitutionSpecification IRequestSpecification
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
NSubstituteBuilder.Builder, NSubstituteBuilder.SubstitutionSpecification
Properties
Builder
Gets the decorated builder supplied through the constructor.
public ISpecimenBuilder Builder { get; }Property Value
ISpecimenBuilder
See Also
SubstitutionSpecification
Gets a specification that determines whether a substitute should be created for a given request.
public IRequestSpecification SubstitutionSpecification { get; }Property Value
IRequestSpecification
Remarks
By default it only returns true for interfaces and abstract classes, but a different specification can be supplied by using the `IRequestSpecification)` overloaded constructor that takes a specification as input. In that case, this property returns the specification supplied to the constructor.
See Also
Methods
Create(object, ISpecimenContext)
Creates a new specimen based on a request.
public object Create(object request, ISpecimenContext context)Parameters
request object
The request that describes what to create.
context ISpecimenContext
A context that can be used to create other specimens.
Returns
The requested specimen if possible; otherwise a NoSpecimen instance.
Remarks
If the request is not a 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.