想象一下,我有以下课程:
class ToTest : IToTest
{
public string MethodA()
{
return "Test";
}
public int MethodB()
{
returns a random number;
}
public string MethodC()
{
return this.MethodA + " " + this.MethodB.ToString();
}
}
我现在正在测试 MethodC,所以我知道我应该模拟当前实例的 MethodA 和 MethodB,所以我只测试 MethodC 的有效性,对吗?
我正在使用 Rhino,我做了以下事情:
ToTest testedObject = new ToTest();
testedObject.Expect(t => t.MethodA).Returns("AString");
testedObject.Expect(t => t.MethodB).Returns(1324");
Assert.AreEqual("AString 1324", testedObject.MethodC());
但是我得到一个正确的错误,说testedObject不是Mock。
方法对吗?我应该如何进行?