I have a user control which does some validation in the ValidateChildren method which I would like to test. I have created a partial mock of the user control, but although I am not setting any expectations on the ValidateChildren method, I am simply calling it, it is simply skipped and the code inside the method never executes. To try and understand what is going on I created a simple test, like so:
public class Foo
{
public virtual bool Method1()
{
throw new NotImplementedException();
}
public virtual bool Method2()
{
return Method1();
}
}
and use this to test it:
[Test]
public void TestFooMethods ()
{
MockRepository m = new MockRepository();
Foo foo = m.PartialMock<Foo>();
RhinoMocksExtensions.Expect<Foo,bool>(
foo,
delegate (Foo obj)
{
return obj.Method1();
}
).Return(true);
Assert.IsTrue (foo.Method2());
}
now I would expect foo.Method1 to be mocked and foo.Method2 not to be. But this always returns false, and if I try and step through in the debugger foo.Method2() is stepped over, and I can't step in to it.
Any ideas why?