我有被使用Wsdl.exe工具,看起來像這樣生成的C#類單元測試模擬:如何使對象與非虛擬函數
public partial class SoapApi : System.Web.Services.Protocols.SoapHttpClientProtocol
{
public SOAPTypeEnum AskServerQuestion()
{
object[] results = return this.Invoke("AskServerQuestion");
return (SOAPTypeEnum) results[0];
}
}
我有些瘦包裝這個代碼跟蹤結果等等。是否有可能使用任何對象模擬框架來製作假的SoapApi類,併爲每個對薄包裝函數的調用返回可預測的結果?
我無法使AskServerQuestion()函數變爲虛擬的,因爲它是由wsdl.exe工具自動生成的。
http://stackoverflow.com/questions/1073684/mocking-non-virtual-methods-in-c – 2010-02-02 20:42:13