views:

206

answers:

2

If have following class

public abstract class MyBaseClass : BaseClass
{
    public override string Test(string value)
    {
        return value == null ? value : base.Test(value);
    }
}

Using partial mocks I can actually test the first part of the Test-code (with value = null). Is it possible to test the fact that the call to the base class is actually done when value != null?

+2  A: 

No, you can't do that because your Test method already overrides the base method, and no ordinary dymaic mock can intercept MyBaseClass.Test's invocation of base.Test.

Here's a more detailed explanation, although it relates to Moq. However, the same argument applies to Rhino Mocks, and here's why.

Mark Seemann
A: 

Why do you even need to behavior-test this code and make your life hard with mocking? This looks like a good candidate for state-based testing: you provide input (value) and make assertions on the output of the method. A lot of times keeping it simple saves the day.

Igor Brejc