示例#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!"));
        }
示例#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));
        }
示例#3
0
        public void AsText_WithSimpleString_ShouldReturnAResponseWithStatusCodeOk()
        {
            var response = new TextResponse("Hello, world!");

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

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