In following with NUnit’s conventions, I only use EquivalentTo
for comparing collections - so I’d call the extension method something else, maybe HasPropertiesEqual()
or leave it without wrapping in another extension method so it’s clear how they’re equal.
You don’t need the extra checks since ToObjectDictionary() returns null
(like most extension methods) and EquivalentTo() already does the null
check dance:
if (thisList == null || otherList == null)
return thisList == otherList;
ToObjectDictionary()
just converts a POCO into a Dictionary<string,object>
making it easy to dynamically inspect its property values.