You made a big mistake in your original post. You talked about the Equals() method in the IDictionary interface. This is the point!
Equals () is a virtual System.Object method that classes can override. Interfaces do not implement methods at all . Instead, interface instances are reference types, inheriting from System.Object and potentially declaring an override of Equals() .
Now the point ... System.Collections.Generic.Dictionary<K,V> does not override the equal. You said that you implemented your IDictionary in your own way and reasonably overcame Equals, but look at your own code
Assert.AreEqual (backingDictionary, readOnlyDictionary);
This method is basically implemented as return backingDictionary.Equals(readOnlyDictionary) and here again is the point.
The Basic Equals () method returns false, if two objects are instances of different classes, you cannot control this. Otherwise, if two objects are of the same type, each element is compared through reflection (just members, not properties) using the Equals() approach instead of == (this is what the manual calls a “comparison of values” instead of “reference compare ")
So firstly, I won’t be surprised if Assert.AreEqual (readOnlyDictionary,backingDictionary); succeed because it will call the custom Equals method.
I have no doubt that the approaches of other users in this topic work, but I just wanted to explain to you what was a mistake in your initial approach. Of course, Microsoft would better use the Equals method, which compares the current instance with any other IDictionary instance, but again, this goes beyond the scope of the Dictionary class, which is a public stand-alone class and is not intended to be the only public implementation of IDictionary. For example, when you define an interface, factory, and a protected class that implements it in a library, you can compare the class with other instances of the base interface, and not with the class itself, which is not public.
I hope to help you. Greetings.