示例#1
0
        public void TestClone()
        {
            element.Properties["Attr"] = "value";
            child1.Properties["Attr1"] = "value1";
            child2.Properties["Attr2"] = "value2";
            child3.Properties["Attr3"] = "value3";

            WomElement clonedElement = new WomElement(element);
            Assert.IsNotNull(clonedElement, "clonedElement == null ");
            Assert.AreNotSame(element, clonedElement, "element == clonedElement ");
            Assert.AreEqual(3, clonedElement.ElementList.Count, "3 != clonedElement.ElementList.Count ");
            Assert.AreNotSame(child1, clonedElement.ElementList[0], "child1 == clonedElement.ElementList[0] ");
            Assert.AreNotSame(child2, clonedElement.ElementList[1], "child2 == clonedElement.ElementList[1] ");
            Assert.AreNotSame(child3, clonedElement.ElementList[2], "child3 == clonedElement.ElementList[2] ");
            Assert.AreEqual("value", clonedElement.Properties["Attr"],
                "\"value\" != clonedElement.Attributes[\"Attr\"] ");
            Assert.AreEqual("value1", clonedElement.ElementList[0].Properties["Attr1"],
                "\"value1\" != clonedElement.ElementList[0].Attributes[\"Attr1\"] ");
            Assert.AreEqual("value2", clonedElement.ElementList[1].Properties["Attr2"],
                "\"value2\" != clonedElement.ElementList[1].Attributes[\"Attr2\"] ");
            Assert.AreEqual("value3", clonedElement.ElementList[2].Properties["Attr3"],
                "\"value3\" != clonedElement.ElementList[2].Attributes[\"Attr3\"] ");

            clonedElement.Properties["Attr"] = "newValue";
            clonedElement.ElementList[0].Properties["Attr1"] = "newValue";

            Assert.AreEqual("value", element.Properties["Attr"], "\"value\" != element.Attributes[\"Attr\"] ");
            Assert.AreEqual("value1", child1.Properties["Attr1"], "\"value1\" != child1.Attributes[\"Attr1\"] ");
        }
        public void TestHasAttributes()
        {
            Assert.IsTrue(element.HasProperties, "element.HasAttributes != true ");

            WomElement element2 = new WomElement("Test");
            Assert.IsFalse(element2.HasProperties, "element2.HasAttributes != false ");
        }
示例#3
0
 public void SetUp()
 {
     element = new WomElement("Element");
     element.ElementList.Add(child1 = new WomElement("Child1"));
     element.ElementList.Add(child2 = new WomElement("Child2"));
     element.ElementList.Add(child3 = new WomElement("Child3"));
     emptyElement = new WomElement("Element");
 }
 public void SetUp()
 {
     doc = new WomDocument(
         node11 = new WomElement("Node11", new WomProperty("Prop1", "value1"), new WomProperty("Prop2", "value2"),
             node21 = new WomElement("Node21", new WomProperty("Prop1", "value1"), new WomProperty("Prop2", "value2")),
             node22 = new WomElement("Node22", new WomProperty("Prop1", "value1"), new WomProperty("Prop2", "value2"),
                 node31 = new WomElement("Node31"), new WomElement("Node32")),
             node23 = new WomElement("Node23", new WomProperty("Prop1", "value1"), new WomProperty("Prop2", "value2"))));
 }
        public void SetUp()
        {
            test1 = new WomElement("Test1");
            test1.ElementList.Add(child11 = new WomElement("Child11"));
            test1.ElementList.Add(child12 = new WomElement("Child12"));
            test1.ElementList.Add(child13 = new WomElement("Child13"));

            test2 = new WomElement("Test2");
            test2.ElementList.Add(child21 = new WomElement("Child21"));
            test2.ElementList.Add(child22 = new WomElement("Child22"));
            test2.ElementList.Add(child23 = new WomElement("Child23"));
        }
 public void TestCopyTo()
 {
     WomElement[] array = new WomElement[4];
     test1.ElementList.CopyTo(array, 1);
     Assert.IsNull(array[0], "array[0] != null ");
     Assert.AreSame(child11, array[1], "child11 != array[1] ");
     Assert.AreSame(child12, array[2], "child12 != array[2] ");
     Assert.AreSame(child13, array[3], "child13 != array[3] ");
 }
 public void TestInsert()
 {
     WomElement newChilld = new WomElement("newChild");
     test1.ElementList.Insert(1, newChilld);
     Assert.AreEqual(4, test1.ElementList.Count, "4 != test1.ElementList.Count ");
     Assert.AreSame(newChilld, test1.ElementList[1], "newChilld != test1.ElementList[1] ");
     Assert.AreSame(test1, newChilld.Parent, "test1 != newChilld.Parent ");
     Assert.AreSame(child11, test1.ElementList[0], "child11 != test1.ElementList[0] ");
     Assert.AreSame(child12, test1.ElementList[2], "child12 != test1.ElementList[2] ");
     Assert.AreSame(child13, test1.ElementList[3], "child13 != test1.ElementList[3] ");
 }
 public void TestIndexerSet()
 {
     WomElement newChilld = new WomElement("newChild");
     test1.ElementList[1] = newChilld;
     Assert.AreEqual(3, test1.ElementList.Count, "3 != test1.ElementList.Count ");
     Assert.AreSame(newChilld, test1.ElementList[1], "newChilld != test1.ElementList[1] ");
     Assert.AreSame(test1, newChilld.Parent, "test1 != newChilld.Parent ");
     Assert.IsNull(child12.Parent, "child12.Parent != null ");
 }
 public void SetUp()
 {
     element = new WomElement("Element");
     element.Properties["Attr1"] = "value1";
     element.Properties["Attr2"] = "value2";
 }
示例#10
0
        public void TestIndex()
        {
            Assert.AreEqual(0, child1.Index, "0 != child1.Index ");
            Assert.AreEqual(1, child2.Index, "1 != child2.Index ");
            Assert.AreEqual(2, child3.Index, "2 != child3.Index ");

            WomElement child = new WomElement("Child");
            Assert.AreEqual(-1, child.Index, "-1 != child.Index ");
        }
 public void SetUp()
 {
     exprReader = new ParserExpressionReader();
     context = new WomElement("Context");
 }