public void DictionariesAreEqualWhenUsingCustomComparer() { var dict1 = new Dictionary <int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 } }; var dict2 = new Dictionary <int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 } }; Assert.IsTrue(DictionaryUtility.AreEqual(dict1, dict2, new GenericEqualityComparer <int>((x, y) => x == y))); }
public void DictionariesArNotEqualWhenValueIsdifferent() { var dict1 = new Dictionary <int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 } }; var dict2 = new Dictionary <int, int> { { 1, 2 }, { 2, 2 }, { 3, 3 } }; Assert.IsFalse(DictionaryUtility.AreEqual(dict1, dict2)); }
public void DictionariesAreNotEqualWhenFirstIsMissingItem() { var dict1 = new Dictionary <int, int> { { 1, 1 }, { 2, 2 } }; var dict2 = new Dictionary <int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 } }; Assert.IsFalse(DictionaryUtility.AreEqual(dict1, dict2)); }
public void DictionariesAreEqualWhenItemsAreAddedOutOfOrder() { var dict1 = new Dictionary <int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 } }; var dict2 = new Dictionary <int, int> { { 1, 1 }, { 3, 3 }, { 2, 2 } }; Assert.IsTrue(DictionaryUtility.AreEqual(dict1, dict2)); }
public void ReadOnlyDictionariesAreNotEqualWhenValueIsDifferent() { var dict1 = new Dictionary <int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 } }.AsReadOnly(); var dict2 = new Dictionary <int, int> { { 1, 2 }, { 2, 2 }, { 3, 3 } }.AsReadOnly(); Assert.IsFalse(DictionaryUtility.AreEqual(dict1, dict2)); }
public void ReadOnlyDictionariesAreEqual() { var dict1 = new Dictionary <int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 } }.AsReadOnly(); var dict2 = new Dictionary <int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 } }.AsReadOnly(); Assert.IsTrue(DictionaryUtility.AreEqual(dict1, dict2)); }
public void DictionariesAreEqual() { Dictionary <int, int> dict1 = new Dictionary <int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 } }; Dictionary <int, int> dict2 = new Dictionary <int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 } }; Assert.IsTrue(DictionaryUtility.AreEqual(dict1, dict2)); }
public void DictionariesAreEqualWhenUsingCustomKeyComparer() { var comparer = new GenericEqualityComparer <int>((x, y) => x == y, HashCodeUtility.GetPersistentHashCode); var dict1 = new Dictionary <int, int>(comparer) { { 1, 1 }, { 2, 2 }, { 3, 3 } }; var dict2 = new Dictionary <int, int>(comparer) { { 1, 1 }, { 2, 2 }, { 3, 3 } }; Assert.IsTrue(DictionaryUtility.AreEqual(dict1, dict2)); }