public void AggregateExceptionSerializeTest() { Exception aggregateError = null; #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously Func <Task> asyncFunc = async() => { File.ReadAllText("some invalid path.txt"); Assert.Fail(); }; #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously try { asyncFunc().Wait(); } catch (Exception ex) { aggregateError = ex; } var exceptionDumper = new JsonExceptionDumper(); Debug.Assert(aggregateError != null, "aggregateError != null"); var dto = exceptionDumper.Dump <ExceptionDto>(aggregateError); TestContext.WriteLine(JsonConvert.SerializeObject(dto, JsonDefaults.JsonConfigSerializerSource.Settings)); }
public void SimpleSerializeTest() { Exception simpleError = null; try { File.ReadAllText("some invalid path.txt"); Assert.Fail(); } catch (Exception ex) { simpleError = ex; } var exceptionDumper = new JsonExceptionDumper(); var dto = exceptionDumper.Dump <ExceptionDto>(simpleError); TestContext.WriteLine(JsonConvert.SerializeObject(dto, JsonDefaults.JsonConfigSerializerSource.Settings)); }