示例#1
0
        public void HasExpectedProperties()
        {
            var obj    = JObject.Parse("{ \"a\": 1 }");
            var result = new ScriptObjectResult(obj, new Dictionary <string, object>());

            Assert.Empty(result.ContentTypes);
            Assert.Equal(obj.ToString(), result.Value.ToString());
        }
示例#2
0
        public void AddsExistingContentType()
        {
            var obj    = JObject.Parse("{ \"a\": 1 }");
            var result = new ScriptObjectResult(obj, new Dictionary <string, object>()
            {
                ["content-type"] = "application/json; charset=utf-8"
            });

            Assert.Equal("application/json; charset=utf-8", result.ContentTypes.First());
        }
示例#3
0
        public void AddsHeadersToResponse()
        {
            var obj    = JObject.Parse("{ \"a\": 1 }");
            var result = new ScriptObjectResult(obj, new Dictionary <string, object>()
            {
                ["custom-header"] = "header"
            });
            var context = new DefaultHttpContext();

            result.AddResponseHeaders(context);
            Assert.Equal("header", context.Response.Headers["custom-header"]);
        }