public void TestClassInstance () { var callee = new TestSubject (); var wrapper = new Wrapper(callee, "MethodConcatenate"); EnvDict env = new Dictionary<string, object>(); var t = wrapper.InvokeRoute(env, this.dict); Assert.AreEqual(this.expected, (string)env["result"]); }
public void TestTypeConversion () { var c = new TestSubject (); AddFunc f = c.MethodAdd; EnvDict env = new Dictionary<string, object>(); var wrapper = new Wrapper (f); wrapper.InvokeRoute(env, this.dict).Wait(); Assert.AreEqual(5, (int)env["result"]); }
public void TestDelegateToInstanceMethod () { var c = new TestSubject (); ConcatFunc f = c.MethodConcatenate; EnvDict env = new Dictionary<string, object>(); var wrapper = new Wrapper (f); wrapper.InvokeRoute(env, this.dict).Wait(); Assert.AreEqual(this.expected, (string)env["result"]); }
// Creates a route which calls methodName on instance callee converting any // matching entries in env["routeParams"] to arguments of callee.methodName private static IAppBuilder Route(this IAppBuilder app, string httpMethod, object callee, string methodName, RouteTemplate[] templates) { if (callee == null) { var msg = string.Format("Null target for route {0} {1}", httpMethod, templates[0]); throw new ArgumentNullException("callee", msg); } var wrapper = new Wrapper(callee, methodName); return Route(app, httpMethod, wrapper.Invoke, templates); }