The documentation on NMock is scanty at best, non existent at worst.
Add into this mix that I self identify as a Mort. Someone who is generally more concerned about grabbing the data a customer wants and displaying it the way she wants it, so that I can pick up my pay check and go enjoy spending my money. Apparently, this combination has left me in the position of trying desperately to find example code to improve my oop skills while at the same time, educating me in exactly how weak my those skills are.
To that end here is an example of how to mock a collection of your 3rd party object (and remind me to wax lyrically about just how cool mocks are)
Mock Setup
IMock[] folderMock = new IMock[2];
IMock foldersMock;
folderMock[0] = new DynamicMock(typeof(FooFolder));
folderMock[1] = new DynamicMock(typeof(FooFolder));
foldersMock = new DynamicMock(typeof(FooFolders));
foldersMock.ExpectAndReturn("Count", 2);
Queue coll = new Queue(2);
coll.Clear();
coll.Enqueue(folderMock[0].MockInstance);
coll.Enqueue(folderMock[1].MockInstance);
foldersMock.ExpectAndReturn("GetEnumerator", coll.GetEnumerator());
Calling Code
FooFolders myFolders = GetFooFolders( “SomeString” );
if ( myFolders.Count > 0 )
foreach( FooFolder folder in myFolders )
{
// Do something with folder
}
}