Example #1
0
        public void AsText_WithSimpleString_ShouldReturnAResponseWithContentsOfString()
        {
            var response = new TextResponse("Hello, world!");

            var stream = new MemoryStream();
            response.Contents.Invoke(stream);
            stream.Position = 0;
            var reader = new StreamReader(stream);
            var contents = reader.ReadToEnd();

            Assert.That(contents, Is.EqualTo("Hello, world!"));
        }
Example #2
0
        public void AsText_WithStringFormat_ShouldReturnAResponseWithContentsOfFormattedString()
        {
            var date = DateTime.Now;
            var response = new TextResponse("Hello, {0} it's {1}", "Tom", date);

            var stream = new MemoryStream();
            response.Contents.Invoke(stream);
            stream.Position = 0;
            var reader = new StreamReader(stream);
            var contents = reader.ReadToEnd();

            Assert.That(contents, Is.EqualTo("Hello, Tom it's " + date));
        }
Example #3
0
        public void AsText_WithSimpleString_ShouldReturnAResponseWithStatusCodeOk()
        {
            var response = new TextResponse("Hello, world!");

            Assert.That(response.StatusCode, Is.EqualTo(200));
        }
Example #4
0
        public void AsText_WithSimpleString_ShouldReturnAResponseWithCorrectContentType()
        {
            var response = new TextResponse("Hello, world!");

            Assert.That(response.ContentType, Is.EqualTo("text/plain"));
        }