Visual studio 2010 Moles似乎需要对moled方法进行散列
我正在一个家庭项目上试用Moles,希望能够推荐它在工作项目中被采用。我正在使用VS 10.0.30319和Moles 1.0.0.0 我创建了以下类:Visual studio 2010 Moles似乎需要对moled方法进行散列,visual-studio-2010,moles,Visual Studio 2010,Moles,我正在一个家庭项目上试用Moles,希望能够推荐它在工作项目中被采用。我正在使用VS 10.0.30319和Moles 1.0.0.0 我创建了以下类: public class DeveloperTestControlBL { public static bool VerifyCurrentDevelopmentStatus(int tpid, int testStatusID) { return false; // For this example, a
public class DeveloperTestControlBL
{
public static bool VerifyCurrentDevelopmentStatus(int tpid, int testStatusID)
{
return false; // For this example, always return false,
// so that a return of true means the delegation worked
}
}
在我的测试类中,我创建了一个测试,它测试一个调用VerifyCurrentDevelopmentStatus方法的类。我本来希望有一份声明,格式如下:
[TestMethod]
[HostType("Moles")]
public void TestPreTCIToEditReady_WithMoles()
{
var devTCBL = new SDeveloperTestControlBL();
devTCBL.VerifyCurrentDevelopmentStatus = delegate(int tpid, int testStatusID)
{
return true;
}
// rest of the test here
}
我发现,要设置委托,我必须执行以下操作:
[TestClass]
public class MyTest
{
[TestMethod]
[HostType("Moles")]
public void TestPreTCIToEditReady_WithMoles()
{
DelegateExample.Moles.MDeveloperTestControlBL.VerifyCurrentDevelopmentStatusInt32Int32 =
VerifyCurrentDevelopmentStatusAlwaysTrue;
// Rest of the test here
}
private bool VerifyCurrentDevelopmentStatusAlwaysTrue(int tpid, int status)
{
return true;
}
关于我做错了什么,有人有什么建议吗?我有
使用Microsoft.Moles.Framework;声明,并参考测试项目中的DeveloperTestControlBL.Moles
提前感谢,,
Ron L试试这个
devTCBL.VerifyCurrentDevelopmentStatus (delegate(int tpid, int testStatusID)
{
return true;
});
这对我有用