Class MockVirtualMethodsCommand
Namespace: AutoFixture.AutoMoq
Assembly: AutoFixture.AutoMoq.dll
Sets up a mocked object's methods so that the return values will be retrieved from a fixture, instead of being created directly by Moq.
This will setup any virtual methods that are either non-void or have "out" parameters.
public class MockVirtualMethodsCommand : ISpecimenCommandInheritance
object ← MockVirtualMethodsCommand
Implements
ISpecimenCommand
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
This will setup any virtual methods that are either non-void or have "out" parameters. This includes:
- interface's methods/property getters;
- class's abstract/virtual/overridden/non-sealed methods/property getters.
Notes:
- Due to a limitation in Moq, methods with "ref" parameters are skipped.
- Automatic mocking of generic methods isn't feasible either - we'd have to antecipate any type parameters that this method could be called with.
- To not interfere with other post-processors in the chain we skip getters for properties that have both getters and setters.
Constructors
MockVirtualMethodsCommand()
public MockVirtualMethodsCommand()Methods
Execute(object, ISpecimenContext)
Sets up a mocked object's methods so that the return values will be retrieved from a fixture, instead of being created directly by Moq.
public void Execute(object specimen, ISpecimenContext context)Parameters
specimen object
The mock to setup.
context ISpecimenContext
The context of the mock.