I can't for the life of me find the proper syntax using the Fluent/AAA syntax in Rhino for validating order of operations.
I know how to do this with the old school record/playback syntax:
MockRepository repository = new MockRepository();
using (repository.Ordered())
{
// set some ordered expectations
}
using (repository.Playback())
{
// test
}
Can anyone tell me what the equivalent to this in AAA syntax for Rhino Mocks would be. Even better if you can point me to some documentation for this.
Try this:
Here's an example with interaction testing which is what you usually want to use ordered expectations for:
This syntax is very much Expect/Verify but as far as I know it's the only way to do it right now, and it does take advantage of some of the nice features introduced with 3.5.
tvanfosson's solution does not work for me either. I needed to verify that calls are made in particular order for 2 mocks.
According to Ayende's reply in Google Groups
Ordered()
does not work in AAA syntax.The GenerateMock static helper along with Ordered() did not work as expected for me. This is what did the trick for me (the key seems to be to explicitly create your own MockRepository instance):