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've set up a mock when upon receiving a specific value of a property should return a value.
The test went as expected (objects with the specific valued property received the expected value, all others got null).
Issue is that the Verify isn't working as expected:
The tested object property value was changed thoughout the test. I expected the verify to count calls with specific value. It only counted the total number of calls made to the function with the object with any value!
Snippet: m.Setup(s => s.SomeFunction(It.Is<T>(t => t.SomeProperty.Equals("SomeValue")))).Returns("ExpectedValue");
... Call function that uses m
.... m.Verify(s => s.SomeFunction(It.Is<T>(t => t.SomeProperty.Equals("SomeValue"))), Times.Exactly(2));
The output of test:
Expected invocation on the mock exactly 2 times, but was 4 times: s => s.SomeFunction(It.Is<T>(t => t.SomeProperty.Equals("SomeValue")))
The mock was indeed called 4 times during the test, 2 out of them was with the "SomeValue" in t.SomeProperty (validated in debug)
Performed invocations:
Mock<m:1> (s):
m.SomeFunction(T)
m.SomeFunction(T)
m.SomeFunction(T)
m.SomeFunction(T)
The text was updated successfully, but these errors were encountered:
I've set up a mock when upon receiving a specific value of a property should return a value.
The test went as expected (objects with the specific valued property received the expected value, all others got null).
Issue is that the Verify isn't working as expected:
The tested object property value was changed thoughout the test. I expected the verify to count calls with specific value. It only counted the total number of calls made to the function with the object with any value!
Snippet:
m.Setup(s => s.SomeFunction(It.Is<T>(t => t.SomeProperty.Equals("SomeValue")))).Returns("ExpectedValue");
...
Call function that uses m
....
m.Verify(s => s.SomeFunction(It.Is<T>(t => t.SomeProperty.Equals("SomeValue"))), Times.Exactly(2));
The mock was indeed called 4 times during the test, 2 out of them was with the "SomeValue" in t.SomeProperty (validated in debug)
The text was updated successfully, but these errors were encountered: