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
Moq.MockException:
Expected invocation on the mock exactly 5 times, but was 4 times: x => x.UploadFile(It.IsAny<File>())
No setups configured.
I reinforce that this error is intermittent, sometimes it succeeds... I get that this has relation with the parallel execution of the code, but there is a reliable way of fixing this?
I looked around in the internet but all the scenarios seem to be slightly different from mine.
Thanks in advance,
The text was updated successfully, but these errors were encountered:
@lucaslra - Could you please post a minimally complete, self-contained, and executable code example that demonstrates this problem? (Perhaps not on every single run as this appears to be a threading issue, but it should be able to trigger the error every now and then.) From the little bit of code you've posted, it is hard to tell how exactly your real code looks. (For example, you have something called fileProcessor you use in the parallel loop, but you verify against mockedFileProcessor. It's these small details suggesting that one isn't getting the full picture here.)
P.S.: Could you please also state what version of Moq you're using? If you're not using the current version (4.10.0 at this time of writing), please make sure to update, re-run your code, and see if the problem persists.
Hi @stakx
I spent sometime trying to do what you've asked, but I really cannot create an isolated scenario that can reproduce the problem, which is pretty weird.
I guess it says that this is something on my setup.
Hi,
I have a simple code that is called exactly 5 times through the use of Parallel.ForEach:
The method works exactly as expected, but I am facing a problem with my Moq verification of the call count.
I have this verification:
But intermittently I get this errror:
I reinforce that this error is intermittent, sometimes it succeeds... I get that this has relation with the parallel execution of the code, but there is a reliable way of fixing this?
I looked around in the internet but all the scenarios seem to be slightly different from mine.
Thanks in advance,
The text was updated successfully, but these errors were encountered: