Patch :-)

On Wed, Aug 12, 2009 at 3:01 AM, Ben M <[email protected]> wrote:

>
> oic.  Well would it be worthwhile to consider adding an alternative
> mode to support this or perhaps the following syntax?
>
> Expect.Call(publisher.Send(null)).Permit.Once()
>
> :)
>
> thx
> Ben
>
> On Aug 11, 4:38 pm, Ayende Rahien <[email protected]> wrote:
> > Ben,Partial work in a very specific way, if a method is not intercepted,
> it
> > is expected that the real object will get it.
> > As such, Repeat.Once() indicate how often this should be repeated, not
> that
> > only one call is permitted.
> >
> > On Wed, Aug 12, 2009 at 2:12 AM, Ben M <[email protected]> wrote:
> >
> > > yes, but doesnt this sort of defeat the purpose of using Repeat.Once
> > > ()?
> >
> > > i mean if i'm using a strict or dynamic mock then i can use Repeat.Once
> > > () in this way, why then can i not do this w/ a partial?
> >
> > > On Aug 11, 4:08 pm, Ayende Rahien <[email protected]> wrote:
> > > > 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to