Пример #1
0
        public void CanMatchEmptyUrl()
        {
            RouteCollection routes = new RouteCollection();

            routes.Add(new Route(string.Empty, new Mock <IRouteHandler>().Object)
            {
                Defaults = new RouteValueDictionary(new { controller = "Home" })
            });

            var context   = RoutingMockHelpers.FakeHttpContext("~/");
            var routeData = routes.GetRouteData(context);

            Assert.NotNull(routeData);
            Assert.Equal("Home", routeData.Values["controller"]);
        }
Пример #2
0
        public void CanMatchRouteTheShortWay()
        {
            // Arrange
            var routes = new RouteCollection();

            GlobalApplication.RegisterRoutes(routes);
            var context = RoutingMockHelpers.FakeHttpContext("~/foo/bar");

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

            // Assert
            Assert.Equal("bar", routeData.Values["id"]);
            Assert.Equal("Test", routeData.Values["controller"]);
            Assert.Equal("Index", routeData.Values["action"]);
            Assert.Equal("foo-route", routeData.DataTokens["routeName"]);
        }