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
-~----------~----~----~----~------~----~------~--~---

Reply via email to