Ejemplo n.º 1
0
        public void Uri_ShouldReturnCorrectValue(
            [Frozen] Uri baseUri,
            HttpRequestBuilderOptions sut,
            string path,
            string path2,
            string key,
            string value)
        {
            //arrange
            //add reserved caracters to test escaping
            value += "?";
            key   += "=";
            path  += "?";
            path2 += "=";
            sut.AppendPath(path)
            .AppendPath(path2)
            .Parameter(key, value);

            //act
            var actual = sut.Uri;

            //assert
            var expected = string.Format("{0}/{1}/{2}?{3}={4}", baseUri.ToString().TrimEnd('/'), Uri.EscapeDataString(path), Uri.EscapeDataString(path2), Uri.EscapeDataString(key), Uri.EscapeDataString(value));

            actual.Should().Be(expected);
        }
Ejemplo n.º 2
0
        public void AppendPath_ShouldReturnSut(
            HttpRequestBuilderOptions sut,
            string expected)
        {
            //act
            var actual = sut.AppendPath(expected);

            //assert
            actual.Should().Be(sut);
        }
Ejemplo n.º 3
0
        public void PayloadParameter_ShouldReturnSut(
            HttpRequestBuilderOptions sut,
            string key,
            string value)
        {
            //act
            var actual = sut.PayloadParameter(key, value);

            //assert
            actual.Should().Be(sut);
        }
Ejemplo n.º 4
0
        public void AppendPath_WithEmptyStrings_ShouldThrow(
            string path,
            HttpRequestBuilderOptions sut
            )
        {
            //act
            Action action = () => sut.AppendPath(path);

            //assert
            action.ShouldThrow <ArgumentNullException>();
        }
Ejemplo n.º 5
0
        public void Method_ShouldSetMethod(
            HttpRequestBuilderOptions sut,
            HttpMethod method)
        {
            //arrange

            //act
            sut.Method(method);

            //assert
            sut.HttpMethod.Should().Be(method);
        }
Ejemplo n.º 6
0
        public void Method_WithUndefinedMethod_ShouldThrow(
            HttpRequestBuilderOptions sut)
        {
            //arrange
            var method = default(HttpMethod);

            //act
            Action action = () => sut.Method(method);

            //assert
            action.ShouldThrow <ArgumentException>();
        }
Ejemplo n.º 7
0
        public void PayloadParameter_WithEmptyKey_ShouldThrow(
            HttpRequestBuilderOptions sut,
            string value)
        {
            //arrange

            //act
            Action action = () => sut.PayloadParameter("", value);

            //assert
            action.ShouldThrow <ArgumentNullException>();
        }
Ejemplo n.º 8
0
        public void Method_ShouldReturnSut(
            HttpRequestBuilderOptions sut,
            HttpMethod method)
        {
            //arrange

            //act
            var actual = sut.Method(method);

            //assert
            actual.Should().Be(sut);
        }
Ejemplo n.º 9
0
        public void Header_ShouldReturnSut(
            HttpRequestBuilderOptions sut,
            string key,
            string value)
        {
            //arrange

            //act
            var actual = sut.Header(key, value);

            //assert
            actual.Should().Be(sut);
        }
Ejemplo n.º 10
0
        public void Header_ShouldAddHeader(
            HttpRequestBuilderOptions sut,
            string key,
            string value)
        {
            //arrange

            //act
            sut.Header(key, value);

            //assert
            sut.Headers.Should().Contain(new KeyValuePair <string, string>(key, value));
        }
Ejemplo n.º 11
0
        public void Cookie_ShouldAddCookie(
            HttpRequestBuilderOptions sut,
            Uri uri)
        {
            //arrange
            var cookie = new Cookie();

            //act
            sut.Cookie(uri, cookie);

            //assert
            sut.Cookies.Should().Contain(new Tuple <Uri, Cookie>(uri, cookie));
        }
Ejemplo n.º 12
0
        public void Cookie_ShouldReturnSut(
            HttpRequestBuilderOptions sut,
            Uri uri)
        {
            //arrange
            var cookie = new Cookie();

            //act
            var actual = sut.Cookie(uri, cookie);

            //assert
            actual.Should().Be(sut);
        }
Ejemplo n.º 13
0
        public void AppendPath_ShouldAddPath(
            HttpRequestBuilderOptions sut,
            string expected)
        {
            //arrange

            //act
            sut.AppendPath(expected);
            var actual = sut.PathFragments.Last();

            //assert
            actual.Should().Be(expected);
        }
Ejemplo n.º 14
0
        public void PayloadParameter_AddingSameKeyTwice_ShouldThrow(
            HttpRequestBuilderOptions sut,
            string key,
            string value)
        {
            //arrange
            sut.PayloadParameter(key, value);

            //act
            Action action = () => sut.PayloadParameter(key, value);

            //assert
            action.ShouldThrow <ArgumentException>();
        }
Ejemplo n.º 15
0
        public void ToRequest_ShouldReturnCorrectValue(
            HttpRequestBuilderOptions sut,
            Mock <IHttpRequestBuilder> requestBuilder,
            IHttpRequest request)
        {
            //arrange
            requestBuilder.Setup(b => b.BuildRequest(sut)).Returns(request);

            //act
            var actual = sut.ToRequest(requestBuilder.Object);

            //assert
            actual.Should().Be(request);
        }
Ejemplo n.º 16
0
        public void AppendPath_WithPathSeparator_ShouldAddCorrectPath(
            string path,
            string expectedPath,
            HttpRequestBuilderOptions sut
            )
        {
            //arrange

            //act
            sut.AppendPath(path);

            //assert
            var expected = expectedPath.Split('/');

            sut.PathFragments.ShouldAllBeEquivalentTo(expected);
        }
Ejemplo n.º 17
0
        public void Uri_WithNoParameters_ShouldReturnCorrectValue(
            [Frozen] Uri baseUri,
            HttpRequestBuilderOptions sut,
            string path,
            string path2)
        {
            //arrange
            sut.AppendPath(path)
            .AppendPath(path2);

            //act
            var actual = sut.Uri;

            //assert
            var expected = string.Format("{0}/{1}/{2}", baseUri.ToString().TrimEnd('/'), path, path2);

            actual.Should().Be(expected);
        }
Ejemplo n.º 18
0
 public void Sut_ShouldBeHttpRequestMethodBuilder(
     HttpRequestBuilderOptions sut)
 {
     sut.Should().BeAssignableTo <IHttpRequestMethodBuilder>();
 }
Ejemplo n.º 19
0
 public void BaseUri_ShouldReturnCorrectValue(
     [Frozen] Uri expected,
     HttpRequestBuilderOptions sut)
 {
     sut.BaseUri.Should().Be(expected);
 }