Rhino Mocks recently switched to AAA syntax (Arrange, Act, Assert) from Record/Replay. It’s fairly easy to make the switch. I did run into a problem checking the order of calls made on my mocked objects though. It seemed my expected calls never got wired up at all. I found you ¿shouldn’t really? mock things into an instance of a MockRepository but rather call it statically. As soon as I switched everything worked. You can get a reference to the MockRepository by called GetMockRepository on any of your mocked objects.
using (_mockObject1.GetMockRepository().Ordered())
using (_mockObject2.GetMockRepository().Ordered())
{
_mockObject1.Expect(o => o.Func1(Arg<SomeType>.Is.TypeOf));
_mockObject2.Expect(o => o.Func2());
_mockObject1.Expect(o => o.Func3()).Return(true);
_mockObject1.Expect(o => o.Func4()).Return(true);
_mockObject2.Expect(o => o.Func5());
_mockObject1.Expect(o => o.Func6());
_mockObject1.Expect(o => o.Func7()).Return(true);
}
Leave a comment