Rhino Mocks and ordered test with unordered calls
- by Shaddix
I'm using Rhino.Mocks for testing the system.
I'm going to check the order of calling .LoadConfig and .Backup methods. I need .LoadConfig to be the first.
Currently the code is like this:
var module1 = mocks.Stub<IBackupModule>();
var module2 = mocks.Stub<IBackupModule>();
module1.Expect(x => x.Name).Return("test");
module2.Expect(x => x.Name).Return("test2");
using (mocks.Ordered())
{
module1.Expect(x => x.LoadConfig(null));
module2.Expect(x => x.LoadConfig(null));
module1.Expect(x => x.Backup());
module2.Expect(x => x.Backup());
}
mocks.ReplayAll();
The problem is, that there's also a call to .Name property, and i'm not interesting when it'll be called: before .LoadConfig or after the .Backup - it just doesn't matter.
And when I run this I'm getting Exception:
Unordered method call! The expected call is: 'Ordered: { IConfigLoader.LoadConfig(null); }' but was: 'IIdentification.get_Name();'
Is there a way to deal with this?
Thanks