I am stubbing the return value of a method using rhino mocks. However, I want to return the same dummy value for any argument that is passed in.
How do I do this without pre-registering every input to return the same output?
I am stubbing the return value of a method using rhino mocks. However, I want to return the same dummy value for any argument that is passed in.
How do I do this without pre-registering every input to return the same output?
You can use IgnoreArguments()
constraint as shown below:
mockedInstance.Expect(instance => instance.MethodCall(null))
.IgnoreArguments()
.Return(preDefinedValue)
.Repeat()
.Any();
Also by specifying Repeat().Any()
preDefinedValue
will be returned for each call of a method.
See Rhino Mocks wiki for more examples.