public void GenerateRoute_DoesNotClaimData()
        {
            LinkGenerationRoute route = new LinkGenerationRoute(new InnerRoute());

            IHttpRouteData data = route.GetRouteData(string.Empty, new HttpRequestMessage());

            Assert.Null(data);
        }
        public void GenerateRoute_DoesNotClaimData()
        {
            LinkGenerationRoute route = new LinkGenerationRoute(new InnerRoute());

            IHttpRouteData data = route.GetRouteData(string.Empty, new HttpRequestMessage());

            Assert.Null(data);
        }
        public void GenerateRoute_GetVirtualPathIsForwarded()
        {
            HttpRequestMessage request = new HttpRequestMessage();
            IDictionary<string, object> values = new Dictionary<string, object>();

            IHttpVirtualPathData data = new Mock<IHttpVirtualPathData>().Object;

            Mock<IHttpRoute> inner = new Mock<IHttpRoute>();
            inner.Setup(r => r.GetVirtualPath(request, values)).Returns(data);

            LinkGenerationRoute route = new LinkGenerationRoute(inner.Object);

            IHttpVirtualPathData result = route.GetVirtualPath(request, values);

            Assert.Equal(data, result);
        }
        public void GenerateRoute_GetVirtualPathIsForwarded()
        {
            HttpRequestMessage           request = new HttpRequestMessage();
            IDictionary <string, object> values  = new Dictionary <string, object>();

            IHttpVirtualPathData data = new Mock <IHttpVirtualPathData>().Object;

            Mock <IHttpRoute> inner = new Mock <IHttpRoute>();

            inner.Setup(r => r.GetVirtualPath(request, values)).Returns(data);

            LinkGenerationRoute route = new LinkGenerationRoute(inner.Object);

            IHttpVirtualPathData result = route.GetVirtualPath(request, values);

            Assert.Equal(data, result);
        }
        // Add generation hooks for the Attribute-routing subroutes.
        // This lets us generate urls for routes supplied by attr-based routing.
        private static void AddGenerationHooksForSubRoutes(HttpRouteCollection routeTable,
                                                           IEnumerable <RouteEntry> entries)
        {
            Contract.Assert(entries != null);
            foreach (RouteEntry entry in entries)
            {
                Contract.Assert(entry != null);
                string name = entry.Name;

                if (name != null)
                {
                    IHttpRoute route = entry.Route;
                    Contract.Assert(route != null);
                    IHttpRoute linkGenerationRoute = new LinkGenerationRoute(route);
                    routeTable.Add(name, linkGenerationRoute);
                }
            }
        }
        // Add generation hooks for the Attribute-routing subroutes. 
        // This lets us generate urls for routes supplied by attr-based routing.
        private static void AddGenerationHooksForSubRoutes(HttpRouteCollection routeTable,
            IEnumerable<RouteEntry> entries)
        {
            Contract.Assert(entries != null);
            foreach (RouteEntry entry in entries)
            {
                Contract.Assert(entry != null);
                string name = entry.Name;

                if (name != null)
                {
                    IHttpRoute route = entry.Route;
                    Contract.Assert(route != null);
                    IHttpRoute linkGenerationRoute = new LinkGenerationRoute(route);
                    routeTable.Add(name, linkGenerationRoute);
                }
            }
        }
        public void GenerateRoute_ForwardsInnerProperties()
        {
            IHttpRoute          innerRoute = new InnerRoute();
            LinkGenerationRoute route      = new LinkGenerationRoute(innerRoute);

            Assert.NotNull(route.Defaults);
            Assert.Equal(innerRoute.Defaults, route.Defaults);

            Assert.NotNull(route.Constraints);
            Assert.Equal(innerRoute.Constraints, route.Constraints);

            Assert.NotNull(route.DataTokens);
            Assert.Equal(innerRoute.DataTokens, route.DataTokens);

            Assert.NotNull(innerRoute.Handler);
            Assert.Null(route.Handler);

            Assert.NotNull(route.RouteTemplate);
            Assert.Equal(innerRoute.RouteTemplate, route.RouteTemplate);
        }
        public void GenerateRoute_ForwardsInnerProperties()
        {
            IHttpRoute innerRoute = new InnerRoute();
            LinkGenerationRoute route = new LinkGenerationRoute(innerRoute);

            Assert.NotNull(route.Defaults);
            Assert.Equal(innerRoute.Defaults, route.Defaults);

            Assert.NotNull(route.Constraints);
            Assert.Equal(innerRoute.Constraints, route.Constraints);

            Assert.NotNull(route.DataTokens);
            Assert.Equal(innerRoute.DataTokens, route.DataTokens);

            Assert.NotNull(innerRoute.Handler);
            Assert.Null(route.Handler);

            Assert.NotNull(route.RouteTemplate);
            Assert.Equal(innerRoute.RouteTemplate, route.RouteTemplate);
        }