0
創建測試當我嘗試生成以下方法的單元測試(在一個公共靜態類)錯誤而在Visual Studio
private static string[] GetFields(string line, char sep)
{
char[] totrim = { '"', ' ' };
return line.Split(sep).Select(col => col.Trim(totrim)).ToArray();
}
測試輸出說:
While trying to generate your tests, the following errors occurred:
This method or property cannot be called within an event handler.
它的工作原理如果我公開該功能 - 我試過手動運行Publicize.exe,它不會抱怨,但也沒有任何區別。
你測試這個類的組成部分?據我所知,該聲明沒有任何區別。私人方法的測試仍然不會生成。但是,我可以更改爲內部的,即使沒有程序集聲明,它也可以工作... – Benjol 2009-08-20 05:36:56
我在猜測您的測試,並在與您正在測試的代碼相同的項目/組件中。這應該使內部選項起作用。如果你在外部組件中進行測試,我的代碼就可以工作 - 這就是我們目前在我們的項目中有一些測試工作的原因,所以它可以工作 – 2009-08-20 08:27:06