public void GenerateRoute_DoesNotClaimData()
        {
            GenerateRoute route = new GenerateRoute(new NotImplementedRoute());

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

            Assert.Null(data);
        }
        public void GenerateRoute_EmptyProperties()
        {
            GenerateRoute route = new GenerateRoute(new NotImplementedRoute());

            AssertDictionaryIsEmptyAndImmutable(route.Defaults);
            AssertDictionaryIsEmptyAndImmutable(route.Constraints);
            AssertDictionaryIsEmptyAndImmutable(route.DataTokens);
            Assert.Equal(null, route.Handler);
            Assert.Equal(string.Empty, route.RouteTemplate);
        }
        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);

            GenerateRoute route = new GenerateRoute(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 destRoutes, HttpRouteCollection sourceRoutes)
 {
     foreach (KeyValuePair<string, IHttpRoute> kv in sourceRoutes.GetRoutesWithNames())
     {
         string name = kv.Key;
         IHttpRoute route = kv.Value;
         var stubRoute = new GenerateRoute(route);
         destRoutes.Add(name, stubRoute);
     }
 }