Exemplo n.º 1
0
        public void NetSaveReadCDataCollection()
        {
            XmlDocument doc;
            bool        created = CreateAndInitDom(out doc);

            if (created)
            {
                Element root = new Element();
                root.SetDomDoc(doc);

                Element elem = root["aa"]["bb"]["cc"].CreateNew(null);
                Assert.IsTrue(elem.Exists);
                System.String strCData = "<data>Where is my data?</data>";
                elem.AddCData(strCData);
                System.String strCData2 = "<data>Where is my data?</data>";
                elem.AddCData(strCData2);

                List <CData> vec = elem.GetCDataCollection();

                System.String s1 = strCData;
                System.String s2 = vec[0].GetContent();

                Assert.AreEqual(s1, s2);

                System.String s3 = strCData2;
                System.String s4 = vec[1].GetContent();

                Assert.AreEqual(s3, s4);

                XmlDocument doc2;
                Assert.IsTrue(CreateAndLoadXmlString(out doc2, doc.OuterXml));


                Element root2 = new Element();
                root2.SetDomDoc(doc2);

                Element elem2 = root2["aa"]["bb"]["cc"];
                Assert.IsTrue(elem2.Exists);
                List <CData> vec2 = elem.GetCDataCollection();

                System.String s5 = strCData;
                System.String s6 = vec2[0].GetContent();

                Assert.AreEqual(s5, s6);

                System.String s7 = strCData2;
                System.String s8 = vec2[1].GetContent();

                Assert.AreEqual(s7, s8);
            }
        }
Exemplo n.º 2
0
        public void NetUpdateCData()
        {
            XmlDocument doc;
            bool        created = CreateAndInitDom(out doc);

            if (created)
            {
                Element root = new Element();
                root.SetDomDoc(doc);

                Element elem = root["aa"]["bb"]["cc"].CreateNew(null);
                Assert.IsTrue(elem.Exists);
                System.String strCData = "<data>Where is my data?</data>";
                elem.AddCData(strCData);

                CData cdata = elem.GetCDataCollection()[0];

                System.String s1 = strCData;
                System.String s2 = cdata.GetContent();

                Assert.AreEqual(s1, s2);

                System.String strUpdate = "<data>Where is my world?</data>";
                Assert.IsTrue(cdata.Update(strUpdate));

                XmlDocument doc2;
                Assert.IsTrue(CreateAndLoadXmlString(out doc2, doc.OuterXml));


                Element root2 = new Element();
                root2.SetDomDoc(doc2);

                Element elem2 = root2["aa"]["bb"]["cc"];
                Assert.IsTrue(elem2.Exists);
                CData cdata2 = elem2.GetCDataCollection()[0];

                s1 = strUpdate;
                System.String s3 = cdata2.GetContent();

                Assert.AreEqual(s1, s3);
            }
        }