GetBodyAsString() public method

Gets the body of the HTTP response as a T:System.String.
The body is decoded using UTF8 encoding.
public GetBodyAsString ( ) : string
return string
Esempio n. 1
0
        public void GetBody_WithNullEncoding_ThrowsException()
        {
            var response = new BasicHttpResponse();

            response.AppendToBody("ABCD");

            Assert.That(
                () => response.GetBodyAsString(null),
                Throws.Exception.TypeOf <ArgumentNullException>().With.Property("ParamName").EqualTo("encoding"));
        }
Esempio n. 2
0
        public void AppendToBody_WithAdditionalString_AppendsToEnd()
        {
            var newString = "ABCDE";

            var expectedString = "ABCDEABCDE";

            var response = new BasicHttpResponse();
            response.AppendToBody(newString);
            response.AppendToBody(newString);
            Assert.AreEqual(10, response.BodyLength);
            CollectionAssert.AreEqual(expectedString, response.GetBodyAsString());
        }
Esempio n. 3
0
        public void AppendToBody_WithAdditionalString_AppendsToEnd()
        {
            var newString = "ABCDE";

            var expectedString = "ABCDEABCDE";

            var response = new BasicHttpResponse();

            response.AppendToBody(newString);
            response.AppendToBody(newString);
            Assert.AreEqual(10, response.BodyLength);
            CollectionAssert.AreEqual(expectedString, response.GetBodyAsString());
        }
Esempio n. 4
0
        public void GetBody_WithNullEncoding_ThrowsException()
        {
            var response = new BasicHttpResponse();
            response.AppendToBody("ABCD");

            Assert.That(
                () => response.GetBodyAsString(null),
                Throws.Exception.TypeOf<ArgumentNullException>().With.Property("ParamName").EqualTo("encoding"));
        }