예제 #1
0
        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)));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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));
        }
예제 #8
0
        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));
        }