Skip to content

Commit

Permalink
Use different message for Assert.AreEqual when string difference is c…
Browse files Browse the repository at this point in the history
…asing only (#4525)
  • Loading branch information
Youssef1313 authored Jan 6, 2025
1 parent f049f23 commit 8520876
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,8 @@ private static void ThrowAssertAreEqualFailed<T>(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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:<i>. Case is different for actual value:<I>. ");
}

public void AreEqual_WithTurkishCultureAndDoesNotIgnoreCase_Throws()
Expand Down

0 comments on commit 8520876

Please sign in to comment.