I want a one liner, in NUnit, that asserts whether two dictionary are the same. i.e., I want a concise version of the below code:
public static void DictionaryAssert<T, U>(Dictionary<T, U> dictionaryResult, Dictionary<T, U> expectedResult) { Assert.AreEqual(dictionaryResult.Count, expectedResult.Count); foreach (var aKey in expectedResult.Keys) { Assert.AreEqual(expectedResult[aKey], dictionaryResult[aKey]); } }
Surely it isn't so difficult, but I can't find the reference, any idea?
Have a look at CollectionAssert.AreEquivalent. This will assert that the two dictionaries have the same contents, but are not necessarily the same instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With