I have a Moq DbSet that has been working until recently, however since the last update of dependencies it keeps throwing a NotImplementedException
on IQue
Chances are that you have been using version 4.7.58 of Moq. That particular version was affected by a regression that would have triggered such a NotImplementedException
. That regression has been fixed in version 4.7.63, so I suggest you update your Moq package reference to version 4.7.63 or newer to resolve this issue.
The fact that your code would have worked in Moq versions before 4.7.58 was due to a "feature" which unfortunately caused a lot more problems than it solved. For this reason, that feature was reverted.
Moq has been brought back to its original behaviour, where, in this particular scenario, you need to set up the various interface members via mock.As<TInterface>
before the call to mock.Object
. (Usually, in Moq, it's perfectly fine to perform more set ups even after retrieving the mock object; this scenario is a notable exception. Hopefully this can be fixed in a future version of Moq.)
Rolling back Castle.Core to 4.0.0 and Moq to the latest version supporting 4.0.0 solved the issue. I'm still wondering if there is something I've missed that would fix this problem in the new version.