public void GenerateRoute_DoesNotClaimData() { GenerationRoute route = new GenerationRoute(new NotImplementedRoute()); IHttpRouteData data = route.GetRouteData(string.Empty, new HttpRequestMessage()); Assert.Null(data); }
public void GenerateRoute_EmptyProperties() { GenerationRoute route = new GenerationRoute(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); GenerationRoute route = new GenerationRoute(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 <HttpRouteEntry> entries) { Contract.Assert(entries != null); foreach (HttpRouteEntry entry in entries) { Contract.Assert(entry != null); string name = entry.Name; if (name != null) { IHttpRoute route = entry.Route; Contract.Assert(route != null); IHttpRoute generationRoute = new GenerationRoute(route); routeTable.Add(name, generationRoute); } } }