You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to setup a method which accepts a parameter of an interface type. To make it clear suppose that I am mocking the following IFoo interface and its DoSomething method accept parameter of IBar interface:
When calling DoSomething method of the moq object with null argument it works correctly and returns 10 as it was set up but when call it with a new instance of Bar it doesn't go into the Returns part.
moqObject.Object.DoSomething(null);//this returns 10 and works as expected
moqObject.Object.DoSomething(new Bar());//this doesn't enter the Rerturns part of the moqObject
But if I cast the Bar object into IBar it works correctly
moqObject.Object.DoSomething((IBar)new Bar());//this returns 10 as well
Anything wrong with my mocking object setup? or this behavior is by design?
The text was updated successfully, but these errors were encountered:
I am trying to setup a method which accepts a parameter of an interface type. To make it clear suppose that I am mocking the following IFoo interface and its DoSomething method accept parameter of IBar interface:
Then setting up the IFoo mocking object as:
When calling DoSomething method of the moq object with null argument it works correctly and returns 10 as it was set up but when call it with a new instance of Bar it doesn't go into the Returns part.
But if I cast the Bar object into IBar it works correctly
Anything wrong with my mocking object setup? or this behavior is by design?
The text was updated successfully, but these errors were encountered: