我已經得到了我使用記錄靜態類:包裝靜態類/方法以便進行單元測試?
public static class myLogger
{
public static ErrorLogging(string input)
{
//dostuff
}
}
我使用它的方式是:
public class myClassthatDoesStuff
{
...
myLogger.ErrorLogging("some error ocurred");
...
}
我怎樣才能起訂量的myLogger類以能夠進行單元測試並確保執行了ErrorLogging方法? 是否可以在構造函數(構造函數注入)中沒有設置任何參數的情況下做到這一點?myClassthatDoesStuff要求在構造函數中沒有參數。
退房微軟的墊片https://msdn.microsoft.com/en-us/library/hh549176 (v = vs.110).aspx – igorushi
要求 Visual Studio Ultimate –
可能的重複[如何嘲笑靜態方法在C#中使用MOQ框架?](http://stackoverflow.com/questions/12580015/how-to-mock -static-methods-in-c-sharp-using-moq-framework) –