GetRouteData() public méthode

Gets the route data from an incoming request; parses the incoming virtual path and returns the route data that was inside the url.
public GetRouteData ( System.Web.HttpContextBase httpContext ) : System.Web.Routing.RouteData
httpContext System.Web.HttpContextBase The HTTP context containing the url data.
Résultat System.Web.Routing.RouteData
		public void ShouldNotBeNullIfRouteIsMatched()
		{
			var route = new RegexRoute("asdf", handler);
			RouteData routeData = route.GetRouteData("asdf");
			Assert.AreSame(handler, routeData.RouteHandler);
			Assert.IsNotNull(routeData, "routeData should not be null if the path matched the regex");
		}
		public void ShouldHaveMatchedPairIfValueFound()
		{
			var route = new RegexRoute(@"(?<Controller>[a-zA-Z]+)_((?<Action>[a-zA-Z]+)_)?(?<Id>\d+)?", handler);
			RouteData routeData = route.GetRouteData("Products_View_0");
			Assert.AreSame(handler, routeData.RouteHandler);
			Assert.AreEqual("Products", routeData.Values["Controller"]);
			Assert.AreEqual("View", routeData.Values["Action"]);
			Assert.AreEqual("0", routeData.Values["Id"]);
		}
		public void ShouldHaveDefaultValuesIfPairFoundButDoesNotMatchAnything()
		{
			var defaults = new RouteValueDictionary(new {a = "A"});
			var route = new RegexRoute("asdf", defaults, handler);
			RouteData routeData = route.GetRouteData("asdf");
			Assert.AreSame(handler, routeData.RouteHandler);
			Assert.IsNotNull(routeData, "routeData should not be null if the path matched the regex");
			Assert.IsTrue(routeData.Values.ContainsKey("a"));
			Assert.AreEqual("A", routeData.Values["a"], "if the match failed, the value should be default");
		}
 public void RouteGeneratorCallsCustomFunctionIfProvided()
 {
     bool called = false;
     RequestContext innerContext = null;
     RouteValueDictionary innerRouteValues = null;
     RegexRoute innerRoute = null;
     VirtualPathData innerPathData = null;
     var route = new RegexRoute(
         @"(?<Controller>[a-zA-Z]+)(_(?<Action>[a-zA-Z]+))?(_?<Id>\d+)?",
         delegate(RequestContext context, RouteValueDictionary routeValues, RegexRoute thisRoute)
             {
                 called = true;
                 innerContext = context;
                 innerRouteValues = routeValues;
                 innerRoute = thisRoute;
                 innerPathData = new VirtualPathData(thisRoute, "");
                 return innerPathData;
             },
         handler);
     RouteData routeData = route.GetRouteData("Products_View_0");
     var values = new RouteValueDictionary(new {Controller = "Accounts", Action = "Delete", Id = 0});
     var requestContext = new RequestContext(mr.PartialMock<HttpContextBase>(), routeData);
     VirtualPathData pathData = route.GetVirtualPath(
         requestContext,
         values);
     Assert.IsTrue(called);
     Assert.IsNotNull(innerContext);
     Assert.AreSame(requestContext, innerContext);
     Assert.IsNotNull(innerRouteValues);
     Assert.AreSame(values, innerRouteValues);
     Assert.IsNotNull(innerRoute);
     Assert.AreSame(route, innerRoute);
     Assert.IsNotNull(pathData);
     Assert.AreSame(pathData, innerPathData);
 }
 public void ShouldReturnNullIfRouteIsNotMatched()
 {
     var route = new RegexRoute("asdf", handler);
     RouteData routeData = route.GetRouteData("fdsa");
     Assert.IsNull(routeData, "routedata should be null if the path didn't match");
 }
 public void RouteGeneratorReturnsNullWhenNotAllParametersFilledIn()
 {
     var route = new RegexRoute(@"(?<Controller>[a-zA-Z]+)(_(?<Action>[a-zA-Z]+))?(_?<Id>\d+)?",
                                "{Controller}_{Action}_{Id}", handler);
     RouteData routeData = route.GetRouteData("Products_View_0");
     VirtualPathData pathData = route.GetVirtualPath(new RequestContext(mr.PartialMock<HttpContextBase>(), routeData),
                                                     new RouteValueDictionary(
                                                         new {Controller = "Accounts", Action = "Delete"}));
     Assert.IsNull(pathData);
 }
 public void RouteGeneratorGeneratesValidRouteWithoutDefaults()
 {
     var route = new RegexRoute(@"(?<Controller>[a-zA-Z]+)(_(?<Action>[a-zA-Z]+))?(_?<Id>\d+)?",
                                "{Controller}_{Action}_{Id}", handler);
     RouteData routeData = route.GetRouteData("Products_View_0");
     VirtualPathData pathData = route.GetVirtualPath(new RequestContext(mr.PartialMock<HttpContextBase>(), routeData),
                                                     new RouteValueDictionary(
                                                         new {Controller = "Accounts", Action = "Delete", Id = 0}));
     Assert.AreEqual("Accounts_Delete_0", pathData.VirtualPath);
 }