Fixed failing unit tests on Mono; used CollectionAssert.AreEquivalent() instead of CollectionAssert.AreEqual() since the order of items in a Dictionary is unspecified and Mono makes use of this allowance; fixed one serious bug that should have been caught by the .NET 2.0 unit tests: the enumeration of ReadOnlyDictionary via ICollection should return DictionaryEntry[] and not KeyValuePair<>[]

git-svn-id: file:///srv/devel/repo-conversion/nusu@115 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2009-01-13 20:00:13 +00:00
parent 8dc15e8515
commit 2ab3b22c60

View File

@ -281,7 +281,7 @@ namespace Nuclex.Support.Collections {
(outputNumbers as IDictionary).Add(entry.Key, entry.Value); (outputNumbers as IDictionary).Add(entry.Key, entry.Value);
} }
CollectionAssert.AreEqual(numbers, outputNumbers); CollectionAssert.AreEquivalent(numbers, outputNumbers);
} }
/// <summary> /// <summary>
@ -409,9 +409,16 @@ namespace Nuclex.Support.Collections {
Dictionary<int, string> numbers = createTestDictionary(); Dictionary<int, string> numbers = createTestDictionary();
ReadOnlyDictionary<int, string> testDictionary = makeReadOnly(numbers); ReadOnlyDictionary<int, string> testDictionary = makeReadOnly(numbers);
DictionaryEntry[] entries = new DictionaryEntry[numbers.Count];
(testDictionary as ICollection).CopyTo(entries, 0);
KeyValuePair<int, string>[] items = new KeyValuePair<int, string>[numbers.Count]; KeyValuePair<int, string>[] items = new KeyValuePair<int, string>[numbers.Count];
(testDictionary as ICollection).CopyTo(items, 0); for(int index = 0; index < entries.Length; ++index) {
CollectionAssert.AreEqual(numbers, items); items[index] = new KeyValuePair<int, string>(
(int)entries[index].Key, (string)entries[index].Value
);
}
CollectionAssert.AreEquivalent(numbers, items);
} }
/// <summary> /// <summary>
@ -444,7 +451,7 @@ namespace Nuclex.Support.Collections {
memory.Position = 0; memory.Position = 0;
object testDictionary2 = formatter.Deserialize(memory); object testDictionary2 = formatter.Deserialize(memory);
CollectionAssert.AreEqual(testDictionary1, (IEnumerable)testDictionary2); CollectionAssert.AreEquivalent(testDictionary1, (IEnumerable)testDictionary2);
} }
} }