public void ProcessRootRequest(RootRoute route, IRouteHandler routeHandler)
 {
     // todo: unit test this method
     var request = HttpContext.Request;
     RouteData routeData = route.GetRouteData(HttpContext);
     var requestContext = new RequestContext(HttpContext, routeData);
     string originalPath = request.Path;
     HttpContext.RewritePath(request.ApplicationPath, false);
     IHttpHandler httpHandler = routeHandler.GetHttpHandler(requestContext);
     httpHandler.ProcessRequest(System.Web.HttpContext.Current);
     HttpContext.RewritePath(originalPath);
 }
Exemple #2
0
        public void GetRouteDataWithRequestWithSubfolder_WhenAggregationEnabledAndBlogDoesNotHaveSubfolder_DoesNotMatch()
        {
            //arrange
            var httpContext = new Mock <HttpContextBase>();

            httpContext.FakeRequest("~/foo", string.Empty /* subfolder */, "~/");
            var route = new STRouting.RootRoute(true, new Mock <IDependencyResolver>().Object);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object);

            //assert
            Assert.IsNull(routeData);
        }
        public void GetRouteDataWithRequestForDefaultInSubfolder_WhenAggregationEnabled_MatchesRequestAndReturnsDtp()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/subfolder/default.aspx", "subfolder" /* subfolder */, "~/");
            var route = new STRouting.RootRoute(true, new Mock<IDependencyResolver>().Object);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object);

            //assert
            var routeHandler = routeData.RouteHandler as STRouting.PageRouteHandler;
            Assert.AreEqual("~/aspx/Dtp.aspx", routeHandler.VirtualPath);
            Assert.AreSame(route, routeData.Route);
        }
Exemple #4
0
        GetRouteDataWithRequestWithSubfolder_WhenAggregationDisabledAndSubfolderDoesNotMatchBlogSubfolder_DoesNotMatch
            ()
        {
            //arrange
            var httpContext = new Mock <HttpContextBase>();

            httpContext.FakeRequest("~/foo", "bar" /* subfolder */, "~/");
            var route = new STRouting.RootRoute(false, new Mock <IDependencyResolver>().Object);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object);

            //assert
            Assert.IsNull(routeData);
        }
        public void GetRouteDataWithRequestForAppRoot_WhenAggregationDisabled_MatchesAndReturnsDtp()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/", string.Empty /* subfolder */, "~/");
            var route = new STRouting.RootRoute(false, new Mock<IServiceLocator>().Object);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object);

            //assert
            var routeHandler = routeData.RouteHandler as STRouting.PageRouteHandler;
            Assert.AreEqual("~/aspx/Dtp.aspx", routeHandler.VirtualPath);
            Assert.AreSame(route, routeData.Route);
            Assert.IsTrue(routeData.DataTokens.ContainsKey(STRouting.PageRoute.ControlNamesKey));
        }
        public void Page_Load(object sender, EventArgs e)
        {
            // Workaround for Cassini issue with request to /, IIS 6 and IIS 7 Classic mode.
            // In IIS7 Integrated mode, Default.aspx can be deleted.

            var serviceLocator = Bootstrapper.ServiceLocator;
            var pipelineService = new PipelineService(new HttpContextWrapper(HttpContext.Current), serviceLocator);

            var route = new RootRoute(HostInfo.Instance.BlogAggregationEnabled, serviceLocator);
            IRouteHandler routeHandler =
                new Subtext.Framework.Routing.PageRouteHandler(
                    HostInfo.Instance.BlogAggregationEnabled ? "~/aspx/AggDefault.aspx" : "~/aspx/Dtp.aspx",
                    serviceLocator.GetService<ISubtextPageBuilder>(), serviceLocator);

            pipelineService.ProcessRootRequest(route, routeHandler);
        }
        public void GetRouteDataWithRequestForAppRoot_WhenAggregationEnabled_MatchesAndReturnsAggDefault()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/", string.Empty /* subfolder */, "~/");
            var route = new STRouting.RootRoute(true, new Mock<IDependencyResolver>().Object);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object);

            //assert
            var routeHandler = routeData.RouteHandler as STRouting.PageRouteHandler;
            Assert.AreEqual("~/aspx/AggDefault.aspx", routeHandler.VirtualPath);
            Assert.AreSame(route, routeData.Route);
            Assert.IsFalse(routeData.DataTokens.ContainsKey(STRouting.PageRoute.ControlNamesKey));
        }
Exemple #8
0
        public void GetVirtualPath_WhenSupplyingRouteValues_AppendsValuesToQueryString()
        {
            //arrange
            var httpContext = new Mock <HttpContextBase>();

            httpContext.FakeRequest("~/subfolder/default.aspx", string.Empty /* subfolder */, "~/");
            var routeData      = new RouteData();
            var requestContext = new RequestContext(httpContext.Object, routeData);
            var route          = new STRouting.RootRoute(true, new Mock <IDependencyResolver>().Object);
            var routeValues    = new RouteValueDictionary(new { foo = "bar" });

            //act
            VirtualPathData virtualPathInfo = route.GetVirtualPath(requestContext, routeValues);

            //assert
            Assert.AreEqual(virtualPathInfo.VirtualPath, "?foo=bar");
        }
Exemple #9
0
        public void GetVirtualPath_WhenAggregationEnabledWithSubfolderInRouteValues_ReturnsSubfolder()
        {
            //arrange
            var httpContext = new Mock <HttpContextBase>();

            httpContext.FakeRequest("~/subfolder/default.aspx", "subfolder" /* subfolder */, "~/");
            var routeData      = new RouteData();
            var requestContext = new RequestContext(httpContext.Object, routeData);
            var route          = new STRouting.RootRoute(true, new Mock <IDependencyResolver>().Object);
            var routeValues    = new RouteValueDictionary(new { subfolder = "subfolder" });

            //act
            VirtualPathData virtualPathInfo = route.GetVirtualPath(requestContext, routeValues);

            //assert
            Assert.AreEqual("subfolder", virtualPathInfo.VirtualPath);
        }
Exemple #10
0
        public void GetRouteDataWithRequestForSubfolder_WhenAggregationDisabled_MatchesRequestAndReturnsDtp()
        {
            //arrange
            var httpContext = new Mock <HttpContextBase>();

            httpContext.FakeRequest("~/subfolder", "subfolder" /* subfolder */, "~/");
            var route = new STRouting.RootRoute(false, new Mock <IDependencyResolver>().Object);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object);

            //assert
            var routeHandler = routeData.RouteHandler as STRouting.PageRouteHandler;

            Assert.AreEqual("~/aspx/Dtp.aspx", routeHandler.VirtualPath);
            Assert.AreSame(route, routeData.Route);
        }
Exemple #11
0
        public void GetRouteDataWithRequestForDefault_WhenAggregationEnabled_MatchesAndReturnsAggDefault()
        {
            //arrange
            var httpContext = new Mock <HttpContextBase>();

            httpContext.FakeRequest("~/Default.aspx", string.Empty /* subfolder */, "~/");
            var route = new STRouting.RootRoute(true, new Mock <IDependencyResolver>().Object);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object);

            //assert
            var routeHandler = routeData.RouteHandler as STRouting.PageRouteHandler;

            Assert.AreEqual("~/aspx/AggDefault.aspx", routeHandler.VirtualPath);
            Assert.AreSame(route, routeData.Route);
        }
Exemple #12
0
        public void GetRouteDataWithRequestForAppRoot_WhenAggregationDisabled_MatchesAndReturnsDtp()
        {
            //arrange
            var httpContext = new Mock <HttpContextBase>();

            httpContext.FakeRequest("~/", string.Empty /* subfolder */, "~/");
            var route = new STRouting.RootRoute(false, new Mock <IDependencyResolver>().Object);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object);

            //assert
            var routeHandler = routeData.RouteHandler as STRouting.PageRouteHandler;

            Assert.AreEqual("~/aspx/Dtp.aspx", routeHandler.VirtualPath);
            Assert.AreSame(route, routeData.Route);
            Assert.IsTrue(routeData.DataTokens.ContainsKey(STRouting.PageRoute.ControlNamesKey));
        }
        public void GetRouteDataWithRequestForSubfolder_WhenAggregationDisabled_MatchesRequestAndReturnsDtp()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/subfolder", "subfolder" /* subfolder */, "~/");
            var route = new STRouting.RootRoute(false, new Mock<IServiceLocator>().Object);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object);

            //assert
            var routeHandler = routeData.RouteHandler as STRouting.PageRouteHandler;
            Assert.AreEqual("~/aspx/Dtp.aspx", routeHandler.VirtualPath);
            Assert.AreSame(route, routeData.Route);
        }
Exemple #14
0
        public void GetVirtualPath_WhenSupplyingRouteValues_AppendsValuesToQueryString()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/subfolder/default.aspx", string.Empty /* subfolder */, "~/");
            var routeData = new RouteData();
            var requestContext = new RequestContext(httpContext.Object, routeData);
            var route = new STRouting.RootRoute(true, new Mock<IDependencyResolver>().Object);
            var routeValues = new RouteValueDictionary(new { foo = "bar" });

            //act
            VirtualPathData virtualPathInfo = route.GetVirtualPath(requestContext, routeValues);

            //assert
            Assert.AreEqual(virtualPathInfo.VirtualPath, "?foo=bar");
        }
Exemple #15
0
        public void GetVirtualPath_WhenAggregationEnabledWithSubfolderInRouteValues_ReturnsSubfolder()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/subfolder/default.aspx", "subfolder" /* subfolder */, "~/");
            var routeData = new RouteData();
            var requestContext = new RequestContext(httpContext.Object, routeData);
            var route = new STRouting.RootRoute(true, new Mock<IDependencyResolver>().Object);
            var routeValues = new RouteValueDictionary(new { subfolder = "subfolder" });

            //act
            VirtualPathData virtualPathInfo = route.GetVirtualPath(requestContext, routeValues);

            //assert
            Assert.AreEqual("subfolder", virtualPathInfo.VirtualPath);
        }
Exemple #16
0
        public void GetRouteDataWithRequestWithSubfolder_WhenAggregationEnabledAndSubfolderDoesNotMatchBlogSubfolder_DoesNotMatch()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/foo", "bar" /* subfolder */, "~/");
            var route = new STRouting.RootRoute(true, new Mock<IDependencyResolver>().Object);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object);

            //assert
            Assert.IsNull(routeData);
        }
        public void GetRouteDataWithRequestWithSubfolder_WhenAggregationEnabledAndBlogDoesNotHaveSubfolder_DoesNotMatch()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/foo", string.Empty /* subfolder */, "~/");
            var route = new STRouting.RootRoute(true, new Mock<IServiceLocator>().Object);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object);

            //assert
            Assert.IsNull(routeData);
        }
        public void GetRouteDataWithRequestForDefault_WhenAggregationEnabled_MatchesAndReturnsAggDefault()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/Default.aspx", string.Empty /* subfolder */, "~/");
            var route = new STRouting.RootRoute(true, new Mock<IServiceLocator>().Object);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object);

            //assert
            var routeHandler = routeData.RouteHandler as STRouting.PageRouteHandler;
            Assert.AreEqual("~/aspx/AggDefault.aspx", routeHandler.VirtualPath);
            Assert.AreSame(route, routeData.Route);
        }
        public void GetVirtualPath_WhenAggregationEnabledAndNoSubfolderInRouteData_ReturnsRoot()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/default.aspx", string.Empty /* subfolder */, "~/");
            var routeData = new RouteData();
            var requestContext = new RequestContext(httpContext.Object, routeData);
            var route = new STRouting.RootRoute(true, new Mock<IServiceLocator>().Object);
            var routeValues = new RouteValueDictionary();

            //act
            VirtualPathData virtualPathInfo = route.GetVirtualPath(requestContext, routeValues);

            //assert
            Assert.AreEqual(string.Empty, virtualPathInfo.VirtualPath);
        }
        public void GetVirtualPath_WhenSupplyingRouteValues_ReturnsNull()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/subfolder/default.aspx", string.Empty /* subfolder */, "~/");
            var routeData = new RouteData();
            var requestContext = new RequestContext(httpContext.Object, routeData);
            var route = new STRouting.RootRoute(true, new Mock<IServiceLocator>().Object);
            var routeValues = new RouteValueDictionary(new {foo = "bar"});

            //act
            VirtualPathData virtualPathInfo = route.GetVirtualPath(requestContext, routeValues);

            //assert
            Assert.IsNull(virtualPathInfo);
        }