示例#1
0
        public void RouteWithControllerWithActionWithId()
        {
            // Arrange
            StubContext     context = new StubContext("~/controller1/action2/id3");
            RouteCollection routes  = new RouteCollection();

            MvcApplication.RegisterRoutes(routes);

            // Act
            RouteData routeData = routes.GetRouteData(context);

            // Assert
            Assert.NotNull(routeData);
            Assert.Equal("controller1", routeData.Values["controller"]);
            Assert.Equal("action2", routeData.Values["action"]);
            Assert.Equal("id3", routeData.Values["id"]);
        }
示例#2
0
        public void RouteWithControllerNoActionNoId()
        {
            // Arrange
            StubContext     context = new StubContext("~/controller1");
            RouteCollection routes  = new RouteCollection();

            MvcApplication.RegisterRoutes(routes);

            // Act
            RouteData routeData = routes.GetRouteData(context);

            // Assert
            Assert.NotNull(routeData);
            Assert.Equal("controller1", routeData.Values["controller"]);
            Assert.Equal("Index", routeData.Values["action"]);
            Assert.Equal(UrlParameter.Optional, routeData.Values["id"]);
        }