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 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:
@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.
After I change the moccking parameter to same as the method it worked fine...
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: