public void It_accepts_changes_in_the_serialization_settings() { // We create a json or jsonpresult that contains an object with a null property var result = new JsonOrJsonpResult { Data = new Foo { } }; result.ExecuteResult(controllerContext.Object); content.Should().Be(@"{}"); // Clear the content, since we just continue to write in the same context. content = string.Empty; // Change a setting result.SerializationSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Include; result.ExecuteResult(controllerContext.Object); content.Should().Be(@"{""bar"":null}"); }
public void It_allows_changing_json_serialization_entirely() { var result = new JsonOrJsonpResult(); result.JsonSerializerFunc = () => @"{""lol"":""indeed"" }"; result.ExecuteResult(controllerContext.Object); content.Should().Be(@"{""lol"":""indeed"" }"); }
public void It_renders_json_correctly() { var result = new JsonOrJsonpResult { Data = new { foo = "bar" } }; result.ExecuteResult(controllerContext.Object); content.Should().Be( @"{""foo"":""bar""}"); contentType.Should().Be("application/json"); }
public void It_renders_jsonp_correctly() { param["callback"] = "func"; var result = new JsonOrJsonpResult { Data = new { foo = "bar" } }; result.ExecuteResult(controllerContext.Object); content.Should().Be( @"func({""foo"":""bar""});"); contentType.Should().Be("application/javascript"); }