Given two dictionaries
var dictA = new Dictionary<string, classA>();
var dictB = new Dictionary<string, classA>();
How to check whether these two dictionaries are the same? The catch here is that I can't use the default classA.Equals
for comparing the value pairs. Instead, the test will pass when and only when given that all the object of the classA
type in the dictionaries must satisfy my own custom IEqualityComparer<ClassA>
.
Specifically, I am looking at something like
CollectionAssert.AreEquivalent(dictA, dictB, new ClassEqualityComparer());
with ClassEqualityComparer
inherits from IEqualityComparer<ClassA>
, or equivalent. I don't mind if I have to subclass a NUnit type of IEqualityComparer
( such as IResolveConstraint
), but the most important thing is that the Assert
method must be something like
Assertion(dictA, dictB, EqualityComparer)
Or something even more simpler; I don't want to use Assert.That
and then implement a type of IResolveConstraint
that runs into pages just to check whether two dictionaries are the same.
Any idea?