Verify value of reference parameter with Moq

前端 未结 4 1448
南方客
南方客 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-04 00:05

    The latest version of Moq supports this scenario.

    Taken from the quickstart at http://code.google.com/p/moq/wiki/QuickStart:

    // ref arguments
    var instance = new Bar();
    // Only matches if the ref argument to the invocation is the same instance
    mock.Setup(foo => foo.Submit(ref instance)).Returns(true);
    

提交回复
热议问题