Using RhinoMocks, how do you mock or stub a concrete class without an empty constructor?
- by Mark Rogers
Mocking a concrete class with Rhino Mocks seems to work pretty easy when you have an empty constructor on a class:
public class MyClass{
public MyClass() {}
}
But if I add a constructor that takes parameters and remove the one that doesn't take parameters:
public class MyClass{
public MyClass(MyOtherClass instance) {}
}
I tend to get an exception:
System.MissingMethodException : Can't
find a constructor with matching
arguments
I've tried putting in nulls in my call to Mock or Stub, but it doesn't work.
Can I create mocks or stubs of concrete classes with Rhino Mocks, or must I always supply (implicitly or explicitly) a parameter-less constructor?