我對單元測試相當陌生。我最近遇到了一個問題,我測試了一個只做一件事的方法 - 它調用了一個屬於該類的對象的方法。這個對象代表的類有它自己的單元測試。如何測試調用另一個類的方法的方法?
據我所知,這個method may change in time,當它做測試應該告訴我如果預期的結果它。但是我能用這種方法測試什麼?
我的代碼:
public class MyClassToBeTested
{
private CustomType myObject;
private const myParameter = 2;
(...)
public string MyProperty
{
get
{
return myObject.DoYourStuff(myParameter);
}
}
}
顯示您的代碼。 –