Example #1
0
        public void RequestUriInvalid()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            Assert.Throws <UriFormatException>(() => builder.BaseUri("/api/").AppendPath("v1"));
        }
Example #2
0
        public void RequestUriNoBasePath()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            builder.AppendPath("http://test.com/api/v1");

            Assert.Throws <FluentException>(() => request.RequestUri());
        }
        public void AppendPathWithoutTrailingSlash()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            builder.BaseUri("http://test.com/api").AppendPath("v1");

            var url = request.RequestUri();

            Assert.Equal("http://test.com/api/v1", url.ToString());
        }
Example #4
0
        public void AppendPathWithTrailingSlash()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            builder.BaseUri("http://test.com/api/").AppendPath("v1");

            var url = request.RequestUri();

            Assert.Equal("http://test.com/api/v1", url.ToString());
        }
        public void HeaderSingleValue()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            builder.BaseUri("http://test.com/");
            builder.Header("Test", "Test");

            Assert.True(builder.Request.Headers.ContainsKey("Test"));
            Assert.True(builder.Request.Headers["Test"].First() == "Test");
        }
Example #6
0
        public void HeaderSingleValue()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            builder.BaseUri("http://test.com/");
            builder.Header("Test", "Test");

            Assert.True(builder.Request.Headers.ContainsKey("Test"));
            Assert.True(builder.Request.Headers["Test"].First() == "Test");
        }
        public void QueryStringFullUri()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            builder.FullUri("http://test.com/path?q=testing&size=10");


            Assert.Equal("http://test.com/path", request.BaseUri.ToString());
            Assert.Equal(2, request.QueryString.Count);
            Assert.Equal("testing", request.QueryString["q"].FirstOrDefault());
        }
Example #8
0
        public void QueryStringFullUri()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            builder.FullUri("http://test.com/path?q=testing&size=10");


            Assert.Equal("http://test.com/path", request.BaseUri.ToString());
            Assert.Equal(2, request.QueryString.Count);
            Assert.Equal("testing", request.QueryString["q"].FirstOrDefault());
        }
Example #9
0
        public void RequestUriInvalidUri()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);
            var baseUri = new Uri("/api", UriKind.Relative);

            Assert.Throws <UriFormatException>(() =>
            {
                builder.BaseUri(baseUri).AppendPath("v1");
                var uri = request.RequestUri();
            });
        }
        public void QueryStringMultipleValue()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            builder.BaseUri("http://test.com/");
            builder.QueryString("Test", "Test1");
            builder.QueryString("Test", "Test2");

            var uri = request.RequestUri();

            Assert.Equal("http://test.com/?Test=Test1&Test=Test2", uri.ToString());
        }
        public void QueryStringNull()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            string value = null;
            builder.BaseUri("http://test.com/");
            builder.QueryString("Test", value);

            var uri = request.RequestUri();

            Assert.Equal("http://test.com/?Test=", uri.ToString());
        }
Example #12
0
        public void QueryStringMultipleValue()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            builder.BaseUri("http://test.com/");
            builder.QueryString("Test", "Test1");
            builder.QueryString("Test", "Test2");

            var uri = request.RequestUri();

            Assert.Equal("http://test.com/?Test=Test1&Test=Test2", uri.ToString());
        }
Example #13
0
        public void QueryStringNull()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            string value = null;

            builder.BaseUri("http://test.com/");
            builder.QueryString("Test", value);

            var uri = request.RequestUri();

            Assert.Equal("http://test.com/?Test=", uri.ToString());
        }
        public void HeaderNullValue()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            string value = null;
            builder.BaseUri("http://test.com/");
            builder.Header("Test", "Test");

            Assert.True(builder.Request.Headers.ContainsKey("Test"));

            builder.Header("Test", value);
            Assert.False(builder.Request.Headers.ContainsKey("Test"));
        }
Example #15
0
        public void HeaderNullValue()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            string value = null;

            builder.BaseUri("http://test.com/");
            builder.Header("Test", "Test");

            Assert.True(builder.Request.Headers.ContainsKey("Test"));

            builder.Header("Test", value);
            Assert.False(builder.Request.Headers.ContainsKey("Test"));
        }
        public void RequestUriInvalidUri()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);
            var baseUri = new Uri("/api", UriKind.Relative);

            Assert.Throws<UriFormatException>(() =>
            {
                builder.BaseUri(baseUri).AppendPath("v1");
                var uri = request.RequestUri();
            });
        }
        public void RequestUriInvalid()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            Assert.Throws<UriFormatException>(() => builder.BaseUri("/api/").AppendPath("v1"));
        }
        public void RequestUriNoBasePath()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            builder.AppendPath("http://test.com/api/v1");

            Assert.Throws<FluentException>(() => request.RequestUri());
        }
 private string GetBodyOfRequest(FluentRequest request)
 {
     return(request.Request.Content.ReadAsStringAsync().Result);
 }
Example #20
0
 private string GetUri(FluentRequest request)
 {
     return(request.Request.RequestUri.AbsoluteUri);
 }
 private string GetContentType(FluentRequest request)
 {
     return(request.Request.Content.Headers.ContentType.MediaType);
 }