How to Use Rhino Mocks/Out and Ref Parameters

From Wikibooks, open books for an open world
< How to Use Rhino Mocks
Jump to: navigation, search

25% developed  as of 12/7/2006 (12/7/2006) Both out and ref parameters are supported.

At the end of the Expect statement, add .OutRef(outOrRefParam0, outOrRefParam1,...) as shown below.

int theRef = 42;
int theOut = 0;
Expect.Call(obj.MyMethod(ref theRef, 0, out theOut)).Return(True).OutRef(13, 666);

Or, if you are using lambda-style expectations:

obj.Expect(x => x.MyMethod(ref theRef, 0, out theOut)).Return(True).OutRef(13, 666);

The variables/objects in OutRef() have the same order as for the method call, ignoring any parameters that are not out or ref.

Personal tools
Namespaces
Variants
Actions
Navigation
Community
Toolbox
Sister projects
Print/export