I have a situation I've run into several times but have never found a good answer for. Suppose I have a class like the following, where one method calls another in the same class:
public class Foo
{
public int Bar()
{
if (Baz())
{
return 1;
}
else
{
return 2;
}
}
public virtual bool Baz()
{
// behavior to be mocked
}
}
I want to unit test the behavior of the method Bar() depending on return values of Baz(). If Baz() were in a different class, I would call PartialMock to set up mocking behavior on that class, but it doesn't seem to work when PartialMock is used on the test class itself. Is there an easy way to do this? What am I missing?
I'm using Rhino Mocks 3.5 and .NET 2.0.