public void try_expand_uri_parameters_should_handle_duplicateX2C_caseX2Dinsensitive_route_values() { // arrange var parameterDescriptorMock = new Mock <HttpParameterDescriptor>(); parameterDescriptorMock.SetupGet(p => p.ParameterType).Returns(typeof(ClassWithId)); var apiExplorer = new TestApiExplorer(new HttpConfiguration()); var descriptions = new List <ApiParameterDescription>() { new ApiParameterDescription() { Source = FromUri, Name = "id" }, new ApiParameterDescription() { Source = FromUri, ParameterDescriptor = parameterDescriptorMock.Object }, }; // act var expanded = apiExplorer.TryExpandUriParameters(new HttpRoute(), New.ParsedRoute, descriptions, out var expandedRouteTemplate); // assert expanded.Should().BeTrue(); expandedRouteTemplate.Should().Be("?id={id}"); }
public void try_expand_uri_parameters_should_expand_parameter(string expectedPath, Type parameterType, string parameterName) { // arrange var apiExplorer = new TestApiExplorer(new HttpConfiguration()); var descriptions = new List <ApiParameterDescription>() { CreateApiParameterDescription(parameterType, parameterName) }; // act var expanded = apiExplorer.TryExpandUriParameters(new HttpRoute(), New.ParsedRoute, descriptions, out var finalPath); // assert expanded.Should().BeTrue(); finalPath.Should().Be(expectedPath); }
public void try_expand_uri_parameters_should_expand_composite_parameters() { // arrange var apiExplorer = new TestApiExplorer(new HttpConfiguration()); var descriptions = new List <ApiParameterDescription>() { CreateApiParameterDescription(typeof(int[]), "id"), CreateApiParameterDescription(typeof(ICollection <string>), "property"), CreateApiParameterDescription(typeof(string), "name"), }; // act var expanded = apiExplorer.TryExpandUriParameters(new HttpRoute(), New.ParsedRoute, descriptions, out var finalPath); // assert expanded.Should().BeTrue(); finalPath.Should().Be("?id[0]={id[0]}&id[1]={id[1]}&property[0]={property[0]}&property[1]={property[1]}&name={name}"); }