Search code examples
c#.netrhino-mocks

RhinoMocks Expectation Return Anything


Is there any way to setup RhinoMocks expectation without caring about return value? Something like that:

repository.Expect(r => r.Add(1)).Return(Anything)

Solution

  • Note that if you don't specify a return value the default will be returned. So null for objects, false for bool, 0 for int, etc.

    So in your case, if you are expecting one call to the method, you could write

    repository.Expect(r => r.Add(1)).Repeat.Once();