I ran into a bit of a trouble while testing one of my classes. I have an abstract class which contains one public method and two protected abstract once. I need to test weather public method calls one of the abstract once.
Heres an example of how my code looks like:
public abstract class A
{
public string DoSomething(stirng input)
{
var output = new StringBuilder();
foreach (var currentChar in input)
{
output.Append(DoSomethingElse(currentChar));
}
return output.ToString();
}
protected abstract char DoSomethingElse(char charToChange);
}
public class B : A
{
protected override char DoSomethingElse(char charToChange)
{
var changedChar = charToChange;
// Some logic changing charToChange's value
return changedChar;
}
}
Because DoSomethingElse()
is protected I've created a class that publishes that method
public class BPublisher : B
{
public virtual new char DoSomethingElse()
{
return base.DoSomethingElse()
}
}
My question is how do I test the fact that DoSomething()
called DoSomethingElse()
using
Rhino mocks?
P.S. I have tried using Expect
and AssertWasCalled
but without success.