コード例 #1
0
 public static void AppendToQuery(this DocflowFilter filter, RequestUrlBuilder urlBuilder)
 {
     foreach (var(name, value) in filter.ToQueryParameters())
     {
         urlBuilder.AppendToQuery(name, value);
     }
 }
コード例 #2
0
        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=");
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        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();
        }