From baf9899404e118ad9c47fbf1b8066d6bb9bf9930 Mon Sep 17 00:00:00 2001 From: "Matthew D. Groves" Date: Mon, 25 Sep 2023 11:02:22 -0400 Subject: [PATCH] #20 trying to get more info why a couple of tests are failing only in CI --- .../TestHelpers/JsonTestHelpers.cs | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Conduit/Conduit.Tests/TestHelpers/JsonTestHelpers.cs b/Conduit/Conduit.Tests/TestHelpers/JsonTestHelpers.cs index c7ea6e13e8..6878468c68 100644 --- a/Conduit/Conduit.Tests/TestHelpers/JsonTestHelpers.cs +++ b/Conduit/Conduit.Tests/TestHelpers/JsonTestHelpers.cs @@ -1,4 +1,7 @@ -using Newtonsoft.Json.Linq; +using System.Diagnostics; +using App.Metrics.Logging; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json.Linq; namespace Conduit.Tests.TestHelpers; @@ -6,9 +9,21 @@ public static class JsonTestHelpers { public static T SubDoc(this string @this, string subDocKey) { - var obj = JObject.Parse(@this); - if (!obj.ContainsKey(subDocKey)) - throw new ArgumentException($"SubDoc '{subDocKey}' not found in JSON."); - return obj[subDocKey].ToObject(); + try + { + var obj = JObject.Parse(@this); + if (!obj.ContainsKey(subDocKey)) + throw new ArgumentException($"SubDoc '{subDocKey}' not found in JSON."); + return obj[subDocKey].ToObject(); + } + catch + { + Trace.WriteLine("TRACE There was a problem getting the subdoc of '{subDocKey}' from this JSON string: '{@this}"); + Debug.Print($"DEBUG There was a problem getting the subdoc of '{subDocKey}' from this JSON string: '{@this}"); + var logfactory = (ILoggerFactory)new LoggerFactory(); + var logger = new Logger(logfactory); + logger.LogError($"TRACE There was a problem getting the subdoc of '{subDocKey}' from this JSON string: '{@this}"); + throw; + } } }