private static void InternalWriteException(IObjectWriter writer, Exception exception) { writer.WriteProperty("message", exception.Message) .WriteProperty("type", exception.GetType().FullName) .WriteProperty("stacktrace", exception.StackTrace); if (exception is AggregateException aggregateException) { writer.WriteArray("inner_exceptions", array => { foreach (Exception innerException in aggregateException.InnerExceptions) { array.WriteObject(x => InternalWriteException(x, innerException)); } }); } else if (exception.InnerException != null) { writer.WriteException(exception.InnerException, "inner_exception"); } }
public void Should_write_boolean_value() { var result = sut.WriteArray("property", a => a.WriteValue(true)).ToString(); Assert.Equal(@"{""property"":[true]}", result); }