Class MockRelay

Namespace: AutoFixture.AutoMoq
Assembly: AutoFixture.AutoMoq.dll

Relays a request for an interface or an abstract class to a request for a Mock%601 of that class.

public class MockRelay : ISpecimenBuilder

Inheritance

objectMockRelay

Implements

ISpecimenBuilder

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

MockRelay()

Initializes a new instance of the MockRelay class.

public MockRelay()

MockRelay(IRequestSpecification)

Initializes a new instance of the MockRelay class with a specification that determines whether a type should be mocked.

public MockRelay(IRequestSpecification mockableSpecification)

Parameters

mockableSpecification IRequestSpecification

A specification that determines whether a type should be mocked or not.

Properties

MockableSpecification

Gets a specification that determines whether a given request should be mocked.

public IRequestSpecification MockableSpecification { get; }

Property Value

IRequestSpecification

Remarks

This specification determines whether a given type should be relayed as a request for a mock of the same type. By default it only returns true for interfaces and abstract classes, but a different specification can be supplied by using the overloaded constructor that takes an `IRequestSpecification` 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

object

A dynamic mock instance of the requested interface or abstract class if possible; otherwise a NoSpecimen instance.