コード例 #1
0
ファイル: FactoryTest.cs プロジェクト: cip4/JDFLibNet
        public virtual void testRemoveAttributeStringString()
        {
            JDFParser p      = new JDFParser();
            JDFDoc    jdfDoc = p.parseFile(sm_dirTestData + "emptyAuthorAttribute.jdf");

            JDFElement root  = jdfDoc.getJDFRoot();
            KElement   kElem = root.getChildByTagName("Created", "", 0, null, false, true);

            bool before = kElem.hasAttribute("Author", "", false);

            Assert.IsTrue(before, "The Attribute 'Author' does not exist");

            if (before)
            {
                kElem.removeAttribute("Author", "");
                bool after = kElem.hasAttribute("Author", "", false);

                Assert.IsFalse(after, "The Attribute 'Author' was not removed");
            }
        }
コード例 #2
0
ファイル: JDFElementTest.cs プロジェクト: cip4/JDFLibNet
        public virtual void testCopyElement()
        {
            JDFDoc     d  = new JDFDoc("d1");
            JDFElement e  = (JDFElement)d.getRoot();
            JDFDoc     d2 = new JDFDoc("d2");
            JDFElement e2 = (JDFElement)d2.getRoot();
            KElement   e3 = e.copyElement(e2, null);
            JDFParser  p  = new JDFParser();
            JDFDoc     dp = p.parseString("<Device xmlns=\"www.CIP4.org/JDFSchema_1_1\"/>");
            KElement   ep = dp.getRoot();
            KElement   e4 = e.copyElement(ep, null);

            Assert.AreEqual(e4.hasAttribute("xmlns"), ep.hasAttribute("xmlns"));
            Assert.AreEqual(e3.getNamespaceURI(), e.getNamespaceURI());
            Assert.IsFalse(d.ToString().IndexOf("xmlns=\"\"") >= 0);
        }
コード例 #3
0
ファイル: XMLDocTest.cs プロジェクト: cip4/JDFLibNet
        public virtual void testClone()
        {
            XMLDoc doc  = new XMLDoc("foobar", null);
            XMLDoc doc2 = (XMLDoc)doc.Clone();

            Assert.IsNotNull(doc.getDocumentElement());
            Assert.IsNotNull(doc2.getDocumentElement());
            Assert.AreNotEqual(doc.getDocumentElement(), doc2.getDocumentElement());
            KElement e = doc.getRoot();

            e.setAttribute("foo", "bar");
            Assert.IsTrue(e.hasAttribute("foo"));
            KElement e2 = doc2.getRoot();

            Assert.IsFalse(e2.hasAttribute("foo"));
            Assert.AreEqual(doc.getDoctype(), doc2.getDoctype());
            Assert.AreEqual(e2.getOwnerDocument_KElement(), doc2);
            Assert.AreNotEqual(doc.getXMLDocUserData(), doc2.getXMLDocUserData());
        }