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()); }
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()); }
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"]); }