我有一个看起来像这样的类:
public class MyClass
{
int myNum;
private MyClass() {}
public static MyClass CreateInstance()
{
MyClass a = new MyClass();
a.myNum=5;
return a;
}
public bool IsBigger(MyClass b)
{
return this.myNum > b.myNum;
}
}
然后,我想制作一个垫片并想使用 IsBigger 方法,但默认情况下它返回 false。在这种情况下如何调用基本方法?
测试是这样的:
[TestMethod]
Public void test()
{
ShimMyClass firstShim = new ShimMyClass();
firstShim.myNumGet = () => { return 6; }
ShimMyClass secondShim = new ShimMyClass();
secondShim.myNumGet = () => { return 7; }
Assert.IsTrue(secondShim.Instance.IsBiggerThan(firstShim.Instance);
}