Example #1
0
        public void GetRouteData_MatchingTheImplicitSubfolderRoute_ReturnsParentDirectoryRoute()
        {
            //arrange
            var route = new PageRoute("url", "~/aspx/Dtp.aspx", new[] { "foo" }, new Mock<ISubtextPageBuilder>().Object,
                                      new Mock<IDependencyResolver>().Object);
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/subfolder/url");
            var blogRequest = new BlogRequest("localhost", "subfolder", new Uri("http://localhost"), false);

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

            //assert
            Assert.AreEqual(route, routeData.Route);
        }
Example #2
0
        public void RequestWithoutSubfolder_ForBlogPostWithSubfolder_DoesNotMatch()
        {
            //arrange
            var subtextRoute = new PageRoute("archive/{slug}", "~/aspx/Dtp.aspx", null,
                                             new Mock<ISubtextPageBuilder>().Object, new Mock<IDependencyResolver>().Object);
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/archive/blog-post");
            //This info is provided by the BlogRequestModule.
            var blogRequest = new BlogRequest("localhost", "subfolder", new Uri("http://localhost/archive/blog-post"),
                                              true);

            //act
            RouteData routeData = subtextRoute.GetRouteData(httpContext.Object, blogRequest);

            //assert.
            Assert.IsNull(routeData);
        }
Example #3
0
        public void Request_ForPageRouteWithConstraints_MatchesWhenConstraintsAreSatisfied()
        {
            //arrange
            var route = new PageRoute("archive/{year}/{month}/{day}/{slug}.aspx", "~/aspx/Dtp.aspx", null,
                                      new Mock<ISubtextPageBuilder>().Object, new Mock<IDependencyResolver>().Object) { Constraints = new RouteValueDictionary(new { year = @"\d{4}" }) };
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/archive/2008/01/23/slug.aspx");
            var blogRequest = new BlogRequest("localhost", null, new Uri("http://localhost"), false);

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

            //assert
            Assert.IsNotNull(routeData);
        }