<PackageReference Include="NUnit" Version="3.10.1" />

KeyValuePairsComparer

Comparator for two KeyValuePair<T, U>s.
using NUnit.Compatibility; using System; using System.Collections.Generic; namespace NUnit.Framework.Constraints.Comparers { internal class KeyValuePairsComparer : IChainComparer { private readonly NUnitEqualityComparer _equalityComparer; internal KeyValuePairsComparer(NUnitEqualityComparer equalityComparer) { _equalityComparer = equalityComparer; } public bool? Equal(object x, object y, ref Tolerance tolerance, bool topLevelComparison = true) { Type type = x.GetType(); Type type2 = y.GetType(); Type obj = type.GetTypeInfo().IsGenericType ? type.GetGenericTypeDefinition() : null; Type type3 = type2.GetTypeInfo().IsGenericType ? type2.GetGenericTypeDefinition() : null; if ((object)obj != typeof(KeyValuePair<, >) || (object)type3 != typeof(KeyValuePair<, >)) return null; Tolerance tolerance2 = Tolerance.Exact; object value = type.GetProperty("Key").GetValue(x, null); object value2 = type2.GetProperty("Key").GetValue(y, null); object value3 = type.GetProperty("Value").GetValue(x, null); object value4 = type2.GetProperty("Value").GetValue(y, null); return _equalityComparer.AreEqual(value, value2, ref tolerance2, false) && _equalityComparer.AreEqual(value3, value4, ref tolerance, false); } } }