tags:

views:

24

answers:

1

I have a

I have an Interface called IFileDownloader which has a signature called DownlowadFile(string url, string fileName)

I have a class, called, StockManager which implements this method. This class has another method called DownloadFiles(string url, String[] fileNames) which calls the Interface method. How can I use Rhino Mocks to verify that the signature was called for each of the passed file in the String[] fileNames?

I have implemented it for a single file but unsure how to modify it to take an ordered list? Here is my sample code:

var stubbedFileDownloader = MockRepository.GenerateMock<IFileDownloader>();
string url = "http://abc.def.klm/download/"
string EXPECTED_FILENAME = "AVC2.xml";
stubbedFileDownloader.Stub(x => x.DownloadFile(url, EXPECTED_FILENAME)
    .Return(true);

var stockManager = new StockManager();   
stockManager.DownloadFiles(url, new string[] { "AVC2.xml" } );
stubbedFileDownloader.VerifyAllExpectations();
A: 

First, not that if you use .Stub you only specify behavior. It does not record an expectation. To record an expectation which is checked by VerifyAllExpectations, use .Expect instead of .Stub.

When you use .Expect for multiple calls with different arguments, then VerifyAllExpectations will check that they were called in the given order.

Wim Coenen