예제 #1
0
        public void RouteUrlWithUrlRouteContext_ReturnsExpectedResult()
        {
            // Arrange
            var services  = CreateServices();
            var urlHelper = CreateUrlHelperWithRouteCollection(services, "/app");

            var routeContext = new UrlRouteContext()
            {
                RouteName = "namedroute",
                Values    = new
                {
                    Action     = "newaction",
                    Controller = "home2",
                    id         = "someid"
                },
                Fragment = "somefragment",
                Host     = "remotetown",
                Protocol = "ftp"
            };

            // Act
            var url = urlHelper.RouteUrl(routeContext);

            // Assert
            Assert.Equal("ftp://remotetown/app/named/home2/newaction/someid#somefragment", url);
        }
예제 #2
0
        /// <inheritdoc />
        public virtual string RouteUrl(UrlRouteContext routeContext)
        {
            var valuesDictionary = PropertyHelper.ObjectToDictionary(routeContext.Values);

            var path = GeneratePathFromRoute(routeContext.RouteName, valuesDictionary);

            if (path == null)
            {
                return(null);
            }

            return(GenerateUrl(routeContext.Protocol, routeContext.Host, path, routeContext.Fragment));
        }
예제 #3
0
        /// <inheritdoc />
        public virtual string RouteUrl(UrlRouteContext routeContext)
        {
            if (routeContext == null)
            {
                throw new ArgumentNullException(nameof(routeContext));
            }

            var valuesDictionary = new RouteValueDictionary(routeContext.Values);

            var path = GeneratePathFromRoute(routeContext.RouteName, valuesDictionary);

            if (path == null)
            {
                return(null);
            }

            return(GenerateUrl(routeContext.Protocol, routeContext.Host, path, routeContext.Fragment));
        }
예제 #4
0
        /// <inheritdoc />
        public virtual string RouteUrl(UrlRouteContext routeContext)
        {
            if (routeContext == null)
            {
                throw new ArgumentNullException(nameof(routeContext));
            }

            var valuesDictionary = new RouteValueDictionary(routeContext.Values);

            var path = GeneratePathFromRoute(routeContext.RouteName, valuesDictionary);
            if (path == null)
            {
                return null;
            }

            return GenerateUrl(routeContext.Protocol, routeContext.Host, path, routeContext.Fragment);
        }
예제 #5
0
        public void RouteUrlWithUrlRouteContext_ReturnsExpectedResult()
        {
            // Arrange
            var services = GetServices();
            var urlHelper = CreateUrlHelperWithRouteCollection(services, "/app");

            var routeContext = new UrlRouteContext()
            {
                RouteName = "namedroute",
                Values = new
                {
                    Action = "newaction",
                    Controller = "home2",
                    id = "someid"
                },
                Fragment = "somefragment",
                Host = "remotetown",
                Protocol = "ftp"
            };

            // Act
            var url = urlHelper.RouteUrl(routeContext);

            // Assert
            Assert.Equal("ftp://remotetown/app/named/home2/newaction/someid#somefragment", url);
        }
예제 #6
0
        /// <inheritdoc />
        public virtual string RouteUrl(UrlRouteContext routeContext)
        {
            var valuesDictionary = PropertyHelper.ObjectToDictionary(routeContext.Values);

            var path = GeneratePathFromRoute(routeContext.RouteName, valuesDictionary);
            if (path == null)
            {
                return null;
            }

            return GenerateUrl(routeContext.Protocol, routeContext.Host, path, routeContext.Fragment);
        }
예제 #7
0
 public override string RouteUrl(UrlRouteContext routeContext)
 {
     return ConvertToLowercaseUrl(base.RouteUrl(routeContext));
 }