Skip to content

Instantly share code, notes, and snippets.

@mwrock
Created September 26, 2012 16:26
Show Gist options
  • Save mwrock/3789000 to your computer and use it in GitHub Desktop.
Save mwrock/3789000 to your computer and use it in GitHub Desktop.
Testing UrlHelper.Route
var mockTeamFoundationFeatureAvailabilityService = new Mock<ITeamFoundationFeatureAvailabilityService>();
var testable = new ApiFeatureAvailabilityController(x => mockTeamFoundationFeatureAvailabilityService.Object);
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost:8080/path");
var config = new HttpConfiguration();
config.Routes.MapHttpRoute("FeatureAvailability", "path/{id}", new { Controller = "ApiFeatureAvailability", id = RouteParameter.Optional });
request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
request.Properties[HttpPropertyKeys.HttpRouteDataKey] = config.Routes.GetRouteData(request);
testable.Url = new UrlHelper(request);
testable.Request = request;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment