1 //**************************************************************************
4 // National Institute Of Standards and Technology
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 //**************************************************************************
19 using NUnit
.Framework
;
21 namespace nist_dom
.fundamental
24 public class DocumentTest
: Assertion
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(),
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".
53 // Semantic Requirements: 1
55 //----------------------------------------------------------------------------
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
;
78 results
.expected
= expectedValue
;
79 results
.actual
= computedValue
;
81 AssertEquals (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 //----------------------------------------------------------------------------
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 "+
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 AssertEquals (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 //----------------------------------------------------------------------------
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 AssertEquals (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 //----------------------------------------------------------------------------
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"+
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 AssertEquals (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
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 //----------------------------------------------------------------------------
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 AssertEquals (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 //----------------------------------------------------------------------------
272 public void core0006D()
274 string computedValue
= "";
275 string expectedValue
= "HTML";
276 System
.Xml
.XmlElement rootNode
= null;
277 System
.Xml
.XmlDocument testNode
= null;
279 testResults results
= new testResults("Core0006D");
281 results
.description
= "For HTML documents, the documentElement attribute "+
282 "returns the element with the HTML tag.";
284 // Retrieve the targeted data and access its "documentElement" attribute.
286 testNode
= util
.getDOMHTMLDocument();
287 rootNode
= testNode
.DocumentElement
;
289 // Its tagName should be set to "HTML".
291 computedValue
= rootNode
.Name
;//tagName;
293 // Write out results.
295 results
.expected
= expectedValue
;
296 results
.actual
= computedValue
;
298 AssertEquals (results
.expected
, results
.actual
);
301 //------------------------ End test case core-0006D --------------------------
303 //-------------------------- test case core-0007D ----------------------------
305 // Testing feature - The "createElement(tagName)" method creates an Element of
306 // the type specified.
308 // Testing approach - Retrieve the entire DOM document and invoke its
309 // "createElement(tagName)" method with tagName="address".
310 // The method should create an instance of an Element
311 // node whose tagName is "address". The type, value and
312 // are further checked.
314 // Semantic Requirements: 6
316 //----------------------------------------------------------------------------
319 public void core0007D()
321 string computedValue
= "";
322 string expectedValue
= "address Element ";
323 System
.Xml
.XmlElement newElement
= null;
324 System
.Xml
.XmlDocument testNode
= null;
326 testResults results
= new testResults("Core0007D");
328 results
.description
= "The \"createElement(tagName)\" method creates an "+
329 "Element of the specified type.";
331 // Retrieve the targeted data and invoke its "createElement" attribute.
333 testNode
= util
.getDOMDocument();
334 newElement
= testNode
.CreateElement("address");
336 // Retrieve the characteristics of this new object.
338 computedValue
= newElement
.Name
+" ";//tagName
339 computedValue
+= newElement
.NodeType
+" ";
340 computedValue
+= newElement
.Value
;
342 // Write out results.
344 results
.expected
= expectedValue
;
345 results
.actual
= computedValue
;
348 AssertEquals (results
.expected
, results
.actual
);
351 //------------------------ End test case core-0007D --------------------------
353 //-------------------------- test case core-0008D ----------------------------
355 // Testing feature - The tagName parameter in the "createElement(tagName)"
356 // method is case-sensitive for XML documents.
358 // Testing approach - Retrieve the entire DOM document and invoke its
359 // "createElement(tagName)" method twice for tagName
360 // equal "address" and "ADDRESS". Each call should
361 // create two distinct Element nodes. Each Element
362 // is in turn assigned an attribute and then that
363 // attribute is retrieved.
365 // Semantic Requirements: 7
367 //----------------------------------------------------------------------------
370 public void core0008D()
372 string computedValue
= "";
373 string expectedValue
= "Fort Worth Dallas";
374 System
.Xml
.XmlElement newElement1
= null;
375 System
.Xml
.XmlElement newElement2
= null;
376 System
.Xml
.XmlDocument testNode
= null;
378 testResults results
= new testResults("Core0008D");
380 results
.description
= "The tagName parameter in the \"createElement( "+
381 "tagName)\" method is case-sensitive for XML "+
384 // Retrieve the targeted data and invoke its "createElement" method.
386 testNode
= util
.getDOMDocument();
387 newElement1
= testNode
.CreateElement("ADDRESS");
388 newElement2
= testNode
.CreateElement("address");
390 // Assign attributes for each one of the created Elements.
392 newElement1
.SetAttribute("district","Fort Worth");
393 newElement2
.SetAttribute("county","Dallas");
395 // Now retrieve the values of each Element's attribute.
397 computedValue
+= newElement1
.GetAttribute("district")+" ";
398 computedValue
+= newElement2
.GetAttribute("county");
400 // Write out results.
402 results
.expected
= expectedValue
;
403 results
.actual
= computedValue
;
406 AssertEquals (results
.expected
, results
.actual
);
409 //------------------------ End test case core-0008D --------------------------
411 //-------------------------- test case core-0009D ----------------------------
413 // Testing feature - The "createDocumentFragment()" method creates an
414 // empty DocumentFragment object.
416 // Testing approach - Retrieve the entire DOM document and invoke its
417 // createDocumentFragment() method. The content, name,
418 // type and value of the newly created object are
419 // further retrieved and checked.
421 // Semantic Requirements: 8
423 //----------------------------------------------------------------------------
426 public void core0009D()
428 string computedValue
= "";
429 string expectedValue
= "0 #document-fragment DocumentFragment ";//"0 #document-fragment 11 null";
430 System
.Xml
.XmlDocumentFragment newDocFragment
= null;
431 System
.Xml
.XmlDocument testNode
= null;
433 testResults results
= new testResults("Core0009D");
435 results
.description
= "The \"createDocumentFragment()\" method creates "+
436 "an empty DocumentFragment object.";
438 // Retrieve the targeted data and invoke its "createDocumentFragment()"
441 testNode
= util
.getDOMDocument();
442 newDocFragment
= testNode
.CreateDocumentFragment();
444 // Retrieve the characterstics of the newly created object.
446 computedValue
+= newDocFragment
.ChildNodes
.Count
+" ";
447 computedValue
+= newDocFragment
.Name
+" ";
448 computedValue
+= newDocFragment
.NodeType
+" ";
449 computedValue
+= newDocFragment
.Value
;
451 // Write out results.
453 results
.expected
= expectedValue
;
454 results
.actual
= computedValue
;
457 AssertEquals (results
.expected
, results
.actual
);
460 //------------------------ End test case core-0009D --------------------------
462 //-------------------------- test case core-0010D ----------------------------
464 // Testing feature - The "createTextNode(data)" method creates a Text node
465 // given by the specified string.
467 // Testing approach - Retrieve the entire DOM document and invoke its
468 // "createTextNode(data)" method. It should create a
469 // new Text node whose data is the specified string. The
470 // name and type of the newly created object are further
471 // retrieved and checked.
473 // Semantic Requirements: 9
475 //----------------------------------------------------------------------------
478 public void core0010D()
480 string computedValue
= "";
481 string expectedValue
= "This is a new Text node #text Text";//"This is a new Text node #text 3";
482 System
.Xml
.XmlText newTextNode
= null;
483 System
.Xml
.XmlDocument testNode
= null;
485 testResults results
= new testResults("Core0010D");
487 results
.description
= "The \"createTextNode(data)\" method creates "+
488 "a Text node given by the specified string.";
490 // Retrieve the targeted data and invoke its "createTextNode(data)" method.
492 testNode
= util
.getDOMDocument();
493 newTextNode
= testNode
.CreateTextNode("This is a new Text node");
495 // Retrieve the characteristics of the newly created object.
497 computedValue
+= newTextNode
.Data
+" ";
498 computedValue
+= newTextNode
.Name
+" ";
499 computedValue
+= newTextNode
.NodeType
;
501 // Write out results.
503 results
.expected
= expectedValue
;
504 results
.actual
= computedValue
;
507 AssertEquals (results
.expected
, results
.actual
);
510 //------------------------ End test case core-0010D --------------------------
512 //-------------------------- test case core-0011D ----------------------------
514 // Testing feature - The "createComment(data)" method creates a new Comment
515 // node given the specified string.
517 // Testing approach - Retrieve the entire DOM document and invoke its
518 // "createComment(data)" method. It should create a
519 // new Comment node whose data is the specified string.
520 // The content, name and type of the newly created
521 // object are further retrieved and examined.
523 // Semantic Requirements: 10
525 //----------------------------------------------------------------------------
528 public void core0011D()
530 string computedValue
= "";
531 string expectedValue
= "This is a new Comment node #comment Comment";//"This is a new Comment node #comment 8";
532 System
.Xml
.XmlComment newCommentNode
= null;
533 System
.Xml
.XmlDocument testNode
= null;
535 testResults results
= new testResults("Core0011D");
537 results
.description
= "The \"createComment(data)\" method creates "+
538 "a new comment node given by the specified string.";
540 // Retrieve the targeted data and invoke its "createComment(data)" method.
542 testNode
= util
.getDOMDocument();
543 newCommentNode
= testNode
.CreateComment("This is a new Comment node");
545 // Retrieve the characteristics of the new object.
547 computedValue
+= newCommentNode
.Data
+" ";
548 computedValue
+= newCommentNode
.Name
+" ";
549 computedValue
+= newCommentNode
.NodeType
;
551 // Write out results.
553 results
.expected
= expectedValue
;
554 results
.actual
= computedValue
;
557 AssertEquals (results
.expected
, results
.actual
);
560 //------------------------ End test case core-0011D --------------------------
562 //-------------------------- test case core-0012D ----------------------------
564 // Testing feature - The "createCDATASection(data)" method creates a new
565 // CDATASection node whose value is the specified string.
567 // Testing approach - Retrieve the entire DOM document and invoke its
568 // "createCDATASection(data)" method. It should create a
569 // new CDATASection node whose data is the specified string.
570 // The content, name and type of the newly created
571 // object are further retrieved and examined.
573 // Semantic Requirements: 11
575 //----------------------------------------------------------------------------
578 public void core0012D()
580 string computedValue
= "";
581 string expectedValue
= "This is a new CDATASection node #cdata-section CDATA";//"This is a new CDATASection node #cdata-section 4";
582 System
.Xml
.XmlCDataSection newCDATASectionNode
= null;
583 System
.Xml
.XmlDocument testNode
= null;
585 testResults results
= new testResults("Core0012D");
587 results
.description
= "The \"createCDATASection(data)\" method creates "+
588 "a new CDATASection node whose value is the "+
591 // Retrieve the targeted data and invoke its "createCDATASection(data)"
594 testNode
= util
.getDOMDocument();
595 newCDATASectionNode
= testNode
.CreateCDataSection("This is a new CDATASection node");
597 // Retrieve the characteristics of the new object.
599 computedValue
+= newCDATASectionNode
.Data
+" ";
600 computedValue
+= newCDATASectionNode
.Name
+" ";
601 computedValue
+= newCDATASectionNode
.NodeType
;
603 // Write out results.
605 results
.expected
= expectedValue
;
606 results
.actual
= computedValue
;
609 AssertEquals (results
.expected
, results
.actual
);
612 //------------------------ End test case core-0012D --------------------------
614 //-------------------------- test case core-0013D ----------------------------
616 // Testing feature - The "createProcessingInstruction(target,data)" method
617 // creates a new ProcessingInstruction node with the
618 // specified name and data strings.
620 // Testing approach - Retrieve the entire DOM document and invoke its
621 // "createProcessingInstruction(target,data)" method. It
622 // should create a new PI node with the specified target
623 // and data. The target, data and type of the newly created
624 // object are further retrieved and examined.
626 // Semantic Requirements: 12
628 //----------------------------------------------------------------------------
631 public void core0013D()
633 string computedValue
= "";
634 string expectedValue
= "XML This is a new PI node ProcessingInstruction";//"XML This is a new PI node 7";
635 System
.Xml
.XmlProcessingInstruction newPINode
= null;
636 System
.Xml
.XmlDocument testNode
= null;
638 testResults results
= new testResults("Core0013D");
640 results
.description
= "The \"createProcessingInstruction(target,data)\" "+
641 "method creates a new processingInstruction node.";
643 // Retrieve the targeted data and invoke its
644 // "createProcessingInstruction(target,data)" method.
646 testNode
= util
.getDOMDocument();
647 newPINode
= testNode
.CreateProcessingInstruction("XML","This is a new PI node");
649 // Retrieve the characteristics of the new object.
651 computedValue
+= newPINode
.Target
+" ";
652 computedValue
+= newPINode
.Data
+" ";
653 computedValue
+= newPINode
.NodeType
;
655 // Write out results.
657 results
.expected
= expectedValue
;
658 results
.actual
= computedValue
;
661 AssertEquals (results
.expected
, results
.actual
);
664 //------------------------ End test case core-0013D --------------------------
666 //-------------------------- test case core-0014D ----------------------------
668 // Testing feature - The "createAttribute(name)" method creates an Attr
669 // node of the given name.
671 // Testing approach - Retrieve the entire DOM document and invoke its
672 // "createAttribute(name)" method. It should create a
673 // new Attr node with the given name. The name, value
674 // and type of the newly created object are further
675 // retrieved and examined.
677 // Semantic Requirements: 13
679 //----------------------------------------------------------------------------
682 public void core0014D()
684 string computedValue
= "";
685 string expectedValue
= "district Attribute";//"district 2";
686 System
.Xml
.XmlAttribute newAttrNode
= null;
687 System
.Xml
.XmlDocument testNode
= null;
689 testResults results
= new testResults("Core0014D");
691 results
.description
= "The \"createAttribute(name)\" method creates "+
692 "a new Attr node of the given name.";
694 // Retrieve the targeted data and invoke its "createAttribute(name)"
697 testNode
= util
.getDOMDocument();
698 newAttrNode
= testNode
.CreateAttribute("district");
700 // Retrieve the characteristics of the new object.
702 computedValue
+= newAttrNode
.Name
+" ";
703 computedValue
+= newAttrNode
.Value
;
704 computedValue
+= newAttrNode
.NodeType
;
706 // Write out results.
708 results
.expected
= expectedValue
;
709 results
.actual
= computedValue
;
712 AssertEquals (results
.expected
, results
.actual
);
715 //------------------------ End test case core-0014D --------------------------
717 //-------------------------- test case core-0015D ----------------------------
719 // Testing feature - The "createEntityReference(name)" method creates an
720 // EntityReference node.
722 // Testing approach - Retrieve the entire DOM document and invoke its
723 // "createEntityReference(name)" method. It should
724 // create a new EntityReference node for the Entity
725 // with the given name. The name, value and type of
726 // the newly created object are further retrieved
729 // Semantic Requirements: 14
731 //----------------------------------------------------------------------------
734 public void core0015D()
736 string computedValue
= "";
737 string expectedValue
= "ent1 EntityReference";//"ent1 null 5";
738 System
.Xml
.XmlEntityReference newEntRefNode
= null;
739 System
.Xml
.XmlDocument testNode
= null;
741 testResults results
= new testResults("Core0015D");
743 results
.description
= "The \"createEntityReference(name)\" method creates "+
744 "a new EntityReference node.";
746 // Retrieve the targeted data and invoke its "createEntityReference(name)"
749 testNode
= util
.getDOMDocument();
750 newEntRefNode
= testNode
.CreateEntityReference("ent1");
752 // Retrieve the characteristics of the new object.
754 computedValue
+= newEntRefNode
.Name
+" ";
755 computedValue
+= newEntRefNode
.Value
+" ";
756 computedValue
+= newEntRefNode
.NodeType
;
758 // Write out results.
760 results
.expected
= expectedValue
;
761 results
.actual
= computedValue
;
764 AssertEquals (results
.expected
, results
.actual
);
767 //------------------------ End test case core-0015D --------------------------
769 //-------------------------- test case core-0016D ----------------------------
771 // Testing feature - The "getElementsByTagName(tagName)" method returns a
772 // NodeList of all the Elements with a given tagName.
774 // Testing approach - Retrieve the entire DOM document and invoke its
775 // "getElementsByTagName(tagName)" method with tagName
776 // equal to "name". The method should return a NodeList
777 // that contains 5 elements.
779 // Semantic Requirements: 15
781 //----------------------------------------------------------------------------
784 public void core0016D()
786 string computedValue
= "0";//0;
787 string expectedValue
= "5";//5;
788 System
.Xml
.XmlDocument testNode
= null;
790 testResults results
= new testResults("Core0016D");
792 results
.description
= "The \"getElementsByTagName(tagName)\" method "+
793 "returns a NodeList of all the Elements with a "+
796 // Retrieve the targeted data and invoke its "getElementsByTagName(tagName)"
799 testNode
= util
.getDOMDocument();
800 System
.Xml
.XmlNodeList elementList
= testNode
.GetElementsByTagName("name");
802 // Retrieve the length of the list.
804 computedValue
= elementList
.Count
.ToString();
806 // Write out results.
808 results
.expected
= expectedValue
;
809 results
.actual
= computedValue
;
812 AssertEquals (results
.expected
, results
.actual
);
815 //------------------------ End test case core-0016D --------------------------
817 //-------------------------- test case core-0017D ----------------------------
819 // Testing feature - The "getElementsByTagName(tagName)" method returns a
820 // NodeList of all the Elements with a given tagName in
821 // a pre-order traversal of the tree.
823 // Testing approach - Retrieve the entire DOM document and invoke its
824 // "getElementsByTagName(tagName)" method with tagName
825 // equal to "name". The method should return a NodeList
826 // that contains 5 elements. Further the fourth item in
827 // the list is retrieved and checked.
829 // Semantic Requirements: 16
831 //----------------------------------------------------------------------------
834 public void core0017D()
836 string computedValue
= "0";//0;
837 string expectedValue
= "Jeny Oconnor";
838 System
.Xml
.XmlDocument testNode
= null;
840 testResults results
= new testResults("Core0017D");
842 results
.description
= "The \"getElementsByTagName(tagName)\" method "+
843 "returns a NodeList of all the Elements with a "+
844 "given tag name in a preorder traversal of the tree.";
846 // Retrieve the targeted data and invoke its "getElementsByTagName(tagName)"
849 testNode
= util
.getDOMDocument();
850 System
.Xml
.XmlNodeList elementList
= testNode
.GetElementsByTagName("name");
852 // Retrieve the fourth item and its data.
854 computedValue
= elementList
.Item(util
.FOURTH
).FirstChild
.Value
;//Data;
856 // Write out results.
858 results
.expected
= expectedValue
;
859 results
.actual
= computedValue
;
862 AssertEquals (results
.expected
, results
.actual
);
865 //------------------------ End test case core-0017D --------------------------
867 //-------------------------- test case core-0018D ----------------------------
869 // Testing feature - The "getElementsByTagName(tagName)" method returns a
870 // NodeList of all the Elements in the tree when the
871 // tagName is equal to "*".
873 // Testing approach - Retrieve the entire DOM document and invoke its
874 // "getElementsByTagName(tagName)" method with tagName
875 // equal to "*". The method should return a NodeList
876 // that contains 41 elements, which is the total number
877 // of Elements in the document.
879 // Semantic Requirements: 17
881 //----------------------------------------------------------------------------
885 public void core0018D()
887 string computedValue
= "0";//0;
888 // Mmm, shouldn't the count be 36?
889 string expectedValue
= "36";//37;
890 System
.Xml
.XmlDocument testNode
= null;
892 testResults results
= new testResults("Core0018D");
894 results
.description
= "The \"getElementsByTagName(tagName)\" method "+
895 "returns a NodeList of all the Elements in the "+
896 "tree when the tag name is equal to \"*\".";
898 // Retrieve the targeted data and invoke its "getElementsByTagName(tagName)"
901 testNode
= util
.getDOMDocument();
902 System
.Xml
.XmlNodeList elementList
= testNode
.GetElementsByTagName("*");
904 // Retrieve the length of the list.
906 computedValue
= elementList
.Count
.ToString();
908 // Write out results.
911 results
.expected
= expectedValue
;
912 results
.actual
= computedValue
;
915 AssertEquals (results
.expected
, results
.actual
);
918 //------------------------ End test case core-0018D --------------------------
920 //------------------------- test case core-0019D -----------------------------
922 // Testing feature - The "createElement(tagName)" method raises an
923 // INVALID_CHARACTER_ERR Exception if the
924 // specified name contains an invalid character.
926 // Testing approach - Retrieve the entire DOM document and invoke its
927 // "createElement(tagName)" method with the tagName
928 // equals to the string "invalid^Name" which contains
929 // an invalid character ("^") in it. The desired
930 // exception should be raised.
932 // Semantic Requirements: 18
934 //----------------------------------------------------------------------------
937 public void core0019D()
939 string computedValue
= "";
940 System
.Xml
.XmlDocument testNode
= null;
941 System
.Xml
.XmlElement invalidElement
= null;
942 string expectedValue
= util
.INVALID_CHARACTER_ERR
;
944 testResults results
= new testResults("Core0019D");
946 results
.description
= "The \"createElement(tagName)\" method raises an "+
947 "INVALID_CHARACTER_ERR Exception if the "+
948 "specified name contains an invalid character.";
950 // Retrieve the targeted data.
952 testNode
= util
.getDOMDocument();
954 // Attempt to create an Element with an invalid tagName should raise
959 invalidElement
= testNode
.CreateElement("invalid^Name");
961 catch(System
.Exception ex
)
963 computedValue
= ex
.GetType ().FullName
;
967 // Write out results.
969 results
.expected
= typeof (XmlException
).FullName
; // MS.NET BUG: It never raises an error.
970 results
.actual
= computedValue
;
973 AssertEquals (results
.expected
, results
.actual
);
976 //------------------------ End test case core-0019D -------------------------
978 //------------------------- test case core-0020D -----------------------------
980 // Testing feature - The "createAttribute(name)" method raises an
981 // INVALID_CHARACTER_ERR Exception if the
982 // specified name contains an invalid character.
984 // Testing approach - Retrieve the entire DOM document and invoke its
985 // "createAttribute(name)" method with the name
986 // equals to the string "invalid^Name" which contains
987 // an invalid character ("^") in it. The desired
988 // exception should be raised.
990 // Semantic Requirements: 19
992 //----------------------------------------------------------------------------
995 public void core0020D()
997 string computedValue
= "";
998 string expectedValue
= util
.INVALID_CHARACTER_ERR
;
999 System
.Xml
.XmlDocument testNode
= null;
1000 System
.Xml
.XmlAttribute invalidAttr
= null;
1002 testResults results
= new testResults("Core0020D");
1004 results
.description
= "The \"createAttribute(name)\" method raises an "+
1005 "INVALID_CHARACTER_ERR Exception if the "+
1006 "specified name contains an invalid character.";
1008 // Retrieve the targeted data.
1010 testNode
= util
.getDOMDocument();
1012 // Attempt to create an Attr node with an invalid name should raise
1017 invalidAttr
= testNode
.CreateAttribute("invalid^Name");
1019 catch(System
.Exception ex
)
1021 computedValue
= ex
.GetType ().FullName
;
1025 // Write out results.
1027 results
.expected
= typeof (ArgumentException
).FullName
; // MS.NET BUG: It never raises an error.
1028 results
.actual
= computedValue
;
1031 AssertEquals (results
.expected
, results
.actual
);
1034 //------------------------ End test case core-0020D -------------------------
1036 //------------------------- test case core-0021D -----------------------------
1038 // Testing feature - The "createEntityReference(name)" method raises an
1039 // INVALID_CHARACTER_ERR Exception if the
1040 // specified name contains an invalid character.
1042 // Testing approach - Retrieve the entire DOM document and invoke its
1043 // "createEntityReference(name)" method with the name
1044 // equals to the string "invalid^Name" which contains
1045 // an invalid character ("^") in it. The desired
1046 // exception should be raised.
1048 // Semantic Requirements: 20
1050 //----------------------------------------------------------------------------
1053 public void core0021D()
1055 string computedValue
= "";
1056 string expectedValue
= "System.Xml.XmlException";//util.INVALID_CHARACTER_ERR;
1057 System
.Xml
.XmlDocument testNode
= null;
1058 System
.Xml
.XmlEntityReference invalidEntRef
= null;
1060 testResults results
= new testResults("Core0021D");
1062 results
.description
= "The \"createEntityReference(name)\" method raises "+
1063 "an INVALID_CHARACTER_ERR Exception if the "+
1064 "specified name contains an invalid character.";
1066 // Retrieve the targeted data.
1068 testNode
= util
.getDOMDocument();
1070 // Attempt to create an EntityReference node with an invalid name should
1071 // raise an exception.
1075 invalidEntRef
= testNode
.CreateEntityReference("invalid^Name");
1077 catch(XmlException ex
)
1079 computedValue
= ex
.GetType ().FullName
;
1082 // Write out results.
1084 results
.expected
= expectedValue
;
1085 results
.actual
= computedValue
;
1088 AssertEquals (results
.expected
, results
.actual
);
1091 //------------------------ End test case core-0021D -------------------------
1093 //------------------------- test case core-0022D ----------------------------
1095 // Testing feature - The "createProcessingInstruction(target,data)" method
1096 // raises an INVALID_CHARACTER_ERR Exception if an
1097 // invalid character was specified. (test for invalid
1100 // Testing approach - Retrieve the entire DOM document and invoke its
1101 // "createProcessingInstruction(target,data)" method with
1102 // the target equals to the string "invalid^target" which
1103 // contains an invalid character ("^") in it. The desired
1104 // exception should be raised.
1106 // Semantic Requirements: 21
1108 //----------------------------------------------------------------------------
1111 public void core0022D()
1113 string computedValue
= "";
1114 string expectedValue
= "System.Xml.XmlException";//util.INVALID_CHARACTER_ERR;
1115 System
.Xml
.XmlDocument testNode
= null;
1116 System
.Xml
.XmlProcessingInstruction invalidPI
= null;
1118 testResults results
= new testResults("Core0022D");
1120 results
.description
= "The \"createProcessingInstruction(target,data)\" "+
1121 "method raises an INVALID_CHARACTER_ERR "+
1122 "DOMException if an invalid character was specified "+ "(invalid target).";
1124 // Retrieve the targeted data.
1126 testNode
= util
.getDOMDocument();
1128 // Attempt to create a ProcessingInstruction node with an invalid
1129 // target name should raise an exception.
1133 invalidPI
= testNode
.CreateProcessingInstruction("invalid^target","data");
1135 catch(XmlException ex
)
1137 computedValue
= ex
.GetType ().FullName
;
1141 // Write out results.
1143 results
.expected
= expectedValue
;
1144 results
.actual
= computedValue
;
1147 AssertEquals (results
.expected
, results
.actual
);
1150 //------------------------ End test case core-0022D -------------------------
1152 //------------------------- test case core-0023D ----------------------------
1154 // Testing feature - The "createCDATASection(data)" method raises a
1155 // NOT_SUPPORTED_ERR Exception if this is an
1158 // Testing approach - Retrieve an HTML based DOM document and invoke its
1159 // "createCDATASection(data)" method. Since this DOM
1160 // document was based on an HTML document, the desired
1161 // exception should be raised.
1163 // System.Xml - Microsoft System.Xml does not supporting this requirement
1165 // Semantic Requirements: 22
1167 //----------------------------------------------------------------------------
1170 public void core0023D()
1172 string computedValue
= "";
1173 string expectedValue
= "";//util.NOT_SUPPORTED_ERR;
1174 System
.Xml
.XmlDocument testNode
= null;
1175 System
.Xml
.XmlCDataSection invalidCData
= null;
1177 testResults results
= new testResults("Core0023D");
1179 results
.description
= "The \"createCDATASection(data)\" method raises "+
1180 "a NOT_SUPPORTED_ERR Exception if this is "+
1181 "an HTML document.";
1183 // Retrieve the targeted data.
1185 testNode
= util
.getDOMHTMLDocument();
1187 // Attempt to create a CDATASection node for an HTML based DOM Document
1188 // should raise an exception.
1192 invalidCData
= testNode
.CreateCDataSection("This is a new CDATA Section");
1194 catch(System
.Exception ex
)
1196 computedValue
= ex
.Message
;
1199 // Write out results.
1201 results
.expected
= expectedValue
;
1202 results
.actual
= computedValue
;
1205 AssertEquals (results
.expected
, results
.actual
);
1208 //------------------------ End test case core-0023D -------------------------
1210 //------------------------- test case core-0024D ----------------------------
1212 // Testing feature - The "createProcessingInstruction(target,data)" method
1213 // raises a NOT_SUPPORTED_ERR Exception if this is an
1216 // Testing approach - Retrieve an HTML based DOM document and invoke its
1217 // "createProcessingInstruction(target,data)" method.
1218 // Since this DOM document was based on an HTML document,
1219 // the desired exception should be raised.
1221 // System.Xml - Microsoft System.Xml does not supporting this requirement
1222 // Semantic Requirements: 23
1224 //----------------------------------------------------------------------------
1227 public void core0024D()
1229 string computedValue
= "";
1230 string expectedValue
= "";//util.NOT_SUPPORTED_ERR;
1231 System
.Xml
.XmlDocument testNode
= null;
1232 System
.Xml
.XmlProcessingInstruction invalidPI
= null;
1234 testResults results
= new testResults("Core0024D");
1236 results
.description
= "The \"createProcessingInstruction(target,data)\" "+
1237 "method raises a NOT_SUPPORTED_ERR Exception "+
1238 "if this is an HTML document.";
1240 // Retrieve the targeted data.
1242 testNode
= util
.getDOMHTMLDocument();
1244 // Attempt to create a ProcessingInstruction node for an HTML based DOM
1245 // Document should raise an exception.
1249 invalidPI
= testNode
.CreateProcessingInstruction("XML","This is a new PI node");
1251 catch(System
.Exception ex
)
1253 computedValue
= ex
.Message
;
1256 // Write out results.
1258 results
.expected
= expectedValue
;
1259 results
.actual
= computedValue
;
1262 AssertEquals (results
.expected
, results
.actual
);
1265 //------------------------ End test case core-0024D -------------------------
1267 //------------------------- test case core-0025D ----------------------------
1269 // Testing feature - The "createEntityReference(data)" method raises
1270 // a NOT_SUPPORTED_ERR Exception if this is an
1273 // Testing approach - Retrieve an HTML based DOM document and invoke its
1274 // "createEntityReference(name)" method. Since this DOM
1275 // document was based on an HTML document, the desired
1276 // exception should be raised.
1278 // System.Xml - Microsoft System.Xml does not supporting this requirement
1280 // Semantic Requirements: 24
1282 //----------------------------------------------------------------------------
1285 public void core0025D()
1287 string computedValue
= "";
1288 string expectedValue
= "";//util.NOT_SUPPORTED_ERR;
1289 System
.Xml
.XmlDocument testNode
= null;
1290 System
.Xml
.XmlEntityReference invalidEntRef
= null;
1292 testResults results
= new testResults("Core0025D");
1294 results
.description
= "The \"createEntityReference(name)\" method raises "+
1295 "a NOT_SUPPORTED_ERR Exception if this is an "+
1298 // Retrieve the targeted data.
1300 testNode
= util
.getDOMHTMLDocument();
1302 // Attempt to create an EntityReference node for an HTML based DOM
1303 // Document should raise an exception.
1307 invalidEntRef
= testNode
.CreateEntityReference("ent1");
1309 catch(System
.Exception ex
)
1311 computedValue
= ex
.GetType().ToString();
1315 // Write out results.
1317 results
.expected
= expectedValue
;
1318 results
.actual
= computedValue
;
1321 AssertEquals (results
.expected
, results
.actual
);
1324 //------------------------ End test case core-0025D -------------------------