public void read_should_retrieve_version_from_url() { // arrange var requestedVersion = "2"; var request = RequestAfterApiVersionConstraintHasBeenMatched(requestedVersion); var reader = new UrlSegmentApiVersionReader(); // act var version = reader.Read(request); // assert version.Should().Be(requestedVersion); }
public void read_should_retrieve_version_from_url() { // arrange var requestedVersion = "2"; var constraint = new ApiVersionRouteConstraint(); var reader = new UrlSegmentApiVersionReader(); var request = RequestAfterApiVersionConstraintHasBeenMatched(requestedVersion, reader); var httpContext = request.HttpContext; var route = default(IRouter); var routeData = ((RoutingFeature)httpContext.Features[typeof(IRoutingFeature)]).RouteData; constraint.Match(httpContext, route, "version", routeData.Values, IncomingRequest); // act var version = reader.Read(request); // assert version.Should().Be(requestedVersion); }