[英]Fitnesse slim: Call generic method (fitSharp)
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
I have a C# fixture that contains the following generic method 我有一个包含以下通用方法的C#装置
public Func<T> GetProcedure<T>(string name)
{
return () => default(T);
}
Question : How do I call GetProcedure from a Slim script table? 问题 :如何从Slim脚本表中调用GetProcedure ?
| show | GetProcedure; <?specify type here?> | text |
I found the following test in the source code, so it should be possible. 我在源代码中找到了以下测试,因此应该可行。 However, I don't know how to define the type T within the script table so that slim can parse it... https://github.com/jediwhale/fitsharp/blob/master/source/fitSharpTest/NUnit/Machine/MemberQueryTest.cs
但是,我不知道如何在脚本表中定义类型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;
}
Unfortunately generic methods are not supported in Slim. 不幸的是,Slim不支持通用方法。 If you're using the Fit test system, you'd say 'getprocedure of mytype' as the method name.
如果您使用的是Fit测试系统,则可以将“ mytype的getprocedure”作为方法名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.