Пример #1
0
        public void EqualityDict()
        {
            // Make initial dict
            BDict testDict = new BDict();
            BString testString = new BString("Hello World");
            BInt testInt = new BInt(5);

            testDict.Add("a", testString);
            testDict.Add("b", testInt);

            // Make test dict
            BDict testDict2 = new BDict();
            BString testString2 = new BString("Hello World");
            BInt testInt2 = new BInt(5);

            testDict2.Add("a", testString2);
            testDict2.Add("b", testInt2);

            // Test equality recursive
            Assert.AreEqual(testDict, testDict2);

            // Test null dict
            BDict nullDict = null;
            Assert.IsFalse(testDict.Equals(nullDict));

            // Test different counts
            testDict2.Add("c", new BInt(10));
            Assert.IsFalse(testDict.Equals(testDict2));

            // Test different values
            testDict.Add("c", new BInt(9));
            Assert.IsFalse(testDict.Equals(testDict2));

            // Test missing keys
            testDict2.Remove("c");
            testDict2.Add("d", new BInt(9));

            Assert.IsFalse(testDict.Equals(testDict2));
        }