I'm working on some legacy code that uses classes, methods and all sorts of patterns that weren't designed for testability. I'd like to create unit tests for changes that were added, but I don't want the base class functionality to be called if I provide a surrogate (the base class methods access a database resource).
What I want to do is effectively similar to:
public override void DoSomething()
{
// Perform some custom logic before calling the base implementation
// ...
// ...
// The keyword base is not valid in this context
(BaseClassSurrogate ?? base).DoSomething();
// Some more custom logic
// ...
// ...
}
Is something like this possible in C#, or is there an alternate way of testing this that doesn't involve a complex refactor?