GetBody() public method

Gets the bytes for the HTTP body.
public GetBody ( ) : byte[]
return byte[]
Esempio n. 1
0
        public void ClearBody_WhenCalled_RemovedAllBytes()
        {
            var newBytes = new byte[5]
            {
                1, 2, 3, 4, 5
            };

            var response = new BasicHttpResponse();

            response.AppendToBody(newBytes);
            response.ClearBody();
            Assert.AreEqual(0, response.BodyLength);
            var bodyBytes = response.GetBody();

            Assert.IsNotNull(bodyBytes);
            Assert.AreEqual(0, bodyBytes.Length);
        }
Esempio n. 2
0
        public void AppendToBody_WithAdditionalBytes_AppendsToEnd()
        {
            var newBytes = new byte[5]
            {
                1, 2, 3, 4, 5
            };

            var expected = new byte[10]
            {
                1, 2, 3, 4, 5, 1, 2, 3, 4, 5
            };

            var response = new BasicHttpResponse();
            response.AppendToBody(newBytes);
            response.AppendToBody(newBytes);
            Assert.AreEqual(10, response.BodyLength);
            CollectionAssert.AreEqual(expected, response.GetBody());
        }
Esempio n. 3
0
        public void AppendToBody_WithAdditionalBytes_AppendsToEnd()
        {
            var newBytes = new byte[5]
            {
                1, 2, 3, 4, 5
            };

            var expected = new byte[10]
            {
                1, 2, 3, 4, 5, 1, 2, 3, 4, 5
            };

            var response = new BasicHttpResponse();

            response.AppendToBody(newBytes);
            response.AppendToBody(newBytes);
            Assert.AreEqual(10, response.BodyLength);
            CollectionAssert.AreEqual(expected, response.GetBody());
        }
Esempio n. 4
0
        public void ClearBody_WhenCalled_RemovedAllBytes()
        {
            var newBytes = new byte[5]
            {
                1, 2, 3, 4, 5
            };

            var response = new BasicHttpResponse();
            response.AppendToBody(newBytes);
            response.ClearBody();
            Assert.AreEqual(0, response.BodyLength);
            var bodyBytes = response.GetBody();
            Assert.IsNotNull(bodyBytes);
            Assert.AreEqual(0, bodyBytes.Length);
        }