Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot mock class with constructor having array parameter using Rhino Mocks

We are not able to mock this class in RhinoMocks.

public class Service
{
    public Service(Command[] commands){}
}
public abstract class Command {}

// Code
var mock = MockRepository.GenerateMock<Service>(new Command[]{}); // or
mock = MockRepository.GenerateMock<Service>(null)

Rhino mocks fails complaining that it cannot find a constructor with matching arguments. What am I doing wrong?

Thanks,

like image 327
SharePoint Newbie Avatar asked May 18 '10 07:05

SharePoint Newbie


1 Answers

Try like this:

var mock = MockRepository.GenerateMock<Service>(
    new object[] { new Command[0] }
);
like image 102
Darin Dimitrov Avatar answered Sep 20 '22 18:09

Darin Dimitrov