Created
September 26, 2012 16:28
-
-
Save mwrock/3789014 to your computer and use it in GitHub Desktop.
Testing UrlHelper.Route
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This is test setup | |
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; | |
//line being tested | |
return service.GetFeatureInformation(RequestContext).Select(x => new FeatureFlag(x.Name, x.Description, baseUri + Url.Route("FeatureAvailability", new { id = x.Name }), x.AvailabilityState.ToString())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment