public void MustHaveAContentItemInRequestContext()
        {
            IRouteHandler routeHandler = new ContentRouteHandler(new ControllerFinder(new Configuration.AssemblyList() { GetType().Assembly }));
            RequestContext requestContext = new RequestContext(Mocks.MockupHttpContext("/").Object, new RouteData());

            Assert.Throws<ArgumentException>( () => routeHandler.GetHttpHandler(requestContext) );
        }
        public void GetsAContentHttpHandler()
        {
            ControllerBuilder.Current.SetControllerFactory(Mocks.MockupControllerFactory().Object);
            RequestContext requestContext = new RequestContext(Mocks.MockupHttpContext("/").Object,new RouteData());
            requestContext.RouteData.Values.SetContentItem(new Page());
            IRouteHandler routeHandler = new ContentRouteHandler(new ControllerFinder(new Configuration.AssemblyList() { GetType().Assembly }));

            IHttpHandler handler = routeHandler.GetHttpHandler(requestContext);

            Assert.IsType<MvcHandler>(handler);
            Assert.NotNull(((MvcHandler)handler).RequestContext.RouteData.Values.GetContentItem());
            Assert.Equal("Page", ((MvcHandler)handler).RequestContext.RouteData.Values["controller"]);
        }
Example #3
0
 public ContentRoute(IContentFinder contentFinder, ContentRouteHandler handler)
 {
     this.contentFinder = contentFinder;
     this.handler = handler;
 }