[LoongArch64] Part-5:add loongarch support in some files for LoongArch64. (#21769)
[mono-project.git] / mcs / class / System.XML / Test / System.Xml / nist_dom / fundamental / Document / Document.cs
blob0fa455b8b72b9189cf8855bebe668ea162ef4fc6
1 //**************************************************************************
2 //
3 //
4 // National Institute Of Standards and Technology
5 // DTS Version 1.0
6 //
7 // Document Interface
8 //
9 // Written by: Carmelo Montanez
10 // Modified by: Mary Brady
12 // Ported to System.Xml by: Mizrahi Rafael rafim@mainsoft.com
13 // Mainsoft Corporation (c) 2003-2004
14 //**************************************************************************
15 using System;
16 using System.Xml;
18 using nist_dom;
19 using NUnit.Framework;
21 namespace nist_dom.fundamental
23 [TestFixture]
24 public class DocumentTest
26 public static int i = 2;
28 public testResults[] RunTests()
30 testResults[] tests = new testResults[] {core0001D(), core0002D(), core0003D(), core0004D(),
31 core0005D(), core0006D(), core0007D(), core0008D(),
32 core0009D(), core0010D(), core0011D(), core0012D(),
33 core0013D(), core0014D(), core0015D(),
34 core0019D(), core0020D(),
35 core0021D(), core0022D(), core0023D(), core0024D(),
36 core0025D()};
38 return tests;
43 //------------------------ test case core-0001T ------------------------
45 // Testing feature - The doctype attribute contains the Document Type
46 // Declaration associated with this Document.
48 // Testing approach - Retrieve the entire DOM document and invoke its
49 // doctype attribute. It should return the Document
50 // type of this document. Its document Type name
51 // should be equal to "staff".
52 //
53 // Semantic Requirements: 1
55 //----------------------------------------------------------------------------
57 [Test]
58 public void core0001D()
60 string computedValue = "";
61 string expectedValue = "staff";
62 System.Xml.XmlDocument testNode = null;
64 testResults results = new testResults("Core0001D");
66 results.description = "The doctype attribute contains the Document Type "+
67 "Declaration associated with this object.";
69 // Retrieve the targeted data and access its "doctype" attribute.
71 testNode = util.getDOMDocument();
72 System.Xml.XmlDocumentType dtype = testNode.DocumentType;
73 computedValue = dtype.Name;
76 // Write out results.
78 results.expected = expectedValue;
79 results.actual = computedValue;
81 Assert.AreEqual (results.expected, results.actual);
84 //------------------------ End test case core-0001D --------------------------
86 //-------------------------- test case core-0002D ----------------------------
88 // Testing feature - The doctype attribute returns null for HTML documents.
90 // Testing approach - Retrieve the an HTML DOM document and invoke its
91 // doctype attribute. It should return null.
93 // Semantic Requirements: 2
95 //----------------------------------------------------------------------------
97 [Test]
98 public void core0002D()
100 string testName = "core-0002D";
101 object computedValue = null;
102 object expectedValue = null;
103 System.Xml.XmlDocument testNode = null;
105 testResults results = new testResults("Core0002D");
107 results.description = "The doctype attribute returns null for HTML "+
108 "documents";
110 // Retrieve the targeted data and access its "doctype" attribute.
112 testNode = util.getDOMHTMLDocument();
113 computedValue = (testNode.DocumentType == null).ToString();
115 // Write out results.
117 results.expected = (expectedValue == null).ToString();
118 results.actual = computedValue.ToString();
120 Assert.AreEqual (results.expected, results.actual);
123 //------------------------ End test case core-0002D --------------------------
125 //-------------------------- test case core-0003D ----------------------------
127 // Testing feature - The doctype attribute returns null for XML documents
128 // without a document type declaration.
130 // Testing approach - Retrieve an XML DOM document without a Document
131 // Type Declaration and invoke its doctype attribute.
132 // It should return null.
134 // Semantic Requirements: 2
136 //----------------------------------------------------------------------------
138 [Test]
139 public void core0003D()
141 object computedValue = null;
142 object expectedValue = null;
143 System.Xml.XmlDocument testNode = null;
145 testResults results = new testResults("Core0003D");
147 results.description = "The doctype attribute returns null for XML "+
148 " documents without a Document Type Declaration.";
150 // Retrieve the targeted data and access its "doctype" attribute.
152 testNode = util.getnoDTDXMLDocument();
153 computedValue = (testNode.DocumentType == null).ToString();
155 // Write out results.
157 results.expected = (expectedValue == null).ToString();
158 results.actual = computedValue.ToString();
160 Assert.AreEqual (results.expected, results.actual);
163 //------------------------ End test case core-0003D --------------------------
165 //-------------------------- test case core-0004D ----------------------------
167 // Testing feature - The implementation attribute contains the
168 // DOMImplementation object that handles this document.
170 // Testing approach - Retrieve the entire DOM document and invoke its
171 // "implementation" attribute. It should return a
172 // DOMImplementation object whose "hasFeature("XML,"1.0")
173 // method is invoke and a true value expected.
175 // Semantic Requirements: 3
177 //----------------------------------------------------------------------------
179 [Test]
180 public void core0004D()
182 string computedValue = "";
183 string expectedValue = "True";
184 System.Xml.XmlImplementation domImp = null;
185 System.Xml.XmlDocument testNode = null;
187 testResults results = new testResults("Core0004D");
189 results.description = "The implementation attribute contains the "+
190 "DOMImplementation object that handles this"+
191 " document.";
193 // Retrieve the targeted data and access its "implementation" attribute.
195 testNode = util.getDOMDocument();
196 domImp = testNode.Implementation;
198 // The "hasFeature" method should return true.
200 computedValue = domImp.HasFeature("XML","1.0").ToString();
202 // Write out results.
204 results.expected = expectedValue;
205 results.actual = computedValue;
207 Assert.AreEqual (results.expected, results.actual);
210 //------------------------ End test case core-0004D --------------------------
212 //-------------------------- test case core-0005D ----------------------------
214 // Testing feature - The documentElement attribute provides direct access
215 // to the child node that is the root element of the
216 // document.
218 // Testing approach - Retrieve the entire DOM document and invoke its
219 // "documentElement" attribute. It should return an
220 // Element node whose "tagName" attribute is "staff".
222 // Semantic Requirements: 4
224 //----------------------------------------------------------------------------
226 [Test]
227 public void core0005D()
229 string computedValue = "";
230 string expectedValue = "staff";
231 System.Xml.XmlElement rootNode = null;
232 System.Xml.XmlDocument testNode = null;
234 testResults results = new testResults("Core0005D");
236 results.description = "The documentElement attribute provides direct "+
237 "to the root node of the document.";
239 // Retrieve the targeted data and access its "documentElement" attribute.
241 testNode = util.getDOMDocument();
242 rootNode = testNode.DocumentElement;
244 // Its tagName should be set to "staff".
246 computedValue = rootNode.Name;//tagName;
248 // Write out results.
250 results.expected = expectedValue;
251 results.actual = computedValue;
253 Assert.AreEqual (results.expected, results.actual);
256 //------------------------ End test case core-0005D --------------------------
258 //-------------------------- test case core-0006D ----------------------------
260 // Testing feature - For HTML documents, the documentElement attribute returns
261 // the Element with the HTML tag.
263 // Testing approach - Retrieve an HTML DOM document and invoke its
264 // "documentElement" attribute. It should return the
265 // Element whose "tagName" is "HTML".
267 // Semantic Requirements: 5
269 //----------------------------------------------------------------------------
271 [Test]
272 [Ignore(".NET DOM implementation does not match W3C DOM specification.")] // MS DOM is buggy
273 public void core0006D()
275 string computedValue = "";
276 string expectedValue = "HTML";
277 System.Xml.XmlElement rootNode = null;
278 System.Xml.XmlDocument testNode = null;
280 testResults results = new testResults("Core0006D");
282 results.description = "For HTML documents, the documentElement attribute "+
283 "returns the element with the HTML tag.";
285 // Retrieve the targeted data and access its "documentElement" attribute.
287 testNode = util.getDOMHTMLDocument();
288 rootNode = testNode.DocumentElement;
290 // Its tagName should be set to "HTML".
292 computedValue = rootNode.Name;//tagName;
294 // Write out results.
296 results.expected = expectedValue;
297 results.actual = computedValue;
299 Assert.AreEqual (results.expected, results.actual);
302 //------------------------ End test case core-0006D --------------------------
304 //-------------------------- test case core-0007D ----------------------------
306 // Testing feature - The "createElement(tagName)" method creates an Element of
307 // the type specified.
309 // Testing approach - Retrieve the entire DOM document and invoke its
310 // "createElement(tagName)" method with tagName="address".
311 // The method should create an instance of an Element
312 // node whose tagName is "address". The type, value and
313 // are further checked.
315 // Semantic Requirements: 6
317 //----------------------------------------------------------------------------
319 [Test]
320 public void core0007D()
322 string computedValue = "";
323 string expectedValue = "address Element ";
324 System.Xml.XmlElement newElement = null;
325 System.Xml.XmlDocument testNode = null;
327 testResults results = new testResults("Core0007D");
329 results.description = "The \"createElement(tagName)\" method creates an "+
330 "Element of the specified type.";
332 // Retrieve the targeted data and invoke its "createElement" attribute.
334 testNode = util.getDOMDocument();
335 newElement = testNode.CreateElement("address");
337 // Retrieve the characteristics of this new object.
339 computedValue = newElement.Name+" ";//tagName
340 computedValue += newElement.NodeType +" ";
341 computedValue += newElement.Value;
343 // Write out results.
345 results.expected = expectedValue;
346 results.actual = computedValue;
348 util.resetData();
349 Assert.AreEqual (results.expected, results.actual);
352 //------------------------ End test case core-0007D --------------------------
354 //-------------------------- test case core-0008D ----------------------------
356 // Testing feature - The tagName parameter in the "createElement(tagName)"
357 // method is case-sensitive for XML documents.
359 // Testing approach - Retrieve the entire DOM document and invoke its
360 // "createElement(tagName)" method twice for tagName
361 // equal "address" and "ADDRESS". Each call should
362 // create two distinct Element nodes. Each Element
363 // is in turn assigned an attribute and then that
364 // attribute is retrieved.
366 // Semantic Requirements: 7
368 //----------------------------------------------------------------------------
370 [Test]
371 public void core0008D()
373 string computedValue = "";
374 string expectedValue = "Fort Worth Dallas";
375 System.Xml.XmlElement newElement1 = null;
376 System.Xml.XmlElement newElement2 = null;
377 System.Xml.XmlDocument testNode = null;
379 testResults results = new testResults("Core0008D");
381 results.description = "The tagName parameter in the \"createElement( "+
382 "tagName)\" method is case-sensitive for XML "+
383 "documents.";
385 // Retrieve the targeted data and invoke its "createElement" method.
387 testNode = util.getDOMDocument();
388 newElement1 = testNode.CreateElement("ADDRESS");
389 newElement2 = testNode.CreateElement("address");
391 // Assign attributes for each one of the created Elements.
393 newElement1.SetAttribute("district","Fort Worth");
394 newElement2.SetAttribute("county","Dallas");
396 // Now retrieve the values of each Element's attribute.
398 computedValue += newElement1.GetAttribute("district")+" ";
399 computedValue += newElement2.GetAttribute("county");
401 // Write out results.
403 results.expected = expectedValue;
404 results.actual = computedValue;
406 util.resetData();
407 Assert.AreEqual (results.expected, results.actual);
410 //------------------------ End test case core-0008D --------------------------
412 //-------------------------- test case core-0009D ----------------------------
414 // Testing feature - The "createDocumentFragment()" method creates an
415 // empty DocumentFragment object.
417 // Testing approach - Retrieve the entire DOM document and invoke its
418 // createDocumentFragment() method. The content, name,
419 // type and value of the newly created object are
420 // further retrieved and checked.
422 // Semantic Requirements: 8
424 //----------------------------------------------------------------------------
426 [Test]
427 public void core0009D()
429 string computedValue = "";
430 string expectedValue = "0 #document-fragment DocumentFragment ";//"0 #document-fragment 11 null";
431 System.Xml.XmlDocumentFragment newDocFragment = null;
432 System.Xml.XmlDocument testNode = null;
434 testResults results = new testResults("Core0009D");
436 results.description = "The \"createDocumentFragment()\" method creates "+
437 "an empty DocumentFragment object.";
439 // Retrieve the targeted data and invoke its "createDocumentFragment()"
440 // method.
442 testNode = util.getDOMDocument();
443 newDocFragment = testNode.CreateDocumentFragment();
445 // Retrieve the characterstics of the newly created object.
447 computedValue += newDocFragment.ChildNodes.Count +" ";
448 computedValue += newDocFragment.Name+" ";
449 computedValue += newDocFragment.NodeType+" ";
450 computedValue += newDocFragment.Value;
452 // Write out results.
454 results.expected = expectedValue;
455 results.actual = computedValue;
457 util.resetData();
458 Assert.AreEqual (results.expected, results.actual);
461 //------------------------ End test case core-0009D --------------------------
463 //-------------------------- test case core-0010D ----------------------------
465 // Testing feature - The "createTextNode(data)" method creates a Text node
466 // given by the specified string.
468 // Testing approach - Retrieve the entire DOM document and invoke its
469 // "createTextNode(data)" method. It should create a
470 // new Text node whose data is the specified string. The
471 // name and type of the newly created object are further
472 // retrieved and checked.
474 // Semantic Requirements: 9
476 //----------------------------------------------------------------------------
478 [Test]
479 public void core0010D()
481 string computedValue = "";
482 string expectedValue = "This is a new Text node #text Text";//"This is a new Text node #text 3";
483 System.Xml.XmlText newTextNode = null;
484 System.Xml.XmlDocument testNode = null;
486 testResults results = new testResults("Core0010D");
488 results.description = "The \"createTextNode(data)\" method creates "+
489 "a Text node given by the specified string.";
491 // Retrieve the targeted data and invoke its "createTextNode(data)" method.
493 testNode = util.getDOMDocument();
494 newTextNode = testNode.CreateTextNode("This is a new Text node");
496 // Retrieve the characteristics of the newly created object.
498 computedValue += newTextNode.Data+" ";
499 computedValue += newTextNode.Name+" ";
500 computedValue += newTextNode.NodeType;
502 // Write out results.
504 results.expected = expectedValue;
505 results.actual = computedValue;
507 util.resetData();
508 Assert.AreEqual (results.expected, results.actual);
511 //------------------------ End test case core-0010D --------------------------
513 //-------------------------- test case core-0011D ----------------------------
515 // Testing feature - The "createComment(data)" method creates a new Comment
516 // node given the specified string.
518 // Testing approach - Retrieve the entire DOM document and invoke its
519 // "createComment(data)" method. It should create a
520 // new Comment node whose data is the specified string.
521 // The content, name and type of the newly created
522 // object are further retrieved and examined.
524 // Semantic Requirements: 10
526 //----------------------------------------------------------------------------
528 [Test]
529 public void core0011D()
531 string computedValue = "";
532 string expectedValue = "This is a new Comment node #comment Comment";//"This is a new Comment node #comment 8";
533 System.Xml.XmlComment newCommentNode = null;
534 System.Xml.XmlDocument testNode = null;
536 testResults results = new testResults("Core0011D");
538 results.description = "The \"createComment(data)\" method creates "+
539 "a new comment node given by the specified string.";
541 // Retrieve the targeted data and invoke its "createComment(data)" method.
543 testNode = util.getDOMDocument();
544 newCommentNode = testNode.CreateComment("This is a new Comment node");
546 // Retrieve the characteristics of the new object.
548 computedValue += newCommentNode.Data+" ";
549 computedValue += newCommentNode.Name+" ";
550 computedValue += newCommentNode.NodeType;
552 // Write out results.
554 results.expected = expectedValue;
555 results.actual = computedValue;
557 util.resetData();
558 Assert.AreEqual (results.expected, results.actual);
561 //------------------------ End test case core-0011D --------------------------
563 //-------------------------- test case core-0012D ----------------------------
565 // Testing feature - The "createCDATASection(data)" method creates a new
566 // CDATASection node whose value is the specified string.
568 // Testing approach - Retrieve the entire DOM document and invoke its
569 // "createCDATASection(data)" method. It should create a
570 // new CDATASection node whose data is the specified string.
571 // The content, name and type of the newly created
572 // object are further retrieved and examined.
574 // Semantic Requirements: 11
576 //----------------------------------------------------------------------------
578 [Test]
579 public void core0012D()
581 string computedValue = "";
582 string expectedValue = "This is a new CDATASection node #cdata-section CDATA";//"This is a new CDATASection node #cdata-section 4";
583 System.Xml.XmlCDataSection newCDATASectionNode = null;
584 System.Xml.XmlDocument testNode = null;
586 testResults results = new testResults("Core0012D");
588 results.description = "The \"createCDATASection(data)\" method creates "+
589 "a new CDATASection node whose value is the "+
590 "specified string.";
592 // Retrieve the targeted data and invoke its "createCDATASection(data)"
593 // method.
595 testNode = util.getDOMDocument();
596 newCDATASectionNode = testNode.CreateCDataSection("This is a new CDATASection node");
598 // Retrieve the characteristics of the new object.
600 computedValue += newCDATASectionNode.Data+" ";
601 computedValue += newCDATASectionNode.Name+" ";
602 computedValue += newCDATASectionNode.NodeType;
604 // Write out results.
606 results.expected = expectedValue;
607 results.actual = computedValue;
609 util.resetData();
610 Assert.AreEqual (results.expected, results.actual);
613 //------------------------ End test case core-0012D --------------------------
615 //-------------------------- test case core-0013D ----------------------------
617 // Testing feature - The "createProcessingInstruction(target,data)" method
618 // creates a new ProcessingInstruction node with the
619 // specified name and data strings.
621 // Testing approach - Retrieve the entire DOM document and invoke its
622 // "createProcessingInstruction(target,data)" method. It
623 // should create a new PI node with the specified target
624 // and data. The target, data and type of the newly created
625 // object are further retrieved and examined.
627 // Semantic Requirements: 12
629 //----------------------------------------------------------------------------
631 [Test]
632 public void core0013D()
634 string computedValue = "";
635 string expectedValue = "XML This is a new PI node ProcessingInstruction";//"XML This is a new PI node 7";
636 System.Xml.XmlProcessingInstruction newPINode = null;
637 System.Xml.XmlDocument testNode = null;
639 testResults results = new testResults("Core0013D");
641 results.description = "The \"createProcessingInstruction(target,data)\" "+
642 "method creates a new processingInstruction node.";
644 // Retrieve the targeted data and invoke its
645 // "createProcessingInstruction(target,data)" method.
647 testNode = util.getDOMDocument();
648 newPINode = testNode.CreateProcessingInstruction("XML","This is a new PI node");
650 // Retrieve the characteristics of the new object.
652 computedValue += newPINode.Target+" ";
653 computedValue += newPINode.Data+" ";
654 computedValue += newPINode.NodeType;
656 // Write out results.
658 results.expected = expectedValue;
659 results.actual = computedValue;
661 util.resetData();
662 Assert.AreEqual (results.expected, results.actual);
665 //------------------------ End test case core-0013D --------------------------
667 //-------------------------- test case core-0014D ----------------------------
669 // Testing feature - The "createAttribute(name)" method creates an Attr
670 // node of the given name.
672 // Testing approach - Retrieve the entire DOM document and invoke its
673 // "createAttribute(name)" method. It should create a
674 // new Attr node with the given name. The name, value
675 // and type of the newly created object are further
676 // retrieved and examined.
678 // Semantic Requirements: 13
680 //----------------------------------------------------------------------------
682 [Test]
683 public void core0014D()
685 string computedValue = "";
686 string expectedValue = "district Attribute";//"district 2";
687 System.Xml.XmlAttribute newAttrNode = null;
688 System.Xml.XmlDocument testNode = null;
690 testResults results = new testResults("Core0014D");
692 results.description = "The \"createAttribute(name)\" method creates "+
693 "a new Attr node of the given name.";
695 // Retrieve the targeted data and invoke its "createAttribute(name)"
696 // method.
698 testNode = util.getDOMDocument();
699 newAttrNode = testNode.CreateAttribute("district");
701 // Retrieve the characteristics of the new object.
703 computedValue += newAttrNode.Name+" ";
704 computedValue += newAttrNode.Value;
705 computedValue += newAttrNode.NodeType;
707 // Write out results.
709 results.expected = expectedValue;
710 results.actual = computedValue;
712 util.resetData();
713 Assert.AreEqual (results.expected, results.actual);
716 //------------------------ End test case core-0014D --------------------------
718 //-------------------------- test case core-0015D ----------------------------
720 // Testing feature - The "createEntityReference(name)" method creates an
721 // EntityReference node.
723 // Testing approach - Retrieve the entire DOM document and invoke its
724 // "createEntityReference(name)" method. It should
725 // create a new EntityReference node for the Entity
726 // with the given name. The name, value and type of
727 // the newly created object are further retrieved
728 // and examined.
730 // Semantic Requirements: 14
732 //----------------------------------------------------------------------------
734 [Test]
735 public void core0015D()
737 string computedValue = "";
738 string expectedValue = "ent1 EntityReference";//"ent1 null 5";
739 System.Xml.XmlEntityReference newEntRefNode = null;
740 System.Xml.XmlDocument testNode = null;
742 testResults results = new testResults("Core0015D");
744 results.description = "The \"createEntityReference(name)\" method creates "+
745 "a new EntityReference node.";
747 // Retrieve the targeted data and invoke its "createEntityReference(name)"
748 // method.
750 testNode = util.getDOMDocument();
751 newEntRefNode = testNode.CreateEntityReference("ent1");
753 // Retrieve the characteristics of the new object.
755 computedValue += newEntRefNode.Name+" ";
756 computedValue += newEntRefNode.Value+" ";
757 computedValue += newEntRefNode.NodeType;
759 // Write out results.
761 results.expected = expectedValue;
762 results.actual = computedValue;
764 util.resetData();
765 Assert.AreEqual (results.expected, results.actual);
768 //------------------------ End test case core-0015D --------------------------
770 //-------------------------- test case core-0016D ----------------------------
772 // Testing feature - The "getElementsByTagName(tagName)" method returns a
773 // NodeList of all the Elements with a given tagName.
775 // Testing approach - Retrieve the entire DOM document and invoke its
776 // "getElementsByTagName(tagName)" method with tagName
777 // equal to "name". The method should return a NodeList
778 // that contains 5 elements.
780 // Semantic Requirements: 15
782 //----------------------------------------------------------------------------
784 [Test]
785 public void core0016D()
787 string computedValue = "0";//0;
788 string expectedValue = "5";//5;
789 System.Xml.XmlDocument testNode = null;
791 testResults results = new testResults("Core0016D");
793 results.description = "The \"getElementsByTagName(tagName)\" method "+
794 "returns a NodeList of all the Elements with a "+
795 "given tag name.";
797 // Retrieve the targeted data and invoke its "getElementsByTagName(tagName)"
798 // method.
800 testNode = util.getDOMDocument();
801 System.Xml.XmlNodeList elementList = testNode.GetElementsByTagName("name");
803 // Retrieve the length of the list.
805 computedValue = elementList.Count.ToString();
807 // Write out results.
809 results.expected = expectedValue;
810 results.actual = computedValue;
812 util.resetData();
813 Assert.AreEqual (results.expected, results.actual);
816 //------------------------ End test case core-0016D --------------------------
818 //-------------------------- test case core-0017D ----------------------------
820 // Testing feature - The "getElementsByTagName(tagName)" method returns a
821 // NodeList of all the Elements with a given tagName in
822 // a pre-order traversal of the tree.
824 // Testing approach - Retrieve the entire DOM document and invoke its
825 // "getElementsByTagName(tagName)" method with tagName
826 // equal to "name". The method should return a NodeList
827 // that contains 5 elements. Further the fourth item in
828 // the list is retrieved and checked.
830 // Semantic Requirements: 16
832 //----------------------------------------------------------------------------
834 [Test]
835 public void core0017D()
837 string computedValue = "0";//0;
838 string expectedValue = "Jeny Oconnor";
839 System.Xml.XmlDocument testNode = null;
841 testResults results = new testResults("Core0017D");
843 results.description = "The \"getElementsByTagName(tagName)\" method "+
844 "returns a NodeList of all the Elements with a "+
845 "given tag name in a preorder traversal of the tree.";
847 // Retrieve the targeted data and invoke its "getElementsByTagName(tagName)"
848 // method.
850 testNode = util.getDOMDocument();
851 System.Xml.XmlNodeList elementList = testNode.GetElementsByTagName("name");
853 // Retrieve the fourth item and its data.
855 computedValue = elementList.Item(util.FOURTH).FirstChild.Value;//Data;
857 // Write out results.
859 results.expected = expectedValue;
860 results.actual = computedValue;
862 util.resetData();
863 Assert.AreEqual (results.expected, results.actual);
866 //------------------------ End test case core-0017D --------------------------
868 //-------------------------- test case core-0018D ----------------------------
870 // Testing feature - The "getElementsByTagName(tagName)" method returns a
871 // NodeList of all the Elements in the tree when the
872 // tagName is equal to "*".
874 // Testing approach - Retrieve the entire DOM document and invoke its
875 // "getElementsByTagName(tagName)" method with tagName
876 // equal to "*". The method should return a NodeList
877 // that contains 41 elements, which is the total number
878 // of Elements in the document.
880 // Semantic Requirements: 17
882 //----------------------------------------------------------------------------
885 [Test]
886 public void core0018D()
888 string computedValue = "0";//0;
889 // Mmm, shouldn't the count be 36?
890 string expectedValue = "36";//37;
891 System.Xml.XmlDocument testNode = null;
893 testResults results = new testResults("Core0018D");
895 results.description = "The \"getElementsByTagName(tagName)\" method "+
896 "returns a NodeList of all the Elements in the "+
897 "tree when the tag name is equal to \"*\".";
899 // Retrieve the targeted data and invoke its "getElementsByTagName(tagName)"
900 // method.
902 testNode = util.getDOMDocument();
903 System.Xml.XmlNodeList elementList = testNode.GetElementsByTagName("*");
905 // Retrieve the length of the list.
907 computedValue = elementList.Count.ToString();
909 // Write out results.
912 results.expected = expectedValue;
913 results.actual = computedValue;
915 util.resetData();
916 Assert.AreEqual (results.expected, results.actual);
919 //------------------------ End test case core-0018D --------------------------
921 //------------------------- test case core-0019D -----------------------------
923 // Testing feature - The "createElement(tagName)" method raises an
924 // INVALID_CHARACTER_ERR Exception if the
925 // specified name contains an invalid character.
927 // Testing approach - Retrieve the entire DOM document and invoke its
928 // "createElement(tagName)" method with the tagName
929 // equals to the string "invalid^Name" which contains
930 // an invalid character ("^") in it. The desired
931 // exception should be raised.
933 // Semantic Requirements: 18
935 //----------------------------------------------------------------------------
937 [Test]
938 [Ignore(".NET DOM implementation does not match W3C DOM specification.")] // MS DOM is buggy
939 public void core0019D()
941 string computedValue = "";
942 System.Xml.XmlDocument testNode = null;
943 System.Xml.XmlElement invalidElement = null;
944 string expectedValue = util.INVALID_CHARACTER_ERR;
946 testResults results = new testResults("Core0019D");
948 results.description = "The \"createElement(tagName)\" method raises an "+
949 "INVALID_CHARACTER_ERR Exception if the "+
950 "specified name contains an invalid character.";
952 // Retrieve the targeted data.
954 testNode = util.getDOMDocument();
956 // Attempt to create an Element with an invalid tagName should raise
957 // an exception.
959 try
961 invalidElement = testNode.CreateElement("invalid^Name");
963 catch(System.Exception ex)
965 computedValue = ex.GetType ().FullName;
969 // Write out results.
971 results.expected = typeof (XmlException).FullName; // MS.NET BUG: It never raises an error.
972 results.actual = computedValue;
974 util.resetData();
975 Assert.AreEqual (results.expected, results.actual);
978 //------------------------ End test case core-0019D -------------------------
980 //------------------------- test case core-0020D -----------------------------
982 // Testing feature - The "createAttribute(name)" method raises an
983 // INVALID_CHARACTER_ERR Exception if the
984 // specified name contains an invalid character.
986 // Testing approach - Retrieve the entire DOM document and invoke its
987 // "createAttribute(name)" method with the name
988 // equals to the string "invalid^Name" which contains
989 // an invalid character ("^") in it. The desired
990 // exception should be raised.
992 // Semantic Requirements: 19
994 //----------------------------------------------------------------------------
996 [Test]
997 [Ignore(".NET DOM implementation does not match W3C DOM specification.")] // MS DOM is buggy
998 public void core0020D()
1000 string computedValue = "";
1001 string expectedValue = util.INVALID_CHARACTER_ERR;
1002 System.Xml.XmlDocument testNode = null;
1003 System.Xml.XmlAttribute invalidAttr = null;
1005 testResults results = new testResults("Core0020D");
1007 results.description = "The \"createAttribute(name)\" method raises an "+
1008 "INVALID_CHARACTER_ERR Exception if the "+
1009 "specified name contains an invalid character.";
1011 // Retrieve the targeted data.
1013 testNode = util.getDOMDocument();
1015 // Attempt to create an Attr node with an invalid name should raise
1016 // an exception.
1018 try
1020 invalidAttr = testNode.CreateAttribute("invalid^Name");
1022 catch(System.Exception ex)
1024 computedValue = ex.GetType ().FullName;
1028 // Write out results.
1030 results.expected = typeof (ArgumentException).FullName; // MS.NET BUG: It never raises an error.
1031 results.actual = computedValue;
1033 util.resetData();
1034 Assert.AreEqual (results.expected, results.actual);
1037 //------------------------ End test case core-0020D -------------------------
1039 //------------------------- test case core-0021D -----------------------------
1041 // Testing feature - The "createEntityReference(name)" method raises an
1042 // INVALID_CHARACTER_ERR Exception if the
1043 // specified name contains an invalid character.
1045 // Testing approach - Retrieve the entire DOM document and invoke its
1046 // "createEntityReference(name)" method with the name
1047 // equals to the string "invalid^Name" which contains
1048 // an invalid character ("^") in it. The desired
1049 // exception should be raised.
1051 // Semantic Requirements: 20
1053 //----------------------------------------------------------------------------
1055 [Test]
1056 [Ignore(".NET DOM implementation does not match W3C DOM specification.")] // MS DOM is buggy
1057 public void core0021D()
1059 string computedValue = "";
1060 string expectedValue = "System.Xml.XmlException";//util.INVALID_CHARACTER_ERR;
1061 System.Xml.XmlDocument testNode = null;
1062 System.Xml.XmlEntityReference invalidEntRef = null;
1064 testResults results = new testResults("Core0021D");
1066 results.description = "The \"createEntityReference(name)\" method raises "+
1067 "an INVALID_CHARACTER_ERR Exception if the "+
1068 "specified name contains an invalid character.";
1070 // Retrieve the targeted data.
1072 testNode = util.getDOMDocument();
1074 // Attempt to create an EntityReference node with an invalid name should
1075 // raise an exception.
1077 try
1079 invalidEntRef = testNode.CreateEntityReference("invalid^Name");
1081 catch(XmlException ex)
1083 computedValue = ex.GetType ().FullName;
1086 // Write out results.
1088 results.expected = expectedValue;
1089 results.actual = computedValue;
1091 util.resetData();
1092 Assert.AreEqual (results.expected, results.actual);
1095 //------------------------ End test case core-0021D -------------------------
1097 //------------------------- test case core-0022D ----------------------------
1099 // Testing feature - The "createProcessingInstruction(target,data)" method
1100 // raises an INVALID_CHARACTER_ERR Exception if an
1101 // invalid character was specified. (test for invalid
1102 // target)
1104 // Testing approach - Retrieve the entire DOM document and invoke its
1105 // "createProcessingInstruction(target,data)" method with
1106 // the target equals to the string "invalid^target" which
1107 // contains an invalid character ("^") in it. The desired
1108 // exception should be raised.
1110 // Semantic Requirements: 21
1112 //----------------------------------------------------------------------------
1114 [Test]
1115 [Ignore(".NET DOM implementation does not match W3C DOM specification.")] // MS DOM is buggy
1116 public void core0022D()
1118 string computedValue = "";
1119 string expectedValue = "System.Xml.XmlException";//util.INVALID_CHARACTER_ERR;
1120 System.Xml.XmlDocument testNode = null;
1121 System.Xml.XmlProcessingInstruction invalidPI = null;
1123 testResults results = new testResults("Core0022D");
1125 results.description = "The \"createProcessingInstruction(target,data)\" "+
1126 "method raises an INVALID_CHARACTER_ERR "+
1127 "DOMException if an invalid character was specified "+ "(invalid target).";
1129 // Retrieve the targeted data.
1131 testNode = util.getDOMDocument();
1133 // Attempt to create a ProcessingInstruction node with an invalid
1134 // target name should raise an exception.
1136 try
1138 invalidPI = testNode.CreateProcessingInstruction("invalid^target","data");
1140 catch(XmlException ex)
1142 computedValue = ex.GetType ().FullName;
1146 // Write out results.
1148 results.expected = expectedValue;
1149 results.actual = computedValue;
1151 util.resetData();
1152 Assert.AreEqual (results.expected, results.actual);
1155 //------------------------ End test case core-0022D -------------------------
1157 //------------------------- test case core-0023D ----------------------------
1159 // Testing feature - The "createCDATASection(data)" method raises a
1160 // NOT_SUPPORTED_ERR Exception if this is an
1161 // HTML document.
1163 // Testing approach - Retrieve an HTML based DOM document and invoke its
1164 // "createCDATASection(data)" method. Since this DOM
1165 // document was based on an HTML document, the desired
1166 // exception should be raised.
1168 // System.Xml - Microsoft System.Xml does not supporting this requirement
1170 // Semantic Requirements: 22
1172 //----------------------------------------------------------------------------
1174 [Test]
1175 public void core0023D()
1177 string computedValue = "";
1178 string expectedValue = "";//util.NOT_SUPPORTED_ERR;
1179 System.Xml.XmlDocument testNode = null;
1180 System.Xml.XmlCDataSection invalidCData = null;
1182 testResults results = new testResults("Core0023D");
1184 results.description = "The \"createCDATASection(data)\" method raises "+
1185 "a NOT_SUPPORTED_ERR Exception if this is "+
1186 "an HTML document.";
1188 // Retrieve the targeted data.
1190 testNode = util.getDOMHTMLDocument();
1192 // Attempt to create a CDATASection node for an HTML based DOM Document
1193 // should raise an exception.
1195 try
1197 invalidCData = testNode.CreateCDataSection("This is a new CDATA Section");
1199 catch(System.Exception ex)
1201 computedValue = ex.GetType () + " : " + ex.Message;
1204 // Write out results.
1206 results.expected = expectedValue;
1207 results.actual = computedValue;
1209 util.resetData();
1210 Assert.AreEqual (results.expected, results.actual);
1213 //------------------------ End test case core-0023D -------------------------
1215 //------------------------- test case core-0024D ----------------------------
1217 // Testing feature - The "createProcessingInstruction(target,data)" method
1218 // raises a NOT_SUPPORTED_ERR Exception if this is an
1219 // HTML document.
1221 // Testing approach - Retrieve an HTML based DOM document and invoke its
1222 // "createProcessingInstruction(target,data)" method.
1223 // Since this DOM document was based on an HTML document,
1224 // the desired exception should be raised.
1226 // System.Xml - Microsoft System.Xml does not supporting this requirement
1227 // Semantic Requirements: 23
1229 //----------------------------------------------------------------------------
1231 [Test]
1232 public void core0024D()
1234 string computedValue = "";
1235 string expectedValue = "";//util.NOT_SUPPORTED_ERR;
1236 System.Xml.XmlDocument testNode = null;
1237 System.Xml.XmlProcessingInstruction invalidPI = null;
1239 testResults results = new testResults("Core0024D");
1241 results.description = "The \"createProcessingInstruction(target,data)\" "+
1242 "method raises a NOT_SUPPORTED_ERR Exception "+
1243 "if this is an HTML document.";
1245 // Retrieve the targeted data.
1247 testNode = util.getDOMHTMLDocument();
1249 // Attempt to create a ProcessingInstruction node for an HTML based DOM
1250 // Document should raise an exception.
1252 try
1254 invalidPI = testNode.CreateProcessingInstruction("XML","This is a new PI node");
1256 catch(System.Exception ex)
1258 computedValue = ex.GetType () + " : " + ex.Message;
1261 // Write out results.
1263 results.expected = expectedValue;
1264 results.actual = computedValue;
1266 util.resetData();
1267 Assert.AreEqual (results.expected, results.actual);
1270 //------------------------ End test case core-0024D -------------------------
1272 //------------------------- test case core-0025D ----------------------------
1274 // Testing feature - The "createEntityReference(data)" method raises
1275 // a NOT_SUPPORTED_ERR Exception if this is an
1276 // HTML document.
1278 // Testing approach - Retrieve an HTML based DOM document and invoke its
1279 // "createEntityReference(name)" method. Since this DOM
1280 // document was based on an HTML document, the desired
1281 // exception should be raised.
1283 // System.Xml - Microsoft System.Xml does not supporting this requirement
1285 // Semantic Requirements: 24
1287 //----------------------------------------------------------------------------
1289 [Test]
1290 public void core0025D()
1292 string computedValue = "";
1293 string expectedValue = "";//util.NOT_SUPPORTED_ERR;
1294 System.Xml.XmlDocument testNode = null;
1295 System.Xml.XmlEntityReference invalidEntRef = null;
1297 testResults results = new testResults("Core0025D");
1299 results.description = "The \"createEntityReference(name)\" method raises "+
1300 "a NOT_SUPPORTED_ERR Exception if this is an "+
1301 "HTML document.";
1303 // Retrieve the targeted data.
1305 testNode = util.getDOMHTMLDocument();
1307 // Attempt to create an EntityReference node for an HTML based DOM
1308 // Document should raise an exception.
1310 try
1312 invalidEntRef = testNode.CreateEntityReference("ent1");
1314 catch(System.Exception ex)
1316 computedValue = ex.GetType().ToString();
1320 // Write out results.
1322 results.expected = expectedValue;
1323 results.actual = computedValue;
1325 util.resetData();
1326 Assert.AreEqual (results.expected, results.actual);
1329 //------------------------ End test case core-0025D -------------------------