private void RunTest() { var @params = GetParams(); var route = new ElasticRoute(@params.Pattern, routeHandler: routeHandler, constraints: @params.Constraints, incomingDefaults: @params.Defaults); request.SetupGet(r => r.AppRelativeCurrentExecutionFilePath).Returns("~/" + @params.Url); var data = route.GetRouteData(context.Object); if ([email protected]) { Assert.IsNull(data); } else { Assert.IsNotNull(data); foreach (var entry in @params.RouteValues) { var strValue = (string)entry.Value; var actual = (string)data.Values[entry.Key]; if (strValue == string.Empty) { Assert.IsNull(actual); } else { Assert.AreEqual(strValue, actual); } } } }
/// <summary> /// Adds a new <see cref="ElasticRoute"/> to the collection. /// </summary> /// <param name="routes">The routes collection.</param> /// <param name="routeName">Name of the route to be registered as.</param> /// <param name="url">The URL pattern.</param> /// <param name="routeHandler">The route handler.</param> /// <param name="constraints">The route values constraints.</param> /// <param name="incomingDefaults">The incoming default route values.</param> /// <param name="outgoingDefaults">The outgoing default route values.</param> /// <param name="projections">The route values projections.</param> /// <param name="dataTokens">The data tokens.</param> public static void Map(this NamedRouteCollection <ElasticRoute> routes, string routeName, string url, IRouteHandler routeHandler, object constraints = null, object incomingDefaults = null, object outgoingDefaults = null, object projections = null, object dataTokens = null) { var route = new ElasticRoute(url, routeHandler: routeHandler, constraints: constraints, incomingDefaults: incomingDefaults, outgoingDefaults: outgoingDefaults, projections: projections, dataTokens: dataTokens); routes.Add(routeName, route); }
private void RunTest() { var @params = GetParams(); var route = new ElasticRoute(@params.Pattern, routeHandler: routeHandler, constraints: @params.Constraints, outgoingDefaults: @params.Defaults); var path = route.GetVirtualPath(requestContext, @params.RouteValues); if (@params.Result) { Assert.IsNotNull(path); Assert.AreEqual(@params.Url, path.VirtualPath); } else { Assert.IsNull(path); } }
/// <summary> /// Initializes a new instance of the <see cref="RouteWrapper"/> class. /// </summary> /// <param name="route">The original route.</param> public RouteWrapper(ElasticRoute route) : base(null, route.RouteHandler) { this.OriginalRoute = route; }