I have some code, simplified as follows. It is an abstract class and a child class.
Here is the abstract class. I know there aren't any abstract methods, it's ok.. for this example, it works. Notice that I have both a normal method and a static method named the same (Reg). Note also they have different arguments, meaning different signatures.
public abstract class Parent
{
private string _s;
public Parent()
: this("empty")
{
}
public Parent(string s) {
_s = s;
}
public void Reg()
{
Parent.Reg(_s);
}
public static void Reg(string word)
{
Console.WriteLine(word);
}
}
And here is my concrete class, inheriting from Parent. Simple enough.
public class Child : Parent
{
public Child(string s)
: base(s + ": from child")
{
}
}
Here is how I test it.
public void RegTest()
{
string s = "eric";
Child target = new Child(s);
MockManager.Init();
using (RecordExpectations r = RecorderManager.StartRecording())
{
Parent.Reg(s);
}
target.Reg();
MockManager.Verify();
}
Parent.Reg (the static method) gets called through! The test fails because "Method TMtest.Parent.Reg() has 1 more expected calls"
TypeMock trace reports under "MockAllInstances" Reg(0/1) while under Static Reg(1) (and it notes this was an unexpected call).
So how do I get TypeMock to mock the static call?
Thanks!
-Eric
________
vapir oxygen