-
-
Notifications
You must be signed in to change notification settings - Fork 802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not able to moq setup 2 different methods with same input parameters #587
Comments
@ShashiG88, impossivle to say what's going wrong without seeing the actual test code. Could you please post a minimal & complete code example that shows how exactly you're invoking these two methods? |
I was able to resolve this .. the method which I was mocking had input parameter nullable int, but during mocking I was passing it as int. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
One of my method has 2 DB methods -
Method1(string a,int? b) and
Method2(string a, int? b)
I mocked and set up these methods -
objectMock.Setup(b => b.Method1(It.IsAny(), It.IsAny<int())).Returns(true);
objectMock.Setup(a => a.Method2(It.IsAny(), It.IsAny())).Returns(true);
and during the test always only one method is getting invoked by mock object and the 2nd method always hits DB.
And when I performed mockObject.verify(..) receiving the exception
Moq.MockException: '
Expected invocation on the mock at least once, but was never performed: a => a.Method2(It.IsAny(), It.IsAny())
The text was updated successfully, but these errors were encountered: