Ejemplo n.º 1
0
        public void Handle_InvalidContent_ReturnsErrorMessage()
        {
            Request   simpleRequest = new Request(MyRequestHelper.GetValidRequestStream("/toLower", method: "POST", body: "text="));
            IResponse result        = _ToLowerPlugin.Handle(simpleRequest);

            Assert.AreEqual(result.ContentLength, "Bitte geben Sie einen Text ein.".Length);
        }
        public void Response_Should_Return_Type_Html()
        {
            var           stream = new RequestStream().ValidRequest("test.html", "POST", "localhost", "message=");
            var           req    = new Request(stream);
            ToLowerPlugin lower  = new ToLowerPlugin();
            var           resp   = lower.Handle(req);

            Assert.AreEqual(200, resp.StatusCode);
            Assert.AreEqual("text/html", resp.ContentType);
        }
        public void Plugin_Send_200_OK()
        {
            var           stream = new RequestStream().ValidRequest("test.html", "POST", "localhost", "message=SINA");
            var           req    = new Request(stream);
            ToLowerPlugin lower  = new ToLowerPlugin();
            var           resp   = lower.Handle(req);

            Assert.AreEqual(200, resp.StatusCode);

            using (var ms = new MemoryStream())
            {
                resp.Send(ms);
                Assert.IsTrue(ms.Length > 0);
                ms.Seek(0, SeekOrigin.Begin);
                using (var sr = new StreamReader(ms))
                {
                    var firstLine = sr.ReadLine();
                    Assert.AreEqual("HTTP/1.1 200 OK", firstLine);
                }
            }
        }