From 3b5a830a8c7a9ca78920a59925c5f76cc09f1f90 Mon Sep 17 00:00:00 2001 From: Ignacio Inglese Date: Thu, 14 Nov 2024 21:48:48 +0000 Subject: [PATCH] Filter empty lines when comparing stack traces in tests --- .../Microsoft.IdentityModel.TestUtils/IdentityComparer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Microsoft.IdentityModel.TestUtils/IdentityComparer.cs b/test/Microsoft.IdentityModel.TestUtils/IdentityComparer.cs index 05325ffe0b..d1b1414f7f 100644 --- a/test/Microsoft.IdentityModel.TestUtils/IdentityComparer.cs +++ b/test/Microsoft.IdentityModel.TestUtils/IdentityComparer.cs @@ -1476,11 +1476,11 @@ internal static bool AreValidationErrorsEqual(ValidationError validationError1, else { // If the stack trace is present, ensure it contains the expected amount of frames. - var stackTraceFrames = exception1.StackTrace.Trim('\n').Split('\n'); - if (stackTraceFrames.Length != validationError2.StackFrames.Count) + var stackTraceFrames = exception1.StackTrace.Trim('\n').Split('\n').Where(s => !s.IsNullOrEmpty()); + if (stackTraceFrames.Count() != validationError2.StackFrames.Count) { - localContext.Diffs.Add($"(exception1.StackTrace.Trim('\\n\').Split('\\n').Length != validationError2.StackFrames.Count: " + - $"{stackTraceFrames.Length}, {validationError2.StackFrames.Count})"); + localContext.Diffs.Add($"(exception1.StackTrace.Trim('\\n\').Split('\\n').Count() != validationError2.StackFrames.Count: " + + $"{stackTraceFrames.Count()}, {validationError2.StackFrames.Count})"); localContext.Diffs.Add($"exception1.StackTrace: {exception1.StackTrace}"); } }