Exemplo n.º 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)));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }