示例#1
0
        public void Setup()
        {
            HttpContext.Current = MockHelperFactory.FakeHttpContext();

            var item = RouteTable.Routes.Cast <Route>().SingleOrDefault(r => r.Url == "{year}/{month}/{url}/{status}");

            if (item == null)
            {
                var routeValueDictionary = new RouteValueDictionary
                {
                    { "controller", "Home" },
                    { "action", "View" },
                    { "status", UrlParameter.Optional }
                };

                var constraintDictionary = new RouteValueDictionary
                {
                    { "year", @"\d{4}" },
                    { "month", @"[0-9]{1,2}" },
                    { "url", @"\S+" },
                    { "status", @"[a-z\-]*" }
                };

                RouteTable.Routes.Add("IndividualPost", new Route("{year}/{month}/{url}/{status}", routeValueDictionary,
                                                                  constraintDictionary, null));
            }
        }
        public void Setup()
        {
            HttpContext.Current = MockHelperFactory.FakeHttpContext();

            var item = RouteTable.Routes.Cast <Route>().SingleOrDefault(r => r.Url == "pages/{pageUrl}/{status}");

            if (item == null)
            {
                var routeValueDictionary = new RouteValueDictionary
                {
                    { "controller", "ViewPage" },
                    { "action", "Index" },
                    { "status", UrlParameter.Optional }
                };

                var constraintDictionary = new RouteValueDictionary
                {
                    { "pageUrl", @"\S+" },
                    { "status", @"[a-z\-]*" }
                };

                RouteTable.Routes.Add("Pages", new Route("pages/{pageUrl}/{status}", routeValueDictionary,
                                                         constraintDictionary, null));
            }
        }
 public void Setup()
 {
     HttpContext.Current = MockHelperFactory.FakeHttpContext();
 }