Just 2 cents worth as I didn't really look into the source code so
forgive me if all I'm talking is crap.
I assume we internally record each call so we can assert later. If we
keep an atomic running number within each mock instance, and record it
with the each call. We can probably say:
mockView.AssertWasCalled(x=>x.ShowInWorkspace("MyWorkspace")).Before(x=>...);
Cheers,
Kenneth
On Tue, Jun 23, 2009 at 1:54 PM, Ayende Rahien<[email protected]> wrote:
> You cannot use Ordered with AAA, that was judged to be rare enough and the
> complexity of providing this feature high enough to not do it.
>
> On Tue, Jun 23, 2009 at 1:02 PM, Alex McMahon <[email protected]> wrote:
>>
>> I've found doing ordered expectations to be a bit of a pain since
>> Rhino Mocks 3.5 introduced AAA syntax, it seems to be one of the few
>> areas where you have to drop back to using the old record/replay
>> syntax, and it's making my test fixtures awfully complicated and
>> fragile.
>>
>> So other than trying to find a nice way to do it in RhinoMocks itself
>> I've got a workaround that I've been using, and I wondered what others
>> thought of it.
>>
>> [TestMethod()]
>> public void ViewTitleSetBeforeShownInWorkspace()
>> {
>> //arrange
>> var mockView=MockRepository.GenerateMock<IView>();
>> bool viewTitleSet=false;
>> mockView.Stub(x=>x.Title=Arg<string>.Is.Anything)
>> .WhenCalled(a=>{viewTitleSet=true});
>> mockView.Stub(x=>x.ShowInWorkspace("MyWorkspace"))
>> .WhenCalled(a=>{Assert.IsTrue(viewTitleSet, "View title should
>> have been set first");});
>>
>> //act
>> var target=new Presenter(mockView);
>> target.Initialize();
>>
>> //assert
>> mockView.AssertWasCalled(x=>x.ShowInWorkspace("MyWorkspace"));
>> }
>>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---