Moq how to correctly mock read-only properties or set only properies

Posted by Chris Marisic on Stack Overflow See other posts from Stack Overflow or by Chris Marisic
Published on 2010-05-17T22:20:44Z Indexed on 2010/05/17 23:00 UTC
Read the original article Hit count: 3163

Filed under:
|
|

What is the correct way for dealing with interfaces the expose only read-only or set-only properties with Moq? Previously I've added the other accessor but this has bleed into my domain too far with random throw new NotImplementedException() statements throughout.

I just want to do something simple like

mock.VerifySet(view => view.SetOnlyValue, Times.Never());

But this is a compile error of The property 'SetOnlyValue' has no getter

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET