Example #1
0
        public void DictionaryNotEqualsWithArraysTest()
        {
            // setup
            string nameA  = "Timmy";
            var    itemsA = new Dictionary <string, object>
            {
                { "a", "apple" },
                { "b", new int[] { 907 } }
            };

            string nameB  = "Timmy";
            var    itemsB = new Dictionary <string, object>
            {
                { "a", "apple" },
                { "b", new int[] { 909 } }
            };

            var dictionaryContainerA = new ObjectDictionaryContainer
            {
                Name  = nameA,
                Items = itemsA
            };

            var dictionaryContainerB = new ObjectDictionaryContainer
            {
                Name  = nameB,
                Items = itemsB
            };

            // test
            var equal = dictionaryContainerA.Equals(dictionaryContainerB);

            // assert
            Assert.IsFalse(equal);
        }
Example #2
0
        public void DictionaryEqualsWithDeferencingTest()
        {
            // setup
            string nameA  = "Timmy";
            var    itemsA = new Dictionary <string, object>
            {
                { "a", "apple" },
                { "b", 32 }
            };

            string nameB  = "Timmy";
            var    itemsB = new Dictionary <string, object>
            {
                { "a", "apple" },
                { "b", 32 }
            };

            var dictionaryContainerA = new ObjectDictionaryContainer
            {
                Name  = nameA,
                Items = itemsA
            };

            var dictionaryContainerB = new ObjectDictionaryContainer
            {
                Name  = nameB,
                Items = itemsB
            };

            // test
            var equal = dictionaryContainerA.Equals(dictionaryContainerB);

            // assert
            Assert.IsTrue(equal);
        }
Example #3
0
        public void DictionaryNotGetHashCodeWithArraysTest()
        {
            // setup
            string nameA  = "Timmy";
            var    itemsA = new Dictionary <string, object>
            {
                { "a", "apple" },
                { "b", new int[] { 907 } }
            };

            string nameB  = "Timmy";
            var    itemsB = new Dictionary <string, object>
            {
                { "a", "apple" },
                { "b", new int[] { 909 } }
            };

            var dictionaryContainerA = new ObjectDictionaryContainer
            {
                Name  = nameA,
                Items = itemsA
            };

            var dictionaryContainerB = new ObjectDictionaryContainer
            {
                Name  = nameB,
                Items = itemsB
            };

            // test
            var dictionaryContainerAHash = dictionaryContainerA.GetHashCode();
            var dictionaryContainerBHash = dictionaryContainerB.GetHashCode();

            // assert
            Assert.AreNotEqual(dictionaryContainerAHash, dictionaryContainerBHash);
        }
Example #4
0
        public void DictionaryGetHashCodeWithDeferencingTest()
        {
            // setup
            string nameA  = "Timmy";
            var    itemsA = new Dictionary <string, object>
            {
                { "a", "apple" },
                { "b", 32 }
            };

            string nameB  = "Timmy";
            var    itemsB = new Dictionary <string, object>
            {
                { "a", "apple" },
                { "b", 32 }
            };

            var dictionaryContainerA = new ObjectDictionaryContainer
            {
                Name  = nameA,
                Items = itemsA
            };

            var dictionaryContainerB = new ObjectDictionaryContainer
            {
                Name  = nameB,
                Items = itemsB
            };

            // test
            var dictionaryContainerAHash = dictionaryContainerA.GetHashCode();
            var dictionaryContainerBHash = dictionaryContainerB.GetHashCode();

            // assert
            Assert.AreEqual(dictionaryContainerAHash, dictionaryContainerBHash);
        }