質問

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

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

Question: How do I call GetProcedure from a Slim script table?

| 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

[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. If you're using the Fit test system, you'd say 'getprocedure of mytype' as the method name.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top