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#夹具
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;
}发布于 2013-03-17 04:24:12
不幸的是,Slim中不支持泛型方法。如果您使用的是Fit测试系统,您可以将'getprocedure of mytype‘作为方法名。
https://stackoverflow.com/questions/15282341
复制相似问题