stubbing protected abstract method using Rhino Mocks

109 Views Asked by At

I have a protected abstract method. Is there anyway I can stub it? Basically the template method calls that abstract method and I need it to stub it. The method cannot be amedted to public since it will break the encapsulation. Is there anyway I can achieve it using Rhino Mocks. I'm using 3.5 verion. Thanks.

1

There are 1 best solutions below

0
On

If it is possible you could make the method internal and expose internals to the test assembly (assuming your tests are not in the same assembly as the abstract class). It would change your encapsulation model, but the method would not be overidable outside the assembly, so as assembly owner you have control over this.