示例#1
0
        public void Should_add_debug_route()
        {
            var routes = new RouteCollection();

            RouteDebugger.RewriteRoutesForTesting(routes);
            Assert.That(routes[0], Is.EqualTo(DebugRoute.Singleton));
        }
示例#2
0
        public void Handler_should_match_route()
        {
            var handler = new DebugHttpHandler();
            var mocks   = new MockRepository();
            var context = mocks.DynamicHttpContextBase();

            SetupResult.For(context.Request.AppRelativeCurrentExecutionFilePath).Return("~/Home/");
            SetupResult.For(context.Request.PathInfo).Return("Index");

            var routes = new RouteCollection
            {
                new Route("{controller}/{action}/{id}", null, new MvcRouteHandler()),
                new Route("{controller}/{action}", null, new MvcRouteHandler()),
                new Route("{controller}/{action}", new RouteValueDictionary(new Hash(Controller => "Home")),
                          new MvcRouteHandler())
            };

            RouteDebugger.RewriteRoutesForTesting(routes);

            mocks.ReplayAll();
            var routeData = new RouteData(routes[0], new DebugRouteHandler());

            routeData.Values.Add("Controller", "Home");
            routeData.Values.Add("Action", "Index");

            handler.RequestContext = new RequestContext(context, routeData);
            handler.ProcessRequest(context, routes);

            Assert.That(context.Response.Output.ToString().Contains("<tr><td>Controller</td><td>Home&nbsp;</td></tr>"));
        }
示例#3
0
        public void Should_not_add_debug_route_if_already_added()
        {
            var routes = new RouteCollection {
                DebugRoute.Singleton
            };

            RouteDebugger.RewriteRoutesForTesting(routes);
            Assert.That(routes.Count, Is.EqualTo(1));
        }
        protected override void OnApplicationStarted()
        {
            ServiceLocator.SetLocatorProvider(() => new NinjectServiceLocator(Kernel));

            RegisterAllControllersIn("Siesta.Example");
            RegisterRoutes(RouteTable.Routes);

            if (ConfigurationManager.AppSettings["enableRouteDebugging"] == "true")
            {
                RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
            }
        }
示例#5
0
        public void Should_rewrite_routes()
        {
            var routes = new RouteCollection
            {
                new Route("{controller}/{action}/{id}", null, new MvcRouteHandler()),
                new Route("{controller}/{action}", null, new MvcRouteHandler())
            };

            RouteDebugger.RewriteRoutesForTesting(routes);

            foreach (Route route in routes)
            {
                Assert.That(route.RouteHandler, Is.InstanceOf <DebugRouteHandler>());
            }
        }
示例#6
0
        public void Handler_should_not_match_route()
        {
            var handler = new DebugHttpHandler();
            var mocks   = new MockRepository();
            var context = mocks.DynamicHttpContextBase();

            SetupResult.For(context.Request.AppRelativeCurrentExecutionFilePath).Return("~/");
            SetupResult.For(context.Request.PathInfo).Return(string.Empty);

            var routes = new RouteCollection();

            RouteDebugger.RewriteRoutesForTesting(routes);

            mocks.ReplayAll();

            var routeData = new RouteData(DebugRoute.Singleton, new DebugRouteHandler());

            handler.RequestContext = new RequestContext(context, routeData);
            handler.ProcessRequest(context, routes);

            Assert.That(context.Response.Output.ToString().Contains("<strong class=\"false\">NO MATCH!</strong>"));
        }