NMock Trick II - Mocking Indexers
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(..));