예제 #1
0
 /// <summary>
 /// This method clears the request builder, so it can be used to build a new request.
 /// </summary>
 public void Clear()
 {
     _httpHeaders.Clear();
     _httpMethod      = null;
     _target          = null;
     _httpVersion     = null;
     _httpMessageBody = new HttpMessageBody();
 }
예제 #2
0
        public void HasBody_NoBody_ReturnsFalse()
        {
            // Arrange
            var messageBody = new HttpMessageBody();

            // Assert
            Assert.IsFalse(messageBody.HasBody);
        }
예제 #3
0
        public void AddContentChunk_GivenNull_ThrowsArgumentNullException()
        {
            // Arrange
            var messageBody = new HttpMessageBody();

            // Act & Assert
            Assert.ThrowsException <ArgumentNullException>(() => messageBody.AddContentChunk(null));
        }
예제 #4
0
        public void GetContentStringEncoding_GivenNull_ThrowsArgumentNullException()
        {
            // Arrage
            var messageBody = new HttpMessageBody();

            // Act & Assert
            Assert.ThrowsException <ArgumentNullException>(() => messageBody.GetContentString(null));
        }
예제 #5
0
        public void Count_SetContentToListOfZeroElements_Returns0()
        {
            // Arrange
            var messageBody = new HttpMessageBody();

            // Act
            messageBody.SetContent(new List <byte>());

            // Assert
            Assert.AreEqual(0, messageBody.Count);
        }
예제 #6
0
        public void HasBody_AddBody_ReturnsTrue()
        {
            // Arrange
            var messageBody = new HttpMessageBody();

            // Act
            messageBody.SetContent("AAA");

            // Assert
            Assert.IsTrue(messageBody.HasBody);
        }
예제 #7
0
        public void Count_SetContentToNull_Returns0()
        {
            // Arrange
            var messageBody = new HttpMessageBody();

            // Act
            messageBody.SetContent((List <byte>)null);

            // Assert
            Assert.AreEqual(0, messageBody.Count);
        }
예제 #8
0
        public void GetContentString_SetContentToString_ReturnsTheSameString()
        {
            // Arrange
            var          messageBody = new HttpMessageBody();
            const string content     = "467y4higifgerhtthąśććąę123123";

            // Act
            messageBody.SetContent(content);

            // Assert
            Assert.AreEqual(content, messageBody.GetContentString());
        }
예제 #9
0
        public void AddContentChunk_EmptyMessageBodyAndGivenSomeData_ContentIsTheSame()
        {
            // Arrange
            var messageBody = new HttpMessageBody();
            var content     = new List <byte> {
                0x41, 0x41, 0x41, 0x41
            };

            // Act
            messageBody.AddContentChunk(content);

            // Assert
            CollectionAssert.AreEqual(content, messageBody.GetContent());
        }
예제 #10
0
        public void AddContentChunk_AddTwoChunks_GetContentReturnsCombinedContent()
        {
            // Arrange
            var messageBody = new HttpMessageBody();
            var content     = new List <byte> {
                0x41, 0x41, 0x41, 0x41
            };

            messageBody.AddContentChunk(content);

            // Act
            messageBody.AddContentChunk(content);

            // Assert
            content.AddRange(content);
            CollectionAssert.AreEqual(content, messageBody.GetContent());
        }
예제 #11
0
        public void GetContent_SetContentToASequenceOfBytes_ReturnsTheSameList()
        {
            // Arrange
            var messageBody = new HttpMessageBody();
            var bytes       = new List <byte>
            {
                45,
                67,
                82,
                16,
                0,
                255
            };

            // Act
            messageBody.SetContent(bytes);

            // Assert
            CollectionAssert.AreEqual(bytes, messageBody.GetContent());
        }
예제 #12
0
        public void Count_SetContentToListOfBytes_ReturnsTheSizeOfTheList()
        {
            // Arrange
            var messageBody = new HttpMessageBody();
            var bytes       = new List <byte>
            {
                45,
                67,
                82,
                16,
                0,
                255
            };

            // Act
            messageBody.SetContent(bytes);

            // Assert
            Assert.AreEqual(bytes.Count, messageBody.Count);
        }