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_substitue_route_parameters() { var requestData = new RequestData { Endpoint = "something/{route}", Parameters = new Dictionary<string, string> { {"route","routevalue"} } }; var routeParamsSubstitutor = new RouteParamsSubstitutor(_apiUri); var result = routeParamsSubstitutor.SubstituteParamsInRequest(requestData); Assert.That(result.AbsoluteUrl, Is.StringContaining("something/routevalue")); }
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 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_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); }
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 RequestBuilder(IApiUri apiUri, IOAuthCredentials oAuthCredentials) { _oAuthCredentials = oAuthCredentials; _routeParamsSubstitutor = new RouteParamsSubstitutor(apiUri); }
public void Domain_should_be_case_insensitive_routes_should_be_case_sensitive() { var requestData = new RequestData { Endpoint = "someThing/{firstRoUte}/{secOndrouTe}/third/{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.EqualTo("http://example.com/someThing/firstValue/secondValue/third/thirdValue")); }