Make a second call: Expect.Call(_publisher.Send(null)) > .IgnoreArguments() > .Return(true) > .Repeat.*Never()*;
On Wed, Aug 12, 2009 at 2:05 AM, Ben M <[email protected]> wrote: > > well, i made a discovery on this. If you only tell it to repeat once, > then the other calls will subsequently go to the actual real method as > opposed to the mock version of the method. So I've done a work around > using Expect.Call().Do() and keeping my own count of the number of > calls, but this is something that in my opinion I should be able to do > in Rhino mocks. Does anyone know how to do this without having to do > it myself? Ayende? > > On Aug 11, 2:48 pm, Ben M <[email protected]> wrote: > > I have a partial mock on a class I'll call 'Publisher' > > > > the publisher has a method called 'Publish' that in turn calls a > > virtual method called Send as follows: > > > > public class Publisher > > { > > public bool Publish(MyList list) > > { > > string msg = _msgBuilder.BuildFrom(list); > > bool success = Send(msg); > > > > return success; > > } > > > > public virtual bool Send(string msg) > > { > > /// snip > > return true; > > } > > > > } > > > > my unit test then does the following: > > [SetUp] > > public void Setup() > > { > > > > _mocks = new MockRepository(); > > > > _publisher = _mocks.PartialMock<Publisher>(); > > > > } > > > > [Test] > > public void OnlyCallSendOnceForEmptyLists() > > { > > Expect.Call(_publisher.Send(null)) > > .IgnoreArguments() > > .Return(true) > > .Repeat.Once; > > > > _mocks.ReplayAll(); > > > > _publisher.Publish(new MyList()); > > _publisher.Publish(new MyList()); > > > > _mocks.VerifyAll(); > > > > } > > > > I would expect this test to fail as it should be expecting no more > > than 1 call, but the test is passing, and stepping thru the debugger I > > can see it IS in fact making 2 calls, yet the test still passes. What > > am I doing wrong that causes this test to give me a false positive? > > > > thanks in advance > > Ben > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/RhinoMocks?hl=en -~----------~----~----~----~------~----~------~--~---
