Example #1
0
        public void TestObjectMethods()
        {
            //Equals
            SimpleElement se1 = new SimpleElement("name");
            SimpleElement se2 = new SimpleElement("name", "value");
            SimpleValue   sv  = new SimpleValue("value");

            Assert.IsFalse(se1.Equals(sv));
            Assert.IsFalse(se1.Equals(se2));
            se2.SetString(se1.GetString());
            Assert.IsTrue(se1.Equals(se2));
            se1.AddElement("child1");
            se1.AddElement("child2");
            Assert.IsFalse(se1.Equals(se2));
            se2.AddElement("child1");
            se2.AddElement("child2");
            Assert.IsTrue(se1.Equals(se2));
            se1.AddAttribute("attr1");
            Assert.IsFalse(se1.Equals(se2));
            se2.AddAttribute("attr1");
            Assert.IsTrue(se1.Equals(se2));

            //GetHashCode
            Assert.AreEqual(XmlHelper.HashElement(se1), se1.GetHashCode());

            //Clone
            SimpleElement se1c = (SimpleElement)se1.Clone();

            Assert.AreEqual(se1c, se1);
            Assert.AreNotSame(se1, se1c);
            se1.Comment = "comment";
            Assert.AreNotEqual(se1c, se1);
        }