Ejemplo n.º 1
0
        public void RequestUriInvalid()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            Assert.Throws <UriFormatException>(() => builder.BaseUri("/api/").AppendPath("v1"));
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 5
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");
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 7
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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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();
            });
        }
Ejemplo n.º 10
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());
        }
Ejemplo n.º 11
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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 14
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"));
        }
Ejemplo n.º 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"));
        }
Ejemplo n.º 16
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();
            });
        }
Ejemplo n.º 17
0
        public void RequestUriInvalid()
        {
            var request = new FluentRequest();
            var builder = new QueryBuilder(request);

            Assert.Throws<UriFormatException>(() => builder.BaseUri("/api/").AppendPath("v1"));
        }
Ejemplo n.º 18
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());
        }
Ejemplo n.º 19
0
 private string GetBodyOfRequest(FluentRequest request)
 {
     return(request.Request.Content.ReadAsStringAsync().Result);
 }
Ejemplo n.º 20
0
 private string GetUri(FluentRequest request)
 {
     return(request.Request.RequestUri.AbsoluteUri);
 }
Ejemplo n.º 21
0
 private string GetContentType(FluentRequest request)
 {
     return(request.Request.Content.Headers.ContentType.MediaType);
 }