Fitnesse slim:调用泛型方法(fitSharp)

时间:2013-03-07 21:42:55

标签: fitnesse fitsharp fitnesse-slim

Linux 3.2.0-3-amd64 #1 SMP Mon Jul 23 02:45:17 UTC 2012 x86_64 GNU/Linux
Mono 2.10.8.1 (Debian 2.10.8.1-7) (64-bit)
glib-sharp 2.12.0.0
FitNesse (v20121220)
FitSharp release 2.2 for .net 4.0

我有一个包含以下通用方法的C#fixture

public Func<T> GetProcedure<T>(string name)
{
    return () => default(T);
}

问题:如何从Slim脚本表中调用 GetProcedure

| show | GetProcedure; <?specify type here?> | text |

我在源代码中找到了以下测试,所以它应该是可能的。但是,我不知道如何在脚本表中定义类型T,以便slim可以解析它... https://github.com/jediwhale/fitsharp/blob/master/source/fitSharpTest/NUnit/Machine/MemberQueryTest.cs

[Test] public void GenericMethodWithParmsIsInvoked() {
    var member = new MemberName("genericmethodofsystemint32", "genericmethod", new[] { typeof(int)});

    var method = MemberQuery.FindInstance(MemberQuery.FindMember, instance, new MemberSpecification(member, 1));
    Assert.IsNotNull(method);
    var result = method.Invoke(new object[] {123});
    Assert.AreEqual("sample123", result.Value.ToString());
}

// This method found via the reflection above.
// see: fitSharp.Test.Double.SampleClass
public string GenericMethod<T>(T input) {
    return "sample" + input;
}

1 个答案:

答案 0 :(得分:1)

不幸的是,Slim不支持通用方法。如果你正在使用Fit测试系统,你会说'getprocedure of mytype'作为方法名称。