Class SubstituteRelay
Namespace: AutoFixture.AutoNSubstitute
Assembly: AutoFixture.AutoNSubstitute.dll
Relays a request for an interface or an abstract class to a request for a substitute of that type.
public class SubstituteRelay : ISpecimenBuilderInheritance
Implements
ISpecimenBuilder
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
This class serves as a residue collector, catching unanswered requests for an instance of an abstract type and converting them to requests for a substitute of that type, dynamically generated by NSubstitute.
Constructors
SubstituteRelay(IRequestSpecification)
Creates a new instance of SubstituteRelay.
public SubstituteRelay(IRequestSpecification specification)Parameters
specification IRequestSpecification
Specification to test whether request should be relayed.
SubstituteRelay()
Creates a new instance of SubstituteRelay.
public SubstituteRelay()Properties
Specification
Specification used to check whether a type request should be redirected to a substitute request.
public IRequestSpecification Specification { get; }Property Value
IRequestSpecification
Methods
Create(object, ISpecimenContext)
Creates a substitute when request is an abstract type.
public object Create(object request, ISpecimenContext context)Parameters
request object
context ISpecimenContext
Returns
Exceptions
An attempt to resolve a substitute from the context returned an object that was not
created by NSubstitute.