예제 #1
0
		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"]);
		}
예제 #2
0
 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"]);
 }
예제 #3
0
		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"]);
		}
예제 #4
0
 // 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);
 }