Thursday, March 15, 2007
« SSL in ASP.NET - Part II | Main | NMock Trick II - Mocking Indexers »

If you are using the NMock mock objects framework, you are probably familiar with the following syntax:

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

This will cause your mock object to return a specific value from some invoked method.

Now, for something less not documented:

To mock a method that sets value of an out parameter, use:

Stub.On(...).Method(...).Will(new SetNamedParameterAction([parameter name], [value]));

You can also use the SetIndexedParameterAction class.

This is not in the documentation, so using Reflector on the NMock2.dll helped find this.

Bookmark and Share Thursday, March 15, 2007 8:09:03 PM (Jerusalem Standard Time, UTC+02:00)  #    Comments [4]