public void ToJsonString_ShouldNotSerializeExceptionAndHttpContext() { var builder = new NoticeBuilder(); builder.SetErrorEntries(new Exception()); builder.SetHttpContext(new FakeHttpContext(), null); var notice = builder.ToNotice(); var json = NoticeBuilder.ToJsonString(notice); Assert.True(json.IndexOf("\"Exception\":", StringComparison.OrdinalIgnoreCase) == -1); Assert.True(json.IndexOf("\"HttpContext\":", StringComparison.OrdinalIgnoreCase) == -1); }
public void ToJsonString() { var builder = new NoticeBuilder(); builder.SetErrorEntries(new Exception()); var notice = builder.ToNotice(); var actualJson = NoticeBuilder.ToJsonString(notice); var expectedJson = JsonConvert.SerializeObject(notice, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); Assert.True(actualJson.Equals(expectedJson)); }
public void ToJsonString_ShouldTruncateNoticeBigger64KB() { var httpContext = new FakeHttpContext { Parameters = new Dictionary <string, string> { { "long_param", new string('x', 64001) } } }; var builder = new NoticeBuilder(); builder.SetHttpContext(httpContext, null); var notice = builder.ToNotice(); var json = NoticeBuilder.ToJsonString(notice); Assert.NotNull(json); Assert.True(json.Length <= 64000); }