Thursday, March 15, 2007
« NMock Trick - Setting an "out" Parameter... | Main | Blogger API Endpoint in dasBlog »

Here's another short trick for the NMock mock objects framework:

To mock an indexer use the syntax (for the getter):

Stub.On(...).Method("get_Item").Will(Return.Value(..));

And for the setter:

Stub.On(...).Method("get_Item").Will(Return.Value(..));

*Update*

Via Paul Pierce's post I found a better way:

Stub.On(...).Get[...].Will(Return.Value(..));

Bookmark and Share Friday, March 16, 2007 12:20:14 AM (Jerusalem Standard Time, UTC+02:00)  #    Comments [0]