Search code examples
c#rhino-mocks

How do I mock an array in Rhino mocks


I am using Rhino mocks and now I need to mock an array IFindUseCase[]

var findUseCases = mocks.StrictMock<IFindUseCase[]>();

But how do I use Expect.Call?

I thought it would be this, but may be not....!

Expect.Call(() => findUseCases[0].Process(null)).Return(null);

Any ideas?


Solution

  • I don't think you want to be creating a mock array, I think you want to create an array of mocks.

    var case1 = mocks.StrictMock<IFindUseCase>();
    var findUseCases = new IFindUseCase[]
         {
             case1
         };
    

    And setup your expectation:

    case1.Expect(m => m.Process(null)).Return(null);