Reputation: 322
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?
Upvotes: 2
Views: 1738
Reputation: 19004
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.
Upvotes: 0
Reputation: 233150
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.
Upvotes: 6