小编Bry*_*Mau的帖子

有没有办法将代理传递给NUnit TestCase或TestFixture?

基本上我希望能够将方法插入到NUnit中的TestCase或TestFixture来改变行为.本质上我想这样做:

[TestFixture]
public class MethodTests
{
    public delegate void SimpleDelegate();

    public static void A()
    {
        // Do something meaningful
    }

    public static void B()
    {
        // Do something meaningful
    }

    public static void C()
    {
        // Do something meaningful
    }

    [TestCase(A,B,C)]
    [TestCase(C,A,B)]
    [TestCase(C,B,A)]
    public void Test(SimpleDelegate action1, SimpleDelegate action2, SimpleDelegate action3 )
    {
        action1();
        action2();
        action3();
    }
}
Run Code Online (Sandbox Code Playgroud)

我收到的[TestCase(A,B,C)]的错误是

  • 错误6参数1:无法从'方法组'转换为'对象'
  • 错误7参数2:无法从"方法组"转换为"对象"
  • 错误8参数3:无法从'方法组'转换为'对象'

你知道是否有办法让这个或类似的东西工作?

c# delegates nunit parameterized-unit-test

14
推荐指数
1
解决办法
4392
查看次数

标签 统计

c# ×1

delegates ×1

nunit ×1

parameterized-unit-test ×1