public static void AppendToQuery(this DocflowFilter filter, RequestUrlBuilder urlBuilder) { foreach (var(name, value) in filter.ToQueryParameters()) { urlBuilder.AppendToQuery(name, value); } }
public void Should_add_empty_query_values_if_requested_to() { var builder = new RequestUrlBuilder("http://foo"); builder.AppendToQuery("key", string.Empty, true); builder.Build().Query.Should().Be("?key="); }
public void Should_not_add_empty_query_values_by_default() { var builder = new RequestUrlBuilder("http://foo"); builder.AppendToQuery("key", string.Empty); builder.Build().Query.Should().BeEmpty(); }
public void Should_not_allow_to_append_to_path_after_appending_to_query() { var builder = new RequestUrlBuilder(); builder.AppendToPath("foo/"); builder.AppendToQuery("key", "value"); Action action = () => builder.AppendToPath("bar"); action.Should().Throw <InvalidOperationException>().Which.ShouldBePrinted(); }
private static Uri GetFullUri(string uriPath, Dictionary <string, object> uriQueryParams) { var urlBuilder = new RequestUrlBuilder(uriPath); if (uriQueryParams != null) { foreach (var queryParam in uriQueryParams) { urlBuilder.AppendToQuery(queryParam.Key, queryParam.Value); } } return(urlBuilder.Build()); }
public void Should_not_be_usable_after_producing_an_url() { var builder = new RequestUrlBuilder { "foo/", "bar/", "baz" }; builder.Build(); Action pathAppend = () => builder.AppendToPath("123"); Action queryAppend = () => builder.AppendToQuery("123", "456"); pathAppend.Should().Throw <ObjectDisposedException>().Which.ShouldBePrinted(); queryAppend.Should().Throw <ObjectDisposedException>().Which.ShouldBePrinted(); }