Skip to content

Commit

Permalink
xunit/xunit#2824: Assert.Equal fails with null values in dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Nov 27, 2023
1 parent 455865a commit c35ef46
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Sdk/CollectionTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,17 @@ protected CollectionTracker(IEnumerable innerEnumerable)

if (valueX == null)
{
if (valueY == null)
continue;
return false;
if (valueY != null)
return false;
}
if (valueY == null)
return false;

var comparer = AssertEqualityComparer.GetDefaultComparer(valueX.GetType());
if (!comparer.Equals(valueX, valueY))
else if (valueY == null)
return false;
else
{
var comparer = AssertEqualityComparer.GetDefaultComparer(valueX.GetType());
if (!comparer.Equals(valueX, valueY))
return false;
}

dictionaryYKeys.Remove(key);
}
Expand Down

0 comments on commit c35ef46

Please sign in to comment.