I have an interface IMyInterfacethat I mock unit test with moq.
Mock<IMyInterface> firstMockedObject = new Mock<IMyInterface>();
Mock<IMyInterface> secondMockedObject = new Mock<IMyInterface>();
The device under test has a registration method that looks like this:
public void RegisterHandler(Type type, IHandler handler)
and then the descriptor method:
public void Handle(IMyInterface objectToHandle)
What I'm trying to check is that I can regiester 2 handlers for two different implementations IMyInterfaceand that the Handle method correctly selects which one to use:
UnitUnderTest.RegisterHAndler(firstMockedObject.Object.GetType(), handler1);
UnitUnderTest.RegisterHAndler(seconMockedObject.Object.GetType(), handler2);
Problem - both mock objects of the same type. Is there a way to get Moq to generate 2 layouts of the same interface as different types?
source
share