public void ControllerGetsPopulated()
 {
     var router=new Router();
     var home=router.Controller(c => new HomeController(c));
     home.Handles("/home").With(x=>x.GetHome());
     var context=new FakeServerContext();
     context.RequestUrl=new Uri("http://foo.bar/home");
     context.HttpMethod="get";
     router.Execute(context);
     Assert.AreEqual("mehfoobar", context.WrittenText());
 }
Beispiel #2
0
        public void Execute_FindsProperRoute()
        {
            var router=new Router();
            router.AddRoute(new Route());
            var rt=new Route();
            router.AddRoute(rt);
            rt.Pattern=new FakePatternMatcher("/foo");
            var context=new FakeServerContext();
            context.HttpMethod="GET";
            context.RequestUrl=new Uri("http://meh.com/foo");
            rt.Responder=(RequestContext c,ref bool skip ) => {
                var view=new WrapperView("foo");
                Assert.AreEqual(c.Context, context);
                return view;
            };

            var res=router.Execute(context);
            Assert.IsTrue(res);

            Assert.AreEqual("foo", context.WrittenText());
        }