Exemplo n.º 1
0
        public void BuildRoutes_CreatesEightRoutes()
        {
            var routeCollection = new RouteCollection();

            SimplyRestfulRouteHandler.BuildRoutes(routeCollection);
            Assert.That(routeCollection.Count, Is.EqualTo(7));
        }
Exemplo n.º 2
0
        public void BuildRoutes_WhenNullArea_CreatesDefaultRoutes()
        {
            var routeCollection = new RouteCollection();

            SimplyRestfulRouteHandler.BuildRoutes(routeCollection, null);
            foreach (Route route in routeCollection)
            {
                Assert.That(route.Url, Is.StringStarting("{controller}"));
            }
        }
Exemplo n.º 3
0
        public void BuildRoutes_WhenAreaHasLeadingSlash_StripsTheSlash()
        {
            var routeCollection = new RouteCollection();

            SimplyRestfulRouteHandler.BuildRoutes(routeCollection, "/admin");
            foreach (Route route in routeCollection)
            {
                Assert.That(route.Url, Is.StringStarting("admin"));
            }
        }
            public virtual void GetRouteData_WithAControllerAndIdUsingHttpGetWithStringIdValidatorAndANumericId_DoesNotMatch()
            {
                routeCollection = new RouteCollection();
                SimplyRestfulRouteHandler.BuildRoutes(routeCollection, ControllerPath, "[a-zA-Z]+", ControllerName);

                using (mocks.Record())
                {
                    SetupContext("/123", "POST", "DELETE");
                }
                using (mocks.Playback())
                {
                    RouteData routeData = routeCollection.GetRouteData(httpContext);
                    Assert.That(routeData, Is.Null);
                }
            }
            public virtual void GetRouteData_WithAControllerAndIdUsingHttpGetWithAnyIdValidator_SetsTheShowAction()
            {
                routeCollection = new RouteCollection();
                SimplyRestfulRouteHandler.BuildRoutes(routeCollection, ControllerPath, SimplyRestfulRouteHandler.MatchAny, ControllerName);

                using (mocks.Record())
                {
                    SetupContext("/123", "POST", "DELETE");
                }
                using (mocks.Playback())
                {
                    RouteData routeData = routeCollection.GetRouteData(httpContext);
                    Assert.That(routeData.RouteHandler, Is.TypeOf(typeof(SimplyRestfulRouteHandler)));
                    AssertController(routeData);
                }
            }
 protected virtual void BuildRoutes(RouteCollection routes)
 {
     SimplyRestfulRouteHandler.BuildRoutes(routes, ControllerPath, SimplyRestfulRouteHandler.MatchPositiveInteger, ControllerName);
 }