For simplicity I like to keep the AAA syntax side of things... what you 
mention looks like the Expect/Replay/Record type stuff I'd like to avoid. 
Also this blog 
post<http://lostechies.com/derickbailey/2010/05/04/rhino-mocks-recursion-and-multiple-return-values-from-stubs/>says
 that "It’s important to note that if you do not specify the number of 
times to repeat for the first stub, then the second stub will simply 
overwrite the first one", which is contrary to my experience so I was 
wondering if this was *intended* behavior, a bug, or missing functionality.

I found a more AAA way around this: using .Repeat.Any() for a subsequent 
call will override a previously stubbed return value where no repeat was 
specified. But you can only use Repeat.Any() once.

On Monday, September 24, 2012 8:47:04 PM UTC-5, Patrick Steele wrote:
>
> Rhino.Mocks allows multiple stubs to be set up on the same method (so 
> you can test what would happen if the first call returns true and the 
> second call returns false). 
>
> If you want to "reset" and clear out all previous stubs, you could: 
>
> status.GetMockRepository().BackToRecordAll(); 
> status.GetMockRepository().ReplayAll(); 
>
> That should reset everything (i.e. whatever stubs you've previously 
> set up should be cleared). 
>
> --- 
> Patrick Steele 
> http://weblogs.asp.net/psteele 
>
>
> On Mon, Sep 24, 2012 at 2:16 PM, Jeffrey Bridgman 
> <[email protected]<javascript:>> 
> wrote: 
> > The stripped down example is a bit contrived, but is there any reason I 
> > can't stub a property twice and the "last one wins"? 
> > Turning IStatus.Connected into a function produces the same result. 
> VB.Net 
> > has the same result. Tested using Rhino Mock 3.6 build 21. 
> > 
> > [TestFixture()] 
> > public class TestTests 
> > { 
> >   private IStatus _status; 
> > 
> >   [SetUp()] 
> >   public void Setup() 
> >   { 
> >     this._status = MockRepository.GenerateStub<IStatus>(); 
> >     this._status.Stub(x => x.Connected()).Return(true); 
> >     // This second stub might lie in a subclass if you're reducing setup 
> > code duplication using inheritance 
> >     this._status.Stub(x => x.Connected()).Return(false); 
> >   } 
> > 
> >   [Test()] 
> >   public void TestTheTestFramework() 
> >   { 
> >     Assert.IsFalse(this._status.Connected()); // Fails ... 
> >   } 
> > } 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Rhino.Mocks" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/rhinomocks/-/VeSM6LXIf_MJ. 
> > To post to this group, send email to 
> > [email protected]<javascript:>. 
>
> > To unsubscribe from this group, send email to 
> > [email protected] <javascript:>. 
> > For more options, visit this group at 
> > http://groups.google.com/group/rhinomocks?hl=en. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rhinomocks/-/U4vebDuhlVwJ.
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