Verify value of reference parameter with Moq

前端 未结 4 1434
南方客
南方客 2021-01-03 23:30

I just switched to Moq and have run into a problem. I\'m testing a method that creates a new instance of a business object, sets the properties of the object from user inpu

4条回答
  •  失恋的感觉
    2021-01-03 23:49

    Unfortunately, I am not sure that this is possible without direct support from Moq. The problem is that Lambda expressions do not support ref or out.

    "A lambda expression cannot directly capture a ref or out parameter from an enclosing method. "

    http://msdn.microsoft.com/en-us/library/bb397687.aspx

    I can't even get an example like yours to work. Adding ref to the setup fails to compile.

    You might want to check out the Moq discussions for more http://groups.google.com/group/moqdisc

    Good luck.

提交回复
热议问题