Is that possible in RhinoMocks to create mock object without it constructor invocation?
public class A
{
public A()
{
throw new InvalidOperationException("Mock me!");
}
}
[Test]
public void TestCtors()
{
MockRepository mocks = new MockRepository();
A a = (A)mocks.StrictMock(typeof(A));
Assert.IsTrue(true, "Should be eligible");
}
I don’t think there is a way around this if you are mocking a concrete class. If you could mock in interface instead that would obviously not call a constructor. Would it be possible to re-work your code so that
Aimplements and interface which you can mock?