public void add_parameters_should_add_parameter_for_url_segment() { // arrange var reader = new UrlSegmentApiVersionReader(); var context = new Mock <IApiVersionParameterDescriptionContext>(); context.Setup(c => c.AddParameter(It.IsAny <string>(), It.IsAny <ApiVersionParameterLocation>())); // act reader.AddParmeters(context.Object); // assert context.Verify(c => c.AddParameter(null, Path), Times.Once()); }
public void read_should_retrieve_version_from_url() { // arrange var requestedVersion = "2"; var configuration = NewConfiguration(); var request = new HttpRequestMessage(Get, $"http://localhost/api/v{requestedVersion}/test"); var reader = new UrlSegmentApiVersionReader(); configuration.EnsureInitialized(); var routeData = configuration.Routes.GetRouteData(request); request.SetConfiguration(configuration); request.SetRouteData(routeData); // act var version = reader.Read(request); // assert version.Should().Be(requestedVersion); }