-
-
Notifications
You must be signed in to change notification settings - Fork 794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
After updating moq from 4.10.1 to 4.11, mocking nhibernate session throws a System.NullReferenceException. #955
Comments
... and what would "doesn't work" mean exactly? Sorry, your report doesn't make it clear enough what exactly the problem is. Also, please test with the latest version of Moq, which at this time is 4.13.1. |
I am revising the report but couldn't delete it, give me a while for analyzing. |
Hi, I edited the description and attached a sample solution. |
Same error for latest version of Moq. |
Thanks for the repro, @ronenfe. This does look like a regression. Seems like quoted expressions might no longer be treated correctly in all cases. I'll take a closer look soon. |
@ronenfe, not a regression, after all! Starting with Moq 4.11.0, matching of multi-part expressions such as your I'll need to check whether it makes sense to evaluate captured variables prior to comparing the expression trees; if yes, your use case can likely be fixed; otherwise, I'll close this issue. |
Thanks stakx, is it possible to overcome this with the current version by changing the usage? or I need to wait for next release? |
Yes, although the resulting code will be less semantically correct than what you have now. You simply need to make sure that you pass the same (as in |
I added the expression to the Item class as a property but I also had to extract the itemId to a property as I can't create an expression without having an id variable when creating it.
|
There you go @ronenfe—starting with the next version of Moq (4.14.0), your scenario should once again work like it used to. |
4.11 and above:
getting: System.NullReferenceException: 'Object reference not set to an instance of an object.'
4.10.1 and beyond:
works.
Attached is a sample solution. See exception when running the test. Downgrade to 4.10.1 and see error is gone.
UnitTestProject2.zip
The text was updated successfully, but these errors were encountered: