Exactly. That's what I'm trying to do is test the behaviour of the base class on it's own, and the behaviour of the child class on it's own. For now, let's forget about the base class.
What you're trying to do is not possible (setting an expectation for a
method and manually invoking the same method on the base
You've got it backwards. I'm trying to test the method on B, and have an expectation fire for A. B overrides A's method. I test A seperately, but I cannot test B independently it seems, without A firing. This seems like a very common requirement to me.
Your suggestion will only work if it's not an override. So I can setup expectations on the base methods, but how can I do this in an override scenario? I think it's a limiation of Moq at the moment, but I don't fully understand it so I want make sure I'm not missing something.
class B : A
{
public override void Create(Entity ent)
{
ent.ID = 1;
base.Create(ent);
}
}
I want to test B and Assert that ent.ID == 1. How can I mock B's parent (A)'s Create method? I want the call to base.Create(ent) inside of B to be mocked. I DONT' want to test A's method. A is the parent class, and I test it separately. But how can I test the REAL method of Create in the child class B, and mock any calls inside to the parent class A?
Thanks.