示例#1
0
        public void CanHandle_Should_Not_Be_Zero()
        {
            //Arrange
            var   stream = new RequestStream().ValidRequest("temp.html?date=&submit=ok");
            var   temp   = new Tempplugin();
            var   req    = new Request(stream);
            float zero;

            //Act
            float nummer = temp.CanHandle(req);

            zero = 0.0f;

            //Assert
            Assert.IsTrue(req.IsValid);
            Assert.AreEqual("GET", req.Method);
            Assert.IsNotNull(req.Url);
            Assert.AreNotEqual(zero, nummer);
        }
        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);
                }
            }
        }