public void Should_return_data() { var requestData = new RequestData { HttpMethod = HttpMethod.Get, Endpoint = "testpath", }; var routeParamsSubstitutor = new RouteParamsSubstitutor(_apiUri); var result = routeParamsSubstitutor.SubstituteParamsInRequest(requestData); Assert.That(result, Is.Not.Null); Assert.That(result.AbsoluteUrl, Is.Not.Empty); Assert.That(result.Parameters, Is.Not.Null); }
public void Should_handle_dashes_and_numbers() { var requestData = new RequestData { Endpoint = "something/{route-66}", Parameters = new Dictionary <string, string> { { "route-66", "routevalue" } } }; var routeParamsSubstitutor = new RouteParamsSubstitutor(_apiUri); var result = routeParamsSubstitutor.SubstituteParamsInRequest(requestData); Assert.That(result.AbsoluteUrl, Is.StringContaining("something/routevalue")); }
public void Routes_should_be_case_insensitive() { var requestData = new RequestData { Endpoint = "something/{firstRoUte}/{secOndrouTe}/thrid/{tHirdRoute}", Parameters = new Dictionary <string, string> { { "firstRoute", "firstValue" }, { "secondRoute", "secondValue" }, { "thirdRoute", "thirdValue" } } }; var routeParamsSubstitutor = new RouteParamsSubstitutor(_apiUri); var result = routeParamsSubstitutor.SubstituteParamsInRequest(requestData); Assert.That(result.AbsoluteUrl, Is.StringContaining("something/firstvalue/secondvalue/thrid/thirdvalue")); }
public void Should_substitue_multiple_route_parameters() { var requestData = new RequestData { Endpoint = "something/{firstRoute}/{secondRoute}/thrid/{thirdRoute}", Parameters = new Dictionary <string, string> { { "firstRoute", "firstValue" }, { "secondRoute", "secondValue" }, { "thirdRoute", "thirdValue" } } }; var routeParamsSubstitutor = new RouteParamsSubstitutor(_apiUri); var result = routeParamsSubstitutor.SubstituteParamsInRequest(requestData); Assert.That(result.AbsoluteUrl, Is.StringContaining("something/firstvalue/secondvalue/thrid/thirdvalue")); }
public void Should_remove_parameters_that_match() { var requestData = new RequestData { Endpoint = "something/{route}", Parameters = new Dictionary <string, string> { { "route", "routevalue" }, { "foo", "bar" } } }; var routeParamsSubstitutor = new RouteParamsSubstitutor(_apiUri); var result = routeParamsSubstitutor.SubstituteParamsInRequest(requestData); Assert.That(result.Parameters.ContainsKey("route"), Is.False); Assert.That(result.Parameters.ContainsKey("foo"), Is.True); }
public void Should_remove_multiple_parameters_that_match() { var requestData = new RequestData { Endpoint = "something/{firstRoute}/{secondRoute}/thrid/{thirdRoute}", Parameters = new Dictionary <string, string> { { "firstRoute", "firstValue" }, { "secondRoute", "secondValue" }, { "thirdRoute", "thirdValue" }, { "foo", "bar" }, } }; var routeParamsSubstitutor = new RouteParamsSubstitutor(_apiUri); var result = routeParamsSubstitutor.SubstituteParamsInRequest(requestData); Assert.That(result.Parameters.ContainsKey("firstRoute"), Is.False); Assert.That(result.Parameters.ContainsKey("secondRoute"), Is.False); Assert.That(result.Parameters.ContainsKey("thirdRoute"), Is.False); Assert.That(result.Parameters.ContainsKey("foo"), Is.True); }