示例#1
0
        public void JsonResultShouldSetContentLength()
        {
            JsonResult result = new JsonResult(HttpStatusCode.OK, "something");

            result.Apply(context);

            Assert.AreEqual(11, context.ResponseContentLength);
        }
示例#2
0
        public void JsonShouldNotEmitBom()
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("key", "value");

            JsonResult result = new JsonResult(dict);

            result.Apply(context);

            byte[] responseBytes = context.ReadResponseStreamAsByteArray();
            string responseBody  = Encoding.UTF8.GetString(responseBytes);

            Assert.AreNotEqual(239, responseBytes[0]);
            Assert.AreEqual("{\"key\":\"value\"}", responseBody);
        }