diff --git a/src/TestFramework/TestFramework/Assertions/Assert.AreEqual.cs b/src/TestFramework/TestFramework/Assertions/Assert.AreEqual.cs index 274bc26248..5b94c7ed13 100644 --- a/src/TestFramework/TestFramework/Assertions/Assert.AreEqual.cs +++ b/src/TestFramework/TestFramework/Assertions/Assert.AreEqual.cs @@ -698,7 +698,8 @@ private static void ThrowAssertAreEqualFailed(T expected, T actual, T delta, [DoesNotReturn] private static void ThrowAssertAreEqualFailed(string? expected, string? actual, bool ignoreCase, CultureInfo culture, string userMessage) { - string finalMessage = !ignoreCase && CompareInternal(expected, actual, ignoreCase, culture) == 0 + // If the user requested to match case, and the difference between expected/actual is casing only, then we use a different message. + string finalMessage = !ignoreCase && CompareInternal(expected, actual, ignoreCase: true, culture) == 0 ? string.Format( CultureInfo.CurrentCulture, FrameworkMessages.AreEqualCaseFailMsg, diff --git a/test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.AreEqualTests.cs b/test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.AreEqualTests.cs index 4760984225..746caa344f 100644 --- a/test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.AreEqualTests.cs +++ b/test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.AreEqualTests.cs @@ -126,7 +126,8 @@ public void AreEqual_WithEnglishCultureAndDoesNotIgnoreCase_Throws() var englishCulture = new CultureInfo("en-EN"); // Won't ignore case. - VerifyThrows(() => Assert.AreEqual(expected, actual, false, englishCulture)); + Exception ex = VerifyThrows(() => Assert.AreEqual(expected, actual, false, englishCulture)); + Verify(ex.Message == "Assert.AreEqual failed. Expected:. Case is different for actual value:. "); } public void AreEqual_WithTurkishCultureAndDoesNotIgnoreCase_Throws()