public virtual void testWriteToStringIndent() { XMLDoc d = new XMLDoc("a", null); KElement e = d.getRoot(); e.appendElement("b"); string s = d.write2String(2); Assert.IsTrue(s.IndexOf("\n ") > 0); s = d.write2String(0); Assert.IsTrue(s.EndsWith("<a>\r\n<b />\r\n</a>")); }
public virtual void testNS() { JDFDoc doc = new JDFDoc("foo:bar"); string s = doc.write2String(2); Assert.IsTrue(s.IndexOf(JDFConstants.JDFNAMESPACE) > 0); XMLDoc doc2 = new XMLDoc("abc", null); string s2 = doc2.write2String(2); Assert.IsTrue(s2.IndexOf(JDFConstants.JDFNAMESPACE) < 0); doc2.getRoot().copyElement(doc.getRoot(), null); s2 = doc2.write2String(2); Assert.IsTrue(s2.IndexOf(JDFConstants.JDFNAMESPACE) > 0); }
public virtual void testEscapeStrings() { XMLDoc d = new XMLDoc("foo", "www.foo.com"); KElement e = d.getRoot(); e.setAttribute("bar", "><&'\""); string s = d.write2String(0); Assert.IsTrue(s.IndexOf("<") > 0); Assert.IsTrue(s.IndexOf("&") > 0); Assert.IsTrue(s.IndexOf(""") > 0); }
public virtual void testSize() { Process.GetCurrentProcess(); GC.Collect(); Process.GetCurrentProcess(); GC.Collect(); Process.GetCurrentProcess(); GC.Collect(); XMLDoc d = new XMLDoc("JDF:foo", JDFConstants.JDFNAMESPACE); long memlocal = d.getDocMemoryUsed(); string s = d.write2String(0); Assert.IsTrue(memlocal + 100000 > s.Length, "mem 1"); // the gc is messy and sometimes returns +/- a few 10k Assert.IsTrue(memlocal + 100000 > s.Length, "mem 2"); d = JDFTestCaseBase.creatXMDoc(); memlocal = d.getDocMemoryUsed(); s = d.write2String(0); Assert.IsTrue(memlocal + 10000 > s.Length, "mem 3"); d = new XMLDoc("foo", null); KElement e = d.getRoot(); KElement e2 = e.appendElement("e2"); KElement e3 = e2.appendElement("e3"); for (int i = 33; i < 999; i++) { e3.setAttribute("k" + Convert.ToString(i), "value" + Convert.ToString(i)); } for (int j = 0; j < 99; j++) { e2.copyElement(e3, null); } memlocal = d.getDocMemoryUsed(); s = d.write2String(0); Assert.IsTrue(memlocal + 200000 > s.Length, "mem 4"); }
public virtual void testForeignRoot() { XMLDoc doc = new XMLDoc("Foo", "fooNS"); KElement r = doc.getRoot(); JDFNode n = new JDFDoc("JDF").getJDFRoot(); r.copyElement(n, null); string s = doc.write2String(0); JDFParser p = new JDFParser(); JDFDoc d = p.parseString(s); Assert.IsNotNull(d.getJDFRoot()); Assert.IsNotNull(d.getRoot()); Assert.AreNotEqual(d.getRoot(), d.getJDFRoot()); }