Exemplo n.º 1
0
        public void RouteWithPropertySearch()
        {
            // Arrange
            var context = new StubHttpContextForRouting(requestUrl: "~/property/search");
            var routes = new RouteCollection();
            RouteConfiguration.Register(routes);

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

            // Assert
            Assert.NotNull(routeData);
            Assert.Equal("Property", routeData.Values["controller"]);
            Assert.Equal("Search", routeData.Values["action"]);
        }
Exemplo n.º 2
0
        static UrlHelper GetUrlHelper(string appPath = "/", RouteCollection routes = null)
        {
            if (routes == null)
            {
                routes = new RouteCollection();
                RouteConfiguration.Register(routes);
            }

            HttpContextBase httpContext = new StubHttpContextForRouting(appPath);
            RouteData routeData = new RouteData();
            routeData.Values.Add("controller", "defaultcontroller");
            routeData.Values.Add("action", "defaultaction");
            RequestContext requestContext = new RequestContext(httpContext, routeData);
            UrlHelper helper = new UrlHelper(requestContext, routes);
            return helper;
        }
Exemplo n.º 3
0
        public void RoutePropertyAuditLog()
        {
            // Arrange
            var context = new StubHttpContextForRouting(requestUrl: "~/property/100/auditLog");
            var routes = new RouteCollection();
            RouteConfiguration.Register(routes);

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

            // Assert
            Assert.NotNull(routeData);
            Assert.Equal("Property", routeData.Values["controller"]);
            Assert.Equal("AuditLog", routeData.Values["action"]);
            Assert.Equal("100", routeData.Values["propertyId"]);
        }