moq SetupSet is obsolete. In place of what?

Posted by jkohlhepp on Stack Overflow See other posts from Stack Overflow or by jkohlhepp
Published on 2010-06-01T13:53:14Z Indexed on 2010/06/10 1:52 UTC
Read the original article Hit count: 836

Filed under:
|

Let's say I want to use moq to create a callback on a setter to store the set property in my own field for later use. (Contrived example - but it gets to the point of the question.) I could do something like this:

myMock.SetupSet(x => x.MyProperty).Callback(value => myLocalVariable = value);

And that works just fine. However, SetupSet is obsolete according to Intellisense. But it doesn't say what should be used as an alternative. I know that moq provides SetupProperty which will autowire the property with a backing field. But that is not what I'm looking for. I want to capture the set value into my own variable. How should I do this using non-obsolete methods?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about moq