It's possible to use myMock.Verify(m => m.f(It.IsAny<string>()), ...);
to assert that the method f(string s)
has been called at least / at most / exactly n times.
I want to do something a bit more complicated: I want to ensure that the number of calls to f(string s)
plus the number of calls to f(int i)
is equal to 3.
Is there an lightweight way to do it with Moq?
More details
Actually I can think of a way to do it: I could setup a callback that would increment a counter when each of those methods is used. However it would require more set up in the test, which could hinder it's readability. (And it would be a shame to re-implement something that could already be implemented in moq).
For instance a lightweight way to do it could be to be able to retrieve the exact number of call to my method, so that I could Assert.AreEqual
on it. But I haven't been able to find a way to do it so far.
Aucun commentaire:
Enregistrer un commentaire