【问题标题】:Moles appears to require moled methods to be hashed摩尔似乎需要对摩尔方法进行哈希处理
【发布时间】:2012-10-18 23:43:22
【问题描述】:

我正在一个家庭项目中试用 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, 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 的引用。

提前致谢, 罗恩L

【问题讨论】:

    标签: visual-studio-2010 moles


    【解决方案1】:

    试试这个

       devTCBL.VerifyCurrentDevelopmentStatus (delegate(int tpid, int testStatusID) 
           {
                return true;
           });
    

    它对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-10
      • 1970-01-01
      • 1970-01-01
      • 2013-02-12
      • 1970-01-01
      相关资源
      最近更新 更多