Пример #1
0
        public virtual void testContainsElement()
        {
            XMLDoc   d  = new XMLDoc("doc", null);
            KElement e  = d.getRoot();
            KElement e1 = e.appendElement("e1");

            e1.setAttribute("a", "b");
            VElement v = new VElement();

            v.appendUnique(e1);
            e1 = e.appendElement("e1");
            e1.setAttribute("a", "b");
            Assert.IsTrue(v.containsElement(e1), "containsElement");
            Assert.IsFalse(v.Contains(e1), "contains");
            e1.setText("foo");
            Assert.IsFalse(v.containsElement(e1), "containsElement");
            v.appendUnique(e1);
            Assert.AreEqual(2, v.Count, "size");
            e1 = e.appendElement("e1");
            e1.setAttribute("a", "b");
            e1.setText("foo");
            Assert.IsTrue(v.containsElement(e1), "containsElement");
            e1.setText("bar");
            Assert.IsFalse(v.containsElement(e1), "containsElement");
        }
Пример #2
0
        public virtual void testWriteToStreamIndent()
        {
            XMLDoc            d   = new XMLDoc("a", null);
            KElement          e   = d.getRoot();
            KElement          b   = e.appendElement("b");
            ByteArrayIOStream bos = new ByteArrayIOStream();

            d.write2Stream(bos, 2, false);
            string s = System.Text.Encoding.GetEncoding("utf-8").GetString(bos.ToArray());

            Assert.IsTrue(s.IndexOf("\n ") > 0);
            string text = "aa\r\nbb\r\n";

            b.setText(text);
            bos = new ByteArrayIOStream();
            d.write2Stream(bos, 2, false);
            s = System.Text.Encoding.GetEncoding("utf-8").GetString(bos.ToArray());
            Assert.IsTrue(s.IndexOf(text) > 0);
            JDFParser p = new JDFParser();

            //		JDFDoc dd =
            p.parseStream(bos.getInputStream());
            bos = new ByteArrayIOStream();
            d.write2Stream(bos, 2, false);
            s = System.Text.Encoding.GetEncoding("utf-8").GetString(bos.ToArray());
            Assert.IsTrue(s.IndexOf(text) > 0);
        }