I am trying to make fun of the IMapper display IMapper :
public interface IMapper<TFoo, TBar> { TBar Map(TFoo foo); TFoo Map(TBar bar); }
In my test, I install mock mapper to wait for everyone to call (around the NHibernate update operation):
However, when the second Map call is made, the map mapper throws because it expects only one call.
Observing the variability of the display during installation at runtime, I can see how the Map(TFoo foo) overload is registered, and then see it replaced when the Map(TBar bar) overload is configured.
Is this a problem with installing Moq, or is there another syntax that I need to use in this case?
EDIT Here is the actual instance code from the test constructor:
public class TestClass { private readonly MockRepository _repository = new MockRepository(MockBehavior.Strict); public TestClass() {
EDIT 2
Here is a complete test case:
public interface IMapper<TFoo, TBar> { TFoo Map(TBar bar); TBar Map(TFoo foo); } public class Foo { public override int GetHashCode() {
If I comment on the redefinition of GetHashCode() on Foo or Bar , or both, the test case passes. Or, if I do not use Mock from Foo and Bar , the test case passes.
EDIT 3 I opened Moq Issue 347 against this problem with more detailed test cases.