Exemplo n.º 1
0
        public void SetMethod_GivenMethod_ReturnsTheSameMethod(HttpMethodType httpMethodType)
        {
            // Act
            var request = _requestBuilder
                          .SetMethod(httpMethodType)
                          .SetTarget(UniformResourceIdentifier.FromString("/index.html"))
                          .SetHttpVersion(HttpVersionType.Http1_1)
                          .SetHeader("Host", "example.com")
                          .SetBody("Hello World!", Encoding.Default)
                          .Build();

            // Assert
            Assert.AreEqual(httpMethodType, request.Method);
        }
Exemplo n.º 2
0
        public void RequestGetHeader_GetNonExistingHeader_ReturnsNull()
        {
            // Act
            var request = _requestBuilder
                          .SetMethod(HttpMethodType.Connect)
                          .SetTarget(UniformResourceIdentifier.FromString("/index.html"))
                          .SetHttpVersion(HttpVersionType.Http1_1)
                          .SetHeader("Host", "example.com")
                          .SetBody("Hello World!", Encoding.Default)
                          .Build();

            // Arrange
            Assert.IsNull(request.GetHeader("NonExistingField"));
        }
Exemplo n.º 3
0
        public void Build_ValidProperties_ReturnsIRequest()
        {
            // Act
            var request = _requestBuilder
                          .SetMethod(HttpMethodType.Get)
                          .SetTarget(UniformResourceIdentifier.FromString("/index.html"))
                          .SetHttpVersion(HttpVersionType.Http1_1)
                          .SetHeader("Host", "example.com")
                          .SetBody("Hello World!", Encoding.Default)
                          .Build();

            // Assert
            Assert.IsNotNull(request);
        }
Exemplo n.º 4
0
        public void SetHeader_AddValidHeader_ReturnsTheSameHeader(string fieldName, string fieldValue)
        {
            // Act
            var request = _requestBuilder
                          .SetMethod(HttpMethodType.Connect)
                          .SetTarget(UniformResourceIdentifier.FromString("/index.html"))
                          .SetHttpVersion(HttpVersionType.Http1_1)
                          .SetHeader(fieldName, fieldValue)
                          .SetBody("Hello World!", Encoding.Default)
                          .Build();

            // Assert
            Assert.AreEqual(fieldValue, request.GetHeader(fieldName));
        }
Exemplo n.º 5
0
        public void Target_SetsTarget_ReturnsTheSameTarget()
        {
            // Arrange
            var uri = UniformResourceIdentifier.FromString("/index.html");

            // Act
            var request = _requestBuilder
                          .SetMethod(HttpMethodType.Connect)
                          .SetTarget(uri)
                          .SetHttpVersion(HttpVersionType.Http1_1)
                          .SetHeader("Host", "example.com")
                          .SetBody("Hello World!", Encoding.Default)
                          .Build();

            // Assert
            Assert.AreEqual(uri, request.Target);
        }