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
Could you please let me know if it's a bug in Moq and I need to wait for the fix or it's a wrong use from my side?
TL;DR: It's not a bug in Moq, but a functional change nonetheless. Moq likely won't go back to the old behavior, so I recommend you update your test code.
The change was introduced by #904 (as mentioned briefly in the changelog). Moq has always matched generic arguments using assignment compatibility, so it shouldn't be surprising that Execute<object>(...) will also match an invocation of Execute<ExecuteResult>(...) since ExecuteResult is assignment-compatible with object.
The surprising part is rather that what made your second Verify work previously: the fact that Moq also included the return type as part of a method signature, and return types had to match precisely. (Therefore, because typeof(ExecuteResult) != typeof(object) the 2nd verify didn't match the first invocation.) This is not how the most common .NET languages (C#, VB.NET) work: there, the return type isn't considered part of a method's signature and doesn't influence method resolution. Moq now works in a manner that's more consistent with these languages.
Hi,
I have a set of unit tests which start failing after upgrade from Moq 4.12.0 to 4.13.0 version.
The code which illustrates the issue:
In version 4.13.0
Finds 2 executions for the line above.
Could you please let me know if it's a bug in Moq and I need to wait for the fix or it's a wrong use from my side?
Thanks.
The text was updated successfully, but these errors were encountered: