/// <summary> /// Performs a verification on the <paramref name="mockUrlHelper"/> that it has recieved an invocation matching that which would be generated by <see cref="UrlHelperExtensions.RouteUrl(IUrlHelper, string, object)"/>. /// </summary> /// <typeparam name="TRouteValues">The type of route values being provided as the comparand for invocation verification request.</typeparam> /// <param name="mockUrlHelper">The mock to add the invocation setup to.</param>> /// <param name="routeName">The name of the route that invocations must match.</param> /// <param name="routeValues">The route values that invocations must match.</param> /// <param name="times">The number of times the invocation must match in order for the verification to pass.</param> public static void VerifyRouteUrl <TRouteValues>(this Mock <IUrlHelper> mockUrlHelper, string routeName, TRouteValues routeValues, Times times) { var urlRouteContextPredicateExpression = UrlRouteContextPredicateLambdaExpressionFactory.Create <TRouteValues>(routeName, routeValues); mockUrlHelper.VerifyRouteUrl(urlRouteContextPredicateExpression, times); }
/// <summary> /// Adds an invocation setup to <paramref name="mockUrlHelper"/> to match an invocation that would be generated by <see cref="UrlHelperExtensions.RouteUrl(IUrlHelper, string, object)"/>. /// </summary> /// <typeparam name="TRouteValues">The type of route values being provided as the comparand for invocation setup.</typeparam> /// <param name="mockUrlHelper">The mock to add the invocation setup to.</param> /// <param name="routeName">The name of the route that invocations must match.</param> /// <param name="routeValues">The route values that invocations must match.</param> /// <returns>Returns an <see cref="ISetup{IUrlHelper, string}"/> so that additional configuration calls can be chained.</returns> public static ISetup <IUrlHelper, string> SetupRouteUrl <TRouteValues>(this Mock <IUrlHelper> mockUrlHelper, string routeName, TRouteValues routeValues) { var urlRouteContextPredicateExpression = UrlRouteContextPredicateLambdaExpressionFactory.Create(routeName, routeValues); return(mockUrlHelper.SetupRouteUrl(urlRouteContextPredicateExpression)); }