I use Rhino.Mocks to test the system.
I am going to check the order of calling the .LoadConfig and .Backup methods. I need .LoadConfig to be the first.
Currently, the code is as follows:
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 is also a call to the .Name property, and I'm not interested when it will be called: before .LoadConfig or after .Backup - it just doesn't matter.
And when I run this, I get an exception: Unordered method call! The expected call is: 'Ordered: { IConfigLoader.LoadConfig(null); }' but was: 'IIdentification.get_Name();'
Is there any way to handle this?
thank
source
share