Does anyone know of a good way to assert if a NameValueCollection is equivalent? At the moment I’m using NUnit, but CollectionAssert.AreEquivalent() seems to only assert the keys. Not the keys and the values.
I wrote this little piece of code to help me out, but it would be nice if there was something out-of-the-box that could do the same.
private static void AssertNameValueCollectionAreEquivalent(NameValueCollection expectedCollection, NameValueCollection collection)
{
// Will evaluate keys only
CollectionAssert.AreEquivalent(expectedCollection, collection);
foreach (string namevalue in collection)
{
Assert.AreEqual(expectedCollection[namevalue], collection[namevalue]);
}
}
how about convert it to Dictionary and assert as: