In my interface
public IMyListInterface : IList<IMyItem>
{
void Foo();
}
how can I easily create an example for testing classes that use IMyListInterface.
Currently I'm using GenerateStub<MyListInterface>()
and delegating the needed methods / properties to a List<IMyItem>
list but it's tedious.
Currently to get the following code under test to work
foreach (var match in matchList)
I'm doing the following in my test class
IList<IMyItem> baseList = new List<IMyItem>();
IMyListInterface matchList = MockRepository.GenerateStub<IMyListInterface>();
matchList.Stub(m => m.GetEnumerator()).Return(null).WhenCalled(i => i.ReturnValue = baseList.GetEnumerator());
Is there a better way?