PageRenderTime 88ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/mcs/class/System.XML/Test/System.Xml/nist_dom/fundamental/Node/Node.cs

https://bitbucket.org/danipen/mono
C# | 5322 lines | 2396 code | 458 blank | 2468 comment | 63 complexity | 71bc61906a1ed41522f299fd79df156d MD5 | raw file
Possible License(s): Unlicense, Apache-2.0, LGPL-2.0, MPL-2.0-no-copyleft-exception, CC-BY-SA-3.0, GPL-2.0
  1. //**************************************************************************
  2. //
  3. //
  4. // National Institute Of Standards and Technology
  5. // DTS Version 1.0
  6. //
  7. // Node Interface
  8. //
  9. // Written by: Carmelo Montanez
  10. // Modified by: Mary Brady
  11. //
  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;
  17. using nist_dom;
  18. using NUnit.Framework;
  19. namespace nist_dom.fundamental
  20. {
  21. [TestFixture]
  22. public class NodeTest
  23. {
  24. public static int i = 2;
  25. /*
  26. public testResults[] RunTests()
  27. {
  28. testResults[] tests = new testResults[] {core0001NO(), core0002NO(), core0003NO(),core0004NO(),
  29. core0005NO(), core0006NO(), core0007NO(), core0008NO(),
  30. core0009NO(), core0010NO(), core0011NO(), core0012NO(),
  31. core0013NO(), core0014NO(), core0015NO(), core0016NO(),
  32. core0017NO(), core0018NO(), core0019NO(), core0020NO(),
  33. core0021NO(), core0022NO(), core0023NO(), core0024NO(),
  34. core0025NO(), core0026NO(), core0027NO(), core0028NO(),
  35. core0029NO(), core0030NO(), core0031NO(), core0032NO(),
  36. core0033NO(), core0034NO(), core0035NO(), core0036NO(),
  37. core0038NO(), core0039NO(), core0040NO(),
  38. core0041NO(), core0042NO(), core0043NO(), core0044NO(),
  39. core0045NO(), core0046NO(), core0047NO(), core0048NO(),
  40. core0049NO(), core0050NO(), core0051NO(), core0052NO(),
  41. core0053NO(), core0054NO(), core0055NO(), core0056NO(),
  42. core0057NO(), core0058NO(), core0059NO(), core0060NO(),
  43. core0061NO(), core0062NO(), core0063NO(), core0064NO(),
  44. core0065NO(), core0066NO(), core0067NO(), core0068NO(),
  45. core0069NO(), core0070NO(), core0071NO(), core0072NO(),
  46. core0073NO(), core0074NO(), core0075NO(), core0076NO(),
  47. core0077NO(), core0078NO(), core0079NO(), core0080NO(),
  48. core0081NO(), core0082NO(), core0083NO(), core0084NO(),
  49. core0085NO(), core0087NO(), core0088NO(),
  50. core0089NO(), core0090NO(), core0091NO(), core0092NO(),
  51. core0093NO(), core0094NO(), core0095NO(), core0096NO(),
  52. core0097NO(), core0098NO(), core0099NO(), core0100NO(),
  53. core0101NO(), core0102NO(), core0103NO()};
  54. return tests;
  55. }
  56. */
  57. //------------------------ test case core-0001NO------------------------
  58. //
  59. // Testing feature - The "nodeType" attribute for an Element node is
  60. // 1 (ELEMENT_NODE).
  61. //
  62. // Testing approach - Retrieve the root node and check its "nodeType"
  63. // attribute. It should be set to 1.
  64. //
  65. // Semantic Requirements: 1, 14
  66. //
  67. //----------------------------------------------------------------------------
  68. [Test]
  69. public void core0001NO()
  70. {
  71. int computedValue = 0;
  72. int expectedValue = util.ELEMENT_NODE;
  73. testResults results = new testResults("Core0001NO");
  74. results.description = "The nodeType attribute for an Element Node "+
  75. " should be set to the constant 1.";
  76. //
  77. // The nodeType attribute for the root node should be set to the value 1.
  78. //
  79. computedValue = (int)util.getRootNode().NodeType;
  80. //
  81. // write out results.
  82. //
  83. results.expected = expectedValue.ToString();
  84. results.actual = computedValue.ToString();
  85. Assert.AreEqual (results.expected, results.actual);
  86. }
  87. //------------------------ End test case core-0001NO --------------------------
  88. //
  89. //------------------------- test case core-0002NO -----------------------------
  90. //
  91. // Testing feature - The "nodeType" attribute for an Attribute node is
  92. // 2 (ATTRIBUTE_NODE).
  93. //
  94. // Testing approach - Retrieve the first attribute from the last child of
  95. // the first employee. Its "nodeType" attribute is then
  96. // checked, it should be set to 2.
  97. //
  98. // Semantic Requirements: 2, 14
  99. //
  100. //----------------------------------------------------------------------------
  101. [Test]
  102. public void core0002NO()
  103. {
  104. string computedValue = "";
  105. System.Xml.XmlElement testNode = null;
  106. System.Xml.XmlAttribute attrNode = null;
  107. string expectedValue = util.ATTRIBUTE_NODE.ToString();
  108. testResults results = new testResults("Core0002NO");
  109. try
  110. {
  111. results.description = "The nodeType attribute for an Attribute Node "+
  112. " should be set to the constant 2.";
  113. //
  114. // Retrieve the targeted data and its type.
  115. //
  116. testNode = (System.Xml.XmlElement)util.nodeObject(util.FIRST,util.SIXTH);
  117. attrNode = testNode.GetAttributeNode("domestic");//.node.
  118. computedValue = ((int)attrNode.NodeType).ToString();
  119. }
  120. catch(System.Exception ex)
  121. {
  122. computedValue = "Exception " + ex.Message;
  123. }
  124. //
  125. // write out results.
  126. //
  127. results.expected = expectedValue.ToString();
  128. results.actual = computedValue;
  129. Assert.AreEqual (results.expected, results.actual);
  130. }
  131. //------------------------ End test case core-0002NO --------------------------
  132. //
  133. //------------------------- test case core-0003NO -----------------------------
  134. //
  135. // Testing feature - The "nodeType" attribute for a Text node is
  136. // 3 (TEXT_NODE).
  137. //
  138. // Testing approach - Retrieve the Text data from the last child of the
  139. // first employee and and examine its "nodeType"
  140. // attribute. It should be set to 3.
  141. //
  142. // Semantic Requirements: 3, 14
  143. //
  144. //----------------------------------------------------------------------------
  145. [Test]
  146. public void core0003NO()
  147. {
  148. string computedValue = "";
  149. System.Xml.XmlNode testNode = null;
  150. System.Xml.XmlNode textNode = null;
  151. string expectedValue = util.TEXT_NODE.ToString();
  152. testResults results = new testResults("Core0003NO");
  153. try
  154. {
  155. results.description = "The nodeType attribute for a Text Node "+
  156. " should be set to the constant 3.";
  157. //
  158. // Retrieve the targeted data.
  159. //
  160. testNode = util.nodeObject(util.FIRST,util.SIXTH);
  161. textNode = testNode.FirstChild;//.node.
  162. //
  163. // The nodeType attribute should be set to the value 3.
  164. //
  165. computedValue = ((int)textNode.NodeType).ToString();
  166. }
  167. catch(System.Exception ex)
  168. {
  169. computedValue = "Exception " + ex.Message;
  170. }
  171. //
  172. // write out results.
  173. //
  174. results.expected = expectedValue.ToString();
  175. results.actual = computedValue;
  176. Assert.AreEqual (results.expected, results.actual);
  177. }
  178. //------------------------ End test case core-0003NO --------------------------
  179. //
  180. //------------------------- test case core-0004NO -----------------------------
  181. //
  182. // Testing feature - The "nodeType" attribute for a CDATASection node is
  183. // 4 (CDATA_SECTION_NODE).
  184. //
  185. // Testing approach - Retrieve the CDATASection node contained inside
  186. // the second child of the second employee and
  187. // examine its "nodeType" attribute. It should be
  188. // set to 4.
  189. //
  190. // Semantic Requirements: 4, 14
  191. //
  192. //----------------------------------------------------------------------------
  193. [Test]
  194. public void core0004NO()
  195. {
  196. string computedValue = "";
  197. System.Xml.XmlNode testNode = null;
  198. System.Xml.XmlNode cDataNode = null;
  199. string expectedValue = util.CDATA_SECTION_NODE.ToString();
  200. testResults results = new testResults("Core0004NO");
  201. try
  202. {
  203. results.description = "The nodeType attribute for a CDATASection Node "+
  204. " should be set to the constant 4.";
  205. //
  206. // Retrieve the targeted data.
  207. //
  208. testNode = util.nodeObject(util.SECOND,util.SECOND);
  209. cDataNode = testNode.LastChild; //.node.
  210. //
  211. // The nodeType attribute should be set to the value 3.
  212. //
  213. computedValue = ((int)cDataNode.NodeType).ToString();
  214. }
  215. catch(System.Exception ex)
  216. {
  217. computedValue = "Exception " + ex.Message;
  218. }
  219. //
  220. // write out results.
  221. //
  222. results.expected = expectedValue.ToString();
  223. results.actual = computedValue.ToString();
  224. Assert.AreEqual (results.expected, results.actual);
  225. }
  226. //------------------------ End test case core-0004NO --------------------------
  227. //
  228. //------------------------- test case core-0005NO -----------------------------
  229. //
  230. // Testing feature - The "nodeType" attribute for an EntityReference node
  231. // is 5 (ENTITY_REFERENCE_NODE).
  232. //
  233. // Testing approach - Retrieve the first Entity Reference node from the
  234. // last child of the second employee and examine its
  235. // "nodeType" attribute. It should be set to 5.
  236. //
  237. // Semantic Requirements: 5, 14
  238. //
  239. //----------------------------------------------------------------------------
  240. [Test]
  241. public void core0005NO()
  242. {
  243. string computedValue = "";
  244. System.Xml.XmlNode testNode = null;
  245. System.Xml.XmlNode entRefNode = null;
  246. string expectedValue = XmlNodeType.EntityReference.ToString ();//util.ENTITY_REFERENCE_NODE;
  247. testResults results = new testResults("Core0005NO");
  248. try
  249. {
  250. results.description = "The nodeType attribute for an EntityReference Node "+
  251. " should be set to the constant 5.";
  252. //
  253. // Retrieve the targeted data.
  254. //
  255. testNode = util.nodeObject(util.SECOND,util.SIXTH);
  256. entRefNode = testNode.FirstChild;//.node.
  257. //
  258. // The nodeType attribute should be set to the value 5.
  259. //
  260. computedValue = entRefNode.NodeType.ToString();
  261. }
  262. catch(System.Exception ex)
  263. {
  264. computedValue = "Exception " + ex.Message;
  265. }
  266. //
  267. // write out results.
  268. //
  269. results.expected = expectedValue.ToString();
  270. results.actual = computedValue.ToString();
  271. Assert.AreEqual (results.expected, results.actual);
  272. }
  273. //------------------------ End test case core-0005NO --------------------------
  274. //
  275. //------------------------- test case core-0006NO -----------------------------
  276. //
  277. // Testing feature - The "nodeType" attribute for an Entity node
  278. // 6 (ENTITY_NODE).
  279. //
  280. // Testing approach - Retrieve the first Entity declaration in the
  281. // "DOCTYPE" section of the XML file and examine
  282. // its "nodeType" attribute. It should be set to 6.
  283. //
  284. // Semantic Requirements: 6, 14
  285. //
  286. //----------------------------------------------------------------------------
  287. [Test]
  288. public void core0006NO()
  289. {
  290. int computedValue = 0;
  291. System.Xml.XmlNode testNode = null;
  292. int expectedValue = util.ENTITY_NODE;
  293. testResults results = new testResults("Core0006NO");
  294. results.description = "The nodeType attribute for an Entity Node "+
  295. " should be set to the constant 6.";
  296. //
  297. // Get the targeted data and its type.
  298. //
  299. testNode = util.getEntity("ent1");
  300. //
  301. // The nodeType attribute should be set to the value 6.
  302. //
  303. computedValue = (int)testNode.NodeType;
  304. //
  305. // write out results.
  306. //
  307. results.expected = expectedValue.ToString();
  308. results.actual = computedValue.ToString();
  309. Assert.AreEqual (results.expected, results.actual);
  310. }
  311. //------------------------ End test case core-0006NO --------------------------
  312. //
  313. //------------------------- test case core-0007NO -----------------------------
  314. //
  315. // Testing feature - The "nodeType" attribute for a ProcessingInstruction.
  316. //
  317. // Testing approach - Retrieve the first declaration in the XML file
  318. // and examine its "nodeType" attribute. It should
  319. // be set to ProcessingInstruction.
  320. //
  321. // Semantic Requirements: 7, 14
  322. //
  323. //----------------------------------------------------------------------------
  324. [Test]
  325. public void core0007NO()
  326. {
  327. string computedValue = "";
  328. System.Xml.XmlNode testNode = null;
  329. string expectedValue = util.XML_DECLARATION_NODE.ToString(); //util.PROCESSING_INSTRUCTION_NODE.ToString();
  330. testResults results = new testResults("Core0007NO");
  331. results.description = "The nodeType attribute for an ProcessingInstruction Node.";
  332. //
  333. // Get the targeted data.
  334. //
  335. testNode = util.getDOMDocument().ChildNodes.Item(0);
  336. //
  337. // The nodeType attribute should be set to the value 7.
  338. //
  339. computedValue = ((int)testNode.NodeType).ToString();
  340. //
  341. // write out results.
  342. //
  343. results.expected = expectedValue.ToString();
  344. results.actual = computedValue.ToString();
  345. Assert.AreEqual (results.expected, results.actual);
  346. }
  347. //------------------------ End test case core-0007NO --------------------------
  348. //
  349. //------------------------- test case core-0008NO -----------------------------
  350. //
  351. // Testing feature - The "nodeType" attribute for a comment node is
  352. // 8 (COMMENT_NODE).
  353. //
  354. // Testing approach - Retrieve the only comment (third child) from the
  355. // main DOM document and examine its "nodeType" attribute.
  356. // It should be set to 8.
  357. //
  358. // Semantic Requirements: 8, 14
  359. //
  360. //----------------------------------------------------------------------------
  361. [Test]
  362. public void core0008NO()
  363. {
  364. int computedValue = 0;
  365. System.Xml.XmlNode testNode = null;
  366. int expectedValue = util.COMMENT_NODE;
  367. testResults results = new testResults("Core0008NO");
  368. results.description = "The nodeType attribute for a Comment Node "+
  369. " should be set to the constant 8.";
  370. //
  371. // Get the targeted data.
  372. //
  373. testNode = util.getDOMDocument().ChildNodes.Item(2);
  374. //
  375. // The nodeType attribute should be set to the value 8.
  376. //
  377. computedValue = (int)testNode.NodeType;
  378. //
  379. // write out results.
  380. //
  381. results.expected = expectedValue.ToString();
  382. results.actual = computedValue.ToString();
  383. Assert.AreEqual (results.expected, results.actual);
  384. }
  385. //------------------------ End test case core-0008NO --------------------------
  386. //
  387. //------------------------- test case core-0009NO -----------------------------
  388. //
  389. // Testing feature - The "nodeType" attribute for a Document node is
  390. // 9 (DOCUMENT_NODE).
  391. //
  392. // Testing approach - Retrieve the DOM Document and examine its
  393. // "nodeType" attribute. It should be set to 9.
  394. //
  395. // Semantic Requirements: 9, 14
  396. //
  397. //----------------------------------------------------------------------------
  398. [Test]
  399. public void core0009NO()
  400. {
  401. int computedValue = 0;
  402. System.Xml.XmlNode testNode = null;
  403. int expectedValue = util.DOCUMENT_NODE;
  404. testResults results = new testResults("Core0009NO");
  405. results.description = "The nodeType attribute for an Document Node "+
  406. " should be set to the constant 9.";
  407. //
  408. // Get the targeted data.
  409. //
  410. testNode = util.getDOMDocument();
  411. //
  412. // The nodeType attribute should be set to the value 9.
  413. //
  414. computedValue = (int)testNode.NodeType;
  415. //
  416. // write out results.
  417. //
  418. results.expected = expectedValue.ToString();
  419. results.actual = computedValue.ToString();
  420. Assert.AreEqual (results.expected, results.actual);
  421. }
  422. //------------------------ End test case core-0009NO --------------------------
  423. //
  424. //------------------------- test case core-0010NO -----------------------------
  425. //
  426. // Testing feature - The "nodeType" attribute for a DocumentType node is
  427. // 10 (DOCUMENT_TYPE_NODE).
  428. //
  429. // Testing approach - Retrieve the DOCTYPE declaration (second child) from
  430. // the XML file and examine its "nodeType" attribute.
  431. // It should be set to 10.
  432. //
  433. // Semantic Requirements: 10, 14
  434. //
  435. //----------------------------------------------------------------------------
  436. [Test]
  437. public void core0010NO()
  438. {
  439. int computedValue = 0;
  440. System.Xml.XmlNode testNode = null;
  441. int expectedValue = util.DOCUMENT_TYPE_NODE;
  442. testResults results = new testResults("Core0010NO");
  443. results.description = "The nodeType attribute for an DocumentType Node "+
  444. " should be set to the constant 10.";
  445. //
  446. // Get the targeted data.
  447. //
  448. testNode = util.getDocType();
  449. //
  450. // The nodeType attribute should be set to the value 10.
  451. //
  452. computedValue = (int)testNode.NodeType;
  453. //
  454. // write out results.
  455. //
  456. results.expected = expectedValue.ToString();
  457. results.actual = computedValue.ToString();
  458. Assert.AreEqual (results.expected, results.actual);
  459. }
  460. //------------------------ End test case core-0010NO --------------------------
  461. //
  462. //------------------------- test case core-0011NO -----------------------------
  463. //
  464. // Testing feature - The "nodeType" attribute for a DocumentFragment node
  465. // is 11 (DOCUMENT_FRAGMENT_NODE).
  466. //
  467. // Testing approach - Retrieve the whole DOM document and invoke its
  468. // "createDocumentFragment()" method and examine the
  469. // "nodeType" attribute of the returned node. It should
  470. // be set to 11.
  471. //
  472. // Semantic Requirements: 11, 14
  473. //
  474. //----------------------------------------------------------------------------
  475. [Test]
  476. public void core0011NO()
  477. {
  478. int computedValue = 0;
  479. System.Xml.XmlNode testNode = null;
  480. int expectedValue = util.DOCUMENT_FRAGMENT_NODE;
  481. testResults results = new testResults("Core0011NO");
  482. results.description = "The nodeType attribute for a DocumentFragment Node "+
  483. " should be set to the constant 11.";
  484. //
  485. // Get the targeted data.
  486. //
  487. testNode = util.getDOMDocument().CreateDocumentFragment();
  488. //
  489. // The nodeType attribute should be set to the value 11.
  490. //
  491. computedValue = (int)testNode.NodeType;
  492. //
  493. // write out results.
  494. //
  495. results.expected = expectedValue.ToString();
  496. results.actual = computedValue.ToString();
  497. Assert.AreEqual (results.expected, results.actual);
  498. }
  499. //------------------------ End test case core-0011NO --------------------------
  500. //
  501. //------------------------- test case core-0012NO -----------------------------
  502. //
  503. // Testing feature - The "nodeType" attribute for a notation node is
  504. // 12 (NOTATION_NODE).
  505. //
  506. // Testing approach - Retrieve the Notation declaration inside the
  507. // DocumentType node and examine its "nodeType"
  508. // attribute. It should be set to 12.
  509. //
  510. // Semantic Requirements: 12, 14
  511. //
  512. //----------------------------------------------------------------------------
  513. [Test]
  514. public void core0012NO()
  515. {
  516. string computedValue = "";
  517. System.Xml.XmlNode testNode = null;
  518. string expectedValue = util.NOTATION_NODE.ToString();
  519. testResults results = new testResults("Core0012NO");
  520. try
  521. {
  522. results.description = "The nodeType attribute for a Notation Node "+
  523. " should be set to the constant 12.";
  524. //
  525. // Get the targeted data.
  526. //
  527. testNode = util.getNotation("notation1");
  528. //
  529. // The nodeType attribute should be set to the value 12.
  530. //
  531. computedValue = ((int)testNode.NodeType).ToString();
  532. }
  533. catch(System.Exception ex)
  534. {
  535. computedValue = "Exception " + ex.Message;
  536. }
  537. //
  538. // write out results.
  539. //
  540. results.expected = expectedValue.ToString();
  541. results.actual = computedValue.ToString();
  542. Assert.AreEqual (results.expected, results.actual);
  543. }
  544. //------------------------ End test case core-0012NO --------------------------
  545. //
  546. //------------------------ test case core-0013NO ----------------------------
  547. //
  548. // Testing feature - The "nodeName" attribute for an Element node is
  549. // its tagName.
  550. //
  551. // Testing approach - Retrieve the first Element node (root node) of the
  552. // DOM object and check its "nodeName" attribute.
  553. // It should be equal to its tagName.
  554. //
  555. // Semantic Requirements: 13, 15
  556. //
  557. //----------------------------------------------------------------------------
  558. [Test]
  559. public void core0013NO()
  560. {
  561. string computedValue = "0";
  562. string expectedValue = "staff";
  563. testResults results = new testResults("Core0013NO");
  564. results.description = "The nodeName attribute for an Element Node " +
  565. "should be set to its tagName.";
  566. //
  567. // The nodeName attribute should be set to "staff".
  568. //
  569. computedValue = util.getRootNode().Name;
  570. //
  571. // write out results.
  572. //
  573. results.expected = expectedValue;
  574. results.actual = computedValue;
  575. Assert.AreEqual (results.expected, results.actual);
  576. }
  577. //------------------------ End test case core-0013NO --------------------------
  578. //
  579. //------------------------- test case core-0014NO -----------------------------
  580. //
  581. // Testing feature - The "nodeName" attribute for an Attribute node is
  582. // the name of the attribute.
  583. //
  584. // Testing approach - Retrieve the attribute named "domestic" from the last
  585. // child of the first employee. Its "nodeName" attribute
  586. // is then checked. It should be set to "domestic".
  587. //
  588. // Semantic Requirements: 13, 15
  589. //
  590. //----------------------------------------------------------------------------
  591. [Test]
  592. public void core0014NO()
  593. {
  594. string computedValue = "0";
  595. string expectedValue = "domestic";
  596. System.Xml.XmlElement testNode = null;
  597. System.Xml.XmlAttribute attrNode = null;
  598. testResults results = new testResults("Core0014NO");
  599. try
  600. {
  601. results.description = "The nodeName attribute for an Attribute Node " +
  602. "should be set to the name of the attribute.";
  603. //
  604. // Retrieve the targeted data.
  605. //
  606. testNode = (System.Xml.XmlElement)util.nodeObject(util.FIRST,util.SIXTH);
  607. attrNode = testNode.GetAttributeNode("domestic"); //.node.
  608. //
  609. // The nodeName attribute should be set to the value "domestic".
  610. //
  611. computedValue = attrNode.Name;
  612. }
  613. catch(System.Exception ex)
  614. {
  615. computedValue = "Exception " + ex.Message;
  616. }
  617. //
  618. // write out results.
  619. //
  620. results.expected = expectedValue;
  621. results.actual = computedValue;
  622. Assert.AreEqual (results.expected, results.actual);
  623. }
  624. //------------------------ End test case core-0014NO --------------------------
  625. //
  626. //------------------------- test case core-0015NO -----------------------------
  627. //
  628. // Testing feature - The "nodeName" attribute for a text node is
  629. // "#text".
  630. //
  631. // Testing approach - Retrieve the Text data from the last child of the
  632. // first employee and and examine its "nodeName"
  633. // attribute. It should be set to "#text".
  634. //
  635. // Semantic Requirements: 13, 15
  636. //
  637. //----------------------------------------------------------------------------
  638. [Test]
  639. public void core0015NO()
  640. {
  641. string computedValue = "0";
  642. string expectedValue = "#text";
  643. System.Xml.XmlNode testNode = null;
  644. System.Xml.XmlNode textNode = null;
  645. testResults results = new testResults("Core0015NO");
  646. try
  647. {
  648. results.description = "The nodeName attribute for a Text Node " +
  649. "should be set to \"#text\".";
  650. //
  651. // Retrieve the targeted data.
  652. //
  653. testNode = util.nodeObject(util.FIRST,util.SIXTH);
  654. textNode = testNode.FirstChild;//.node.
  655. //
  656. // The nodeName attribute should be set to the value "#text".
  657. //
  658. computedValue = textNode.Name;
  659. }
  660. catch(System.Exception ex)
  661. {
  662. computedValue = "Exception " + ex.Message;
  663. }
  664. //
  665. // write out results.
  666. //
  667. results.expected = expectedValue;
  668. results.actual = computedValue;
  669. Assert.AreEqual (results.expected, results.actual);
  670. }
  671. //------------------------ End test case core-0015NO --------------------------
  672. //
  673. //------------------------- test case core-0016NO -----------------------------
  674. //
  675. // Testing feature - The "nodeName" attribute for a CDATASection node is
  676. // "#cdata-section".
  677. //
  678. // Testing approach - Retrieve the CDATASection node inside the second
  679. // child of the second employee and examine its "nodeName"
  680. // attribute. It should be set to "#cdata-section".
  681. //
  682. // Semantic Requirements: 13, 15
  683. //
  684. //----------------------------------------------------------------------------
  685. [Test]
  686. public void core0016NO()
  687. {
  688. string computedValue = "0";
  689. string expectedValue = "#cdata-section";
  690. System.Xml.XmlNode testNode = null;
  691. System.Xml.XmlNode cDataNode = null;
  692. testResults results = new testResults("Core0016NO");
  693. try
  694. {
  695. results.description = "The nodeName attribute for a CDATASection Node " +
  696. "should be set to \"#cdata-section\".";
  697. //
  698. // Retrieve the targeted data.
  699. //
  700. testNode = util.nodeObject(util.SECOND,util.SECOND);
  701. cDataNode = testNode.LastChild;;//.node.
  702. //
  703. // The nodeName attribute should be set to "#cdata-section".
  704. //
  705. computedValue = cDataNode.Name;
  706. }
  707. catch(System.Exception ex)
  708. {
  709. computedValue = "Exception " + ex.Message;
  710. }
  711. //
  712. // write out results.
  713. //
  714. results.expected = expectedValue;
  715. results.actual = computedValue;
  716. Assert.AreEqual (results.expected, results.actual);
  717. }
  718. //------------------------ End test case core-0016NO --------------------------
  719. //
  720. //------------------------- test case core-0017NO -----------------------------
  721. //
  722. // Testing feature - The "nodeName" attribute for an EntityReference node
  723. // is the name of the entity referenced.
  724. //
  725. // Testing approach - Retrieve the first Entity Reference node from the last
  726. // child of the second employee and examine its
  727. // "nodeName" attribute. It should be set to "ent2".
  728. //
  729. // Semantic Requirements: 13, 15
  730. //
  731. //----------------------------------------------------------------------------
  732. [Test]
  733. public void core0017NO()
  734. {
  735. string computedValue = "";
  736. string expectedValue = "ent2";
  737. System.Xml.XmlNode testNode = null;
  738. System.Xml.XmlNode entRefNode = null;
  739. testResults results = new testResults("Core0017NO");
  740. try
  741. {
  742. results.description = "The nodeName attribute for an EntityReference Node " +
  743. "should be set to the name of the entity referenced.";
  744. //
  745. // Retrieve the targeted data.
  746. //
  747. testNode = util.nodeObject(util.SECOND,util.SIXTH);
  748. entRefNode = testNode.FirstChild;//.node.
  749. //
  750. // The nodeName attribute should be set to "ent2".
  751. //
  752. computedValue = entRefNode.Name;
  753. }
  754. catch(System.Exception ex)
  755. {
  756. computedValue = "Exception " + ex.Message;
  757. }
  758. //
  759. // write out results.
  760. //
  761. results.expected = expectedValue;
  762. results.actual = computedValue;
  763. Assert.AreEqual (results.expected, results.actual);
  764. }
  765. //------------------------ End test case core-0017NO --------------------------
  766. //
  767. //------------------------- test case core-0018NO -----------------------------
  768. //
  769. // Testing feature - The "nodeName" attribute for an Entity node is
  770. // the entity name.
  771. //
  772. // Testing approach - Retrieve the first Entity declaration in the
  773. // "DOCTYPE" section of the XML file and examine
  774. // its "nodeName" attribute. It should be set to
  775. // "ent1" .
  776. //
  777. // Semantic Requirements: 13, 15
  778. //
  779. //----------------------------------------------------------------------------
  780. [Test]
  781. public void core0018NO()
  782. {
  783. string computedValue = "";
  784. string expectedValue = "ent1";
  785. System.Xml.XmlNode testNode = null;
  786. testResults results = new testResults("Core0018NO");
  787. results.description = "The nodeName attribute for an Entity Node " +
  788. "should be set to the entity name.";
  789. //
  790. // Get the targeted data.
  791. //
  792. testNode = util.getEntity("ent1");
  793. //
  794. // The nodeName attribute should be set to "ent1".
  795. //
  796. computedValue = testNode.Name;
  797. //
  798. // write out results.
  799. //
  800. results.expected = expectedValue;
  801. results.actual = computedValue;
  802. Assert.AreEqual (results.expected, results.actual);
  803. }
  804. //------------------------ End test case core-0018NO --------------------------
  805. //
  806. //------------------------- test case core-0019NO -----------------------------
  807. //
  808. // Testing feature - The "nodeName" attribute for a ProcessingInstruction
  809. // node is the target.
  810. //
  811. // Testing approach - Retrieve the first declaration in the XML file
  812. // and examine its "nodeName" attribute. It should
  813. // be set to "xml".
  814. //
  815. // Semantic Requirements: 13, 15
  816. //
  817. //----------------------------------------------------------------------------
  818. [Test]
  819. public void core0019NO()
  820. {
  821. string computedValue = "0";
  822. string expectedValue = "xml";
  823. System.Xml.XmlNode testNode = null;
  824. testResults results = new testResults("Core0019NO");
  825. results.description = "The nodeName attribute for a ProcessingInstruction "+
  826. "Node should be set to the target.";
  827. //
  828. // Get the targeted data.
  829. //
  830. testNode = util.getDOMDocument().ChildNodes.Item(0);
  831. //
  832. // The nodeName attribute should be set to "xml".
  833. //
  834. computedValue = testNode.Name;
  835. //
  836. // write out results.
  837. //
  838. results.expected = expectedValue;
  839. results.actual = computedValue;
  840. Assert.AreEqual (results.expected, results.actual);
  841. }
  842. //------------------------ End test case core-0019NO --------------------------
  843. //
  844. //------------------------- test case core-0020NO -----------------------------
  845. //
  846. // Testing feature - The "nodeName" attribute for a comment node is
  847. // "#comment".
  848. //
  849. // Testing approach - Retrieve the only comment in the XML file (third child)
  850. // and examine its "nodeName" attribute. It should
  851. // be set to "#comment".
  852. //
  853. // Semantic Requirements: 13, 15
  854. //
  855. //----------------------------------------------------------------------------
  856. [Test]
  857. public void core0020NO()
  858. {
  859. string computedValue = "0";
  860. string expectedValue = "#comment";
  861. System.Xml.XmlNode testNode = null;
  862. testResults results = new testResults("Core0020NO");
  863. results.description = "The nodeName attribute for a comment Node "+
  864. "should be set to \"#comment\".";
  865. //
  866. // Get the targeted data.
  867. //
  868. testNode = util.getDOMDocument().ChildNodes.Item(2);
  869. //
  870. // The nodeName attribute should be set to "#comment".
  871. //
  872. computedValue = testNode.Name;
  873. //
  874. // write out results.
  875. //
  876. results.expected = expectedValue;
  877. results.actual = computedValue;
  878. Assert.AreEqual (results.expected, results.actual);
  879. }
  880. //------------------------ End test case core-0020NO --------------------------
  881. //
  882. //------------------------- test case core-0021NO -----------------------------
  883. //
  884. // Testing feature - The "nodeName" attribute for a Document node is
  885. // "#document".
  886. //
  887. // Testing approach - Retrieve the DOM Document and examine its
  888. // "nodeName" attribute. It should be set to "#document".
  889. //
  890. // Semantic Requirements: 13, 15
  891. //
  892. //----------------------------------------------------------------------------
  893. [Test]
  894. public void core0021NO()
  895. {
  896. string computedValue = "";
  897. string expectedValue = "#document";
  898. System.Xml.XmlNode testNodeNode = null;
  899. testResults results = new testResults("Core0021NO");
  900. results.description = "The nodeName attribute for a Document Node "+
  901. "should be set to \"#document\".";
  902. //
  903. // Get the targeted data.
  904. //
  905. System.Xml.XmlNode testNode = util.getDOMDocument();
  906. //
  907. // The nodeName attribute should be set to "#document".
  908. //
  909. computedValue = testNode.Name;
  910. //
  911. // write out results.
  912. //
  913. results.expected = expectedValue;
  914. results.actual = computedValue;
  915. Assert.AreEqual (results.expected, results.actual);
  916. }
  917. //------------------------ End test case core-0021NO --------------------------
  918. //
  919. //------------------------- test case core-0022NO -----------------------------
  920. //
  921. // Testing feature - The "nodeName" attribute for a DocumentType node is
  922. // the document type name.
  923. //
  924. // Testing approach - Retrieve the DOCTYPE declaration (second child) from
  925. // the XML file and examine its "nodeName" attribute.
  926. // It should be set to "staff".
  927. //
  928. // Semantic Requirements: 13, 15
  929. //
  930. //----------------------------------------------------------------------------
  931. [Test]
  932. public void core0022NO()
  933. {
  934. string computedValue = "";
  935. string expectedValue = "staff";
  936. System.Xml.XmlNode testNode = null;
  937. testResults results = new testResults("Core0022NO");
  938. results.description = "The nodeName attribute for a DocumentType Node " +
  939. "should be set to the document type name.";
  940. //
  941. // Get the targeted data.
  942. //
  943. testNode = util.getDocType();
  944. //
  945. // The nodeName attribute should be set to "staff".
  946. //
  947. computedValue = testNode.Name;
  948. //
  949. // write out results.
  950. //
  951. results.expected = expectedValue;
  952. results.actual = computedValue;
  953. Assert.AreEqual (results.expected, results.actual);
  954. }
  955. //------------------------ End test case core-0022NO ------------------------
  956. //
  957. //------------------------- test case core-0023NO -----------------------------
  958. //
  959. // Testing feature - The "nodeName" attribute for a DocumentFragment node
  960. // is "#document-fragment".
  961. //
  962. // Testing approach - Retrieve the whole DOM document and invoke its
  963. // "createDocumentFragment()" method and examine the
  964. // "nodeName" attribute of the returned node. It should
  965. // be set to "#document-fragment".
  966. //
  967. // Semantic Requirements: 13, 15
  968. //
  969. //----------------------------------------------------------------------------
  970. [Test]
  971. public void core0023NO()
  972. {
  973. string computedValue = "";
  974. string expectedValue = "#document-fragment";
  975. System.Xml.XmlNode testNode = null;
  976. testResults results = new testResults("Core0023NO");
  977. results.description = "The nodeName attribute for a DocumentFragment Node "+
  978. "should be set to \"#document-fragment\".";
  979. //
  980. // Get the targeted data.
  981. //
  982. testNode = util.getDOMDocument().CreateDocumentFragment();
  983. //
  984. // The nodeName attribute should be set to "#document-fragment".
  985. //
  986. computedValue = testNode.Name;
  987. //
  988. // write out results.
  989. //
  990. results.expected = expectedValue;
  991. results.actual = computedValue;
  992. Assert.AreEqual (results.expected, results.actual);
  993. }
  994. //------------------------ End test case core-0023NO --------------------------
  995. //
  996. //------------------------- test case core-0024NO -----------------------------
  997. //
  998. // Testing feature - The "nodeName" attribute for a notation node is
  999. // the name of the notation.
  1000. //
  1001. // Testing approach - Retrieve the Notation declaration inside the
  1002. // DocumentType node and examine its "nodeName"
  1003. // attribute. It should be set to "notation1".
  1004. //
  1005. // Semantic Requirements: 13, 15
  1006. //
  1007. //----------------------------------------------------------------------------
  1008. [Test]
  1009. public void core0024NO()
  1010. {
  1011. string computedValue = "";
  1012. string expectedValue = "notation1";
  1013. System.Xml.XmlNode testNode = null;
  1014. testResults results = new testResults("Core0024NO");
  1015. try
  1016. {
  1017. results.description = "The nodeName attribute for a Notation Node " +
  1018. "should be set to the notation name.";
  1019. //
  1020. // Get the targeted data.
  1021. //
  1022. testNode = util.getNotation("notation1");
  1023. //
  1024. // The nodeName attribute should be set to "notation1".
  1025. //
  1026. computedValue = testNode.Name;
  1027. }
  1028. catch(System.Exception ex)
  1029. {
  1030. computedValue = "Exception " + ex.Message;
  1031. }
  1032. //
  1033. // write out results.
  1034. //
  1035. results.expected = expectedValue;
  1036. results.actual = computedValue;
  1037. Assert.AreEqual (results.expected, results.actual);
  1038. }
  1039. //------------------------ End test case core-0024NO --------------------------
  1040. //
  1041. //------------------------ test case core-0025NO ----------------------------
  1042. //
  1043. // Testing feature - The "nodeValue" attribute for an Element node is
  1044. // null.
  1045. //
  1046. // Testing approach - Retrieve the root node of the DOM object and check
  1047. // its "nodeValue" attribute. It should be equal
  1048. // to null.
  1049. //
  1050. // Semantic Requirements: 13, 16
  1051. //
  1052. //----------------------------------------------------------------------------
  1053. [Test]
  1054. public void core0025NO()
  1055. {
  1056. object computedValue = null;
  1057. object expectedValue = null;
  1058. testResults results = new testResults("Core0025NO");
  1059. results.description = "The nodeValue attribute for an Element Node " +
  1060. "should be set to null.";
  1061. //
  1062. // The nodeValue attribute should be set to null.
  1063. //
  1064. computedValue = util.getRootNode().Value;
  1065. //
  1066. // write out results.
  1067. //
  1068. results.expected = (expectedValue == null).ToString();
  1069. results.actual = (computedValue == null).ToString();
  1070. Assert.AreEqual (results.expected, results.actual);
  1071. }
  1072. //------------------------ End test case core-0025NO --------------------------
  1073. //
  1074. //------------------------- test case core-0026NO -----------------------------
  1075. //
  1076. // Testing feature - The "nodeValue" attribute for an Attribute node is
  1077. // the value of the attribute.
  1078. //
  1079. // Testing approach - Retrieve the attribute named "domestic" from the last
  1080. // child of the first employee. Its "nodeValue" attribute
  1081. // is then checked, it should be set to "Yes".
  1082. //
  1083. // Semantic Requirements: 13, 16
  1084. //
  1085. //----------------------------------------------------------------------------
  1086. [Test]
  1087. public void core0026NO()
  1088. {
  1089. string computedValue = "";
  1090. string expectedValue = "Yes";
  1091. System.Xml.XmlElement testNode = null;
  1092. System.Xml.XmlAttribute attrNode = null;
  1093. testResults results = new testResults("Core0026NO");
  1094. try
  1095. {
  1096. results.description = "The nodeValue attribute for an Attribute Node " +
  1097. "should be set to the value of the attribute.";
  1098. //
  1099. // Get the targeted data.
  1100. //
  1101. testNode = (System.Xml.XmlElement)util.nodeObject(util.FIRST,util.SIXTH);
  1102. attrNode = testNode.GetAttributeNode("domestic");//.node.
  1103. //
  1104. // The nodeType attribute should be set to "Yes".
  1105. //
  1106. computedValue = attrNode.Value;
  1107. }
  1108. catch(System.Exception ex)
  1109. {
  1110. computedValue = "Exception " + ex.Message;
  1111. }
  1112. //
  1113. // write out results.
  1114. //
  1115. results.expected = expectedValue;
  1116. results.actual = computedValue;
  1117. Assert.AreEqual (results.expected, results.actual);
  1118. }
  1119. //------------------------ End test case core-0026NO --------------------------
  1120. //
  1121. //------------------------- test case core-0027NO -----------------------------
  1122. //
  1123. // Testing feature - The "nodeValue" attribute for a Text node is
  1124. // content of the Text node.
  1125. //
  1126. // Testing approach - Retrieve the Text data from the last child of the
  1127. // first employee and and examine its "nodeValue"
  1128. // attribute. It should be set to
  1129. // "1230 North Ave. Dallas, Texas 98551".
  1130. //
  1131. // Semantic Requirements: 13, 16
  1132. //
  1133. //----------------------------------------------------------------------------
  1134. [Test]
  1135. public void core0027NO()
  1136. {
  1137. string computedValue = "";
  1138. string expectedValue = "1230 North Ave. Dallas, Texas 98551";
  1139. System.Xml.XmlNode testNode = null;
  1140. System.Xml.XmlNode textNode = null;
  1141. testResults results = new testResults("Core0027NO");
  1142. try
  1143. {
  1144. results.description = "The nodeValue attribute for a Text node " +
  1145. "should be set to contents of the of the Text node.";
  1146. //
  1147. // Get the targeted data.
  1148. //
  1149. testNode = util.nodeObject(util.FIRST,util.SIXTH);
  1150. textNode = testNode.FirstChild;//.node.
  1151. //
  1152. // Retrieve the nodeValue attribute.
  1153. //
  1154. computedValue = textNode.Value;
  1155. }
  1156. catch(System.Exception ex)
  1157. {
  1158. computedValue = "Exception " + ex.Message;
  1159. }
  1160. //
  1161. // write out results.
  1162. //
  1163. results.expected = expectedValue;
  1164. results.actual = computedValue;
  1165. Assert.AreEqual (results.expected, results.actual);
  1166. }
  1167. //------------------------ End test case core-0027NO --------------------------
  1168. //
  1169. //------------------------- test case core-0028NO -----------------------------
  1170. //
  1171. // Testing feature - The "nodeValue" attribute for a CDATASection node is
  1172. // the content of the CDATASection.
  1173. //
  1174. // Testing approach - Retrieve the first CDATASection node inside the second
  1175. // child of the second employee and examine its "nodeValue"
  1176. // attribute. It should be set to "This is a CDATA Section
  1177. // with EntityReference number 2 &ent2;".
  1178. //
  1179. // Semantic Requirements: 13, 16
  1180. //
  1181. //----------------------------------------------------------------------------
  1182. [Test]
  1183. public void core0028NO()
  1184. {
  1185. string computedValue = "0";
  1186. string expectedValue = "This is a CDATASection with EntityReference number 2 &ent2;";
  1187. System.Xml.XmlNode testNode = null;
  1188. System.Xml.XmlNode cDataNode = null;
  1189. testResults results = new testResults("Core0028NO");
  1190. try
  1191. {
  1192. results.description = "The nodeValue attribute for a CDATASection Node "+
  1193. "should be set to the contents of the CDATASection.";
  1194. //
  1195. // Retrieve the targeted data.
  1196. //
  1197. testNode = util.nodeObject(util.SECOND,util.SECOND);
  1198. cDataNode = testNode.ChildNodes.Item(1);//.node.
  1199. //
  1200. // Get the "nodeValue" attribute.
  1201. //
  1202. computedValue = cDataNode.Value;
  1203. }
  1204. catch(System.Exception ex)
  1205. {
  1206. computedValue = "Exception " + ex.Message;
  1207. }
  1208. //
  1209. // write out results.
  1210. //
  1211. results.expected = expectedValue;
  1212. results.actual = computedValue;
  1213. Assert.AreEqual (results.expected, results.actual);
  1214. }
  1215. //------------------------ End test case core-0028NO --------------------------
  1216. //
  1217. //------------------------- test case core-0029NO -----------------------------
  1218. //
  1219. // Testing feature - The "nodeValue" attribute for an EntityReference node
  1220. // is null.
  1221. //
  1222. // Testing approach - Retrieve the first Entity Reference node from the last
  1223. // child of the second employee and examine its
  1224. // "nodeValue" attribute. It should be set to null.
  1225. //
  1226. // Semantic Requirements: 13, 16
  1227. //
  1228. //----------------------------------------------------------------------------
  1229. [Test]
  1230. public void core0029NO()
  1231. {
  1232. object computedValue = null;
  1233. object expectedValue = null;
  1234. System.Xml.XmlNode testNode = null;
  1235. System.Xml.XmlNode entRefNode = null;
  1236. testResults results = new testResults("Core0029NO");
  1237. try
  1238. {
  1239. results.description = "The nodeValue attribute for an EntityReference "+
  1240. "node should be set to null.";
  1241. //
  1242. // Get the targeted data.
  1243. //
  1244. testNode = util.nodeObject(util.SECOND,util.SIXTH);
  1245. entRefNode = testNode.FirstChild;//.node.
  1246. //
  1247. // The nodeValue attribute should be set to null.
  1248. //
  1249. computedValue = entRefNode.Value;
  1250. }
  1251. catch(System.Exception ex)
  1252. {
  1253. computedValue = "Exception " + ex.Message;
  1254. }
  1255. //
  1256. // write out results.
  1257. //
  1258. results.expected = (expectedValue == null).ToString();
  1259. results.actual = (computedValue == null).ToString();
  1260. Assert.AreEqual (results.expected, results.actual);
  1261. }
  1262. //------------------------ End test case core-0029NO --------------------------
  1263. //
  1264. //------------------------- test case core-0030NO -----------------------------
  1265. //
  1266. // Testing feature - The "nodeValue" attribute for an Entity node
  1267. // is null.
  1268. //
  1269. // Testing approach - Retrieve the first Entity declaration in the
  1270. // "DOCTYPE" section of the XML file and examine
  1271. // its "nodeValue" attribute. It should be set to
  1272. // null.
  1273. //
  1274. // Semantic Requirements: 13, 16
  1275. //
  1276. //----------------------------------------------------------------------------
  1277. [Test]
  1278. public void core0030NO()
  1279. {
  1280. object computedValue = null;
  1281. object expectedValue = null;
  1282. System.Xml.XmlNode testNode = null;
  1283. testResults results = new testResults("Core0030NO");
  1284. results.description = "The nodeValue attribute for an Entity node " +
  1285. "should be set to null.";
  1286. //
  1287. // Get the targeted data.
  1288. //
  1289. testNode = util.getEntity("ent1");;
  1290. //
  1291. // The nodeValue attribute should be set to null.
  1292. //
  1293. computedValue = testNode.Value;
  1294. //
  1295. // write out results.
  1296. //
  1297. results.expected = (expectedValue == null).ToString();
  1298. results.actual = (computedValue == null).ToString();
  1299. Assert.AreEqual (results.expected, results.actual);
  1300. }
  1301. //------------------------ End test case core-0030NO --------------------------
  1302. //
  1303. //------------------------- test case core-0031NO -----------------------------
  1304. //
  1305. // Testing feature - The "nodeValue" attribute for a ProcessingInstruction
  1306. // node is the entire content excluding the target.
  1307. //
  1308. // Testing approach - Retrieve the first declaration in the XML file
  1309. // and examine its "nodeValue" attribute. It should
  1310. // be set to "version="1.0"".
  1311. //
  1312. // Semantic Requirements: 13, 16
  1313. //
  1314. //----------------------------------------------------------------------------
  1315. [Test]
  1316. public void core0031NO()
  1317. {
  1318. string computedValue = "";
  1319. string expectedValue = "version=\"1.0\"";
  1320. System.Xml.XmlNode testNode = null;
  1321. testResults results = new testResults("Core0031NO");
  1322. results.description = "The nodeValue attribute for a ProcessingInstruction "+
  1323. "node is the entire contents excluding the target.";
  1324. //
  1325. // Get the targeted data.
  1326. //
  1327. testNode = util.getDOMDocument().ChildNodes.Item(0);
  1328. //
  1329. // The nodeValue attribute should be set to "version="1.0"".
  1330. //
  1331. computedValue = testNode.Value;
  1332. //
  1333. // write out results.
  1334. //
  1335. results.expected = expectedValue;
  1336. results.actual = computedValue;
  1337. Assert.AreEqual (results.expected, results.actual);
  1338. }
  1339. //------------------------ End test case core-0031NO --------------------------
  1340. //
  1341. //------------------------- test case core-0032NO -----------------------------
  1342. //
  1343. // Testing feature - The "nodeValue" attribute for a comment node is
  1344. // the content of the comment.
  1345. //
  1346. // Testing approach - Retrieve the only comment in the XML file (third child)
  1347. // and examine its "nodeValue" attribute. It should
  1348. // be set to " This is comment number 1.".
  1349. //
  1350. // Semantic Requirements: 13, 16
  1351. //
  1352. //----------------------------------------------------------------------------
  1353. [Test]
  1354. public void core0032NO()
  1355. {
  1356. string computedValue = "";
  1357. string expectedValue = " This is comment number 1.";
  1358. System.Xml.XmlNode testNode = null;
  1359. testResults results = new testResults("Core0032NO");
  1360. results.description = "The nodeValue attribute for a comment node " +
  1361. "should be set to the contents of the comment.";
  1362. //
  1363. // Get the targeted data.
  1364. //
  1365. testNode = util.getDOMDocument().ChildNodes.Item(2);
  1366. //
  1367. // The nodeValue attribute should be set to " This is comment number 1."
  1368. //
  1369. computedValue = testNode.Value;
  1370. //
  1371. // write out results.
  1372. //
  1373. results.expected = expectedValue;
  1374. results.actual = computedValue;
  1375. Assert.AreEqual (results.expected, results.actual);
  1376. }
  1377. //------------------------ End test case core-0032NO --------------------------
  1378. //
  1379. //------------------------- test case core-0033NO -----------------------------
  1380. //
  1381. // Testing feature - The "nodeValue" attribute for a Document node is
  1382. // null.
  1383. //
  1384. // Testing approach - Retrieve the DOM Document and examine its
  1385. // "nodeValue" attribute. It should be set to null.
  1386. //
  1387. // Semantic Requirements: 13, 16
  1388. //
  1389. //----------------------------------------------------------------------------
  1390. [Test]
  1391. public void core0033NO()
  1392. {
  1393. object computedValue = null;
  1394. object expectedValue = null;
  1395. System.Xml.XmlNode testNode = null;
  1396. testResults results = new testResults("Core0033NO");
  1397. results.description = "The nodeValue attribute for a Document node "+
  1398. "should be set to null.";
  1399. //
  1400. // Get the targeted data.
  1401. //
  1402. testNode = util.getDOMDocument();
  1403. //
  1404. // The nodeValue attribute should be set to null.
  1405. //
  1406. computedValue = testNode.Value;
  1407. //
  1408. // write out results.
  1409. //
  1410. results.expected = (expectedValue == null).ToString();
  1411. results.actual = (computedValue == null).ToString();
  1412. Assert.AreEqual (results.expected, results.actual);
  1413. }
  1414. //------------------------ End test case core-0033NO --------------------------
  1415. //
  1416. //------------------------- test case core-0034NO -----------------------------
  1417. //
  1418. // Testing feature - The "nodeValue" attribute for a DocumentType node is
  1419. // null.
  1420. //
  1421. // Testing approach - Retrieve the DOCTYPE declaration (second child) from
  1422. // the XML file and examine its "nodeValue" attribute.
  1423. // It should be set to null.
  1424. //
  1425. // Semantic Requirements: 13, 16
  1426. //
  1427. //----------------------------------------------------------------------------
  1428. [Test]
  1429. public void core0034NO()
  1430. {
  1431. object computedValue = null;
  1432. object expectedValue = null;
  1433. System.Xml.XmlNode testNode = null;
  1434. testResults results = new testResults("Core0034NO");
  1435. results.description = "The nodeValue attribute for a DocumentType Node " +
  1436. "should be set to null.";
  1437. //
  1438. // Get the targeted data.
  1439. //
  1440. testNode = util.getDOMDocument().ChildNodes.Item(1);
  1441. //
  1442. // The nodeValue attribute should be set to null.
  1443. //
  1444. computedValue = testNode.Value;
  1445. //
  1446. // write out results.
  1447. //
  1448. results.expected = (expectedValue == null).ToString();
  1449. results.actual = (computedValue == null).ToString();
  1450. Assert.AreEqual (results.expected, results.actual);
  1451. }
  1452. //------------------------ End test case core-0034NO ------------------------
  1453. //
  1454. //------------------------- test case core-0035NO -----------------------------
  1455. //
  1456. // Testing feature - The "nodeValue" attribute for a DocumentFragment node
  1457. // is null.
  1458. //
  1459. // Testing approach - Retrieve the whole DOM document and invoke its
  1460. // "createDocumentFragment()" method and examine the
  1461. // "nodeValue" attribute of the returned node. It should
  1462. // be set to null.
  1463. //
  1464. // Semantic Requirements: 13, 16
  1465. //
  1466. //----------------------------------------------------------------------------
  1467. [Test]
  1468. public void core0035NO()
  1469. {
  1470. object computedValue = null;
  1471. object expectedValue = null;
  1472. System.Xml.XmlNode testNode = null;
  1473. testResults results = new testResults("Core0035NO");
  1474. results.description = "The nodeValue attribute for a DocumentFragment node " +
  1475. "should be set to null.";
  1476. //
  1477. // Get the targeted data.
  1478. //
  1479. testNode = util.getDOMDocument().CreateDocumentFragment();
  1480. //
  1481. // The nodeValue attribute should be set to null.
  1482. //
  1483. computedValue = testNode.Value;
  1484. //
  1485. // write out results.
  1486. //
  1487. results.expected = (expectedValue == null).ToString();
  1488. results.actual = (computedValue == null).ToString();
  1489. Assert.AreEqual (results.expected, results.actual);
  1490. }
  1491. //------------------------ End test case core-0035NO --------------------------
  1492. //
  1493. //------------------------- test case core-0036NO -----------------------------
  1494. //
  1495. // Testing feature - The "nodeValue" attribute for a notation node is
  1496. // the name of the notation.
  1497. //
  1498. // Testing approach - Retrieve the Notation declaration inside the
  1499. // DocumentType node and examine its nodeValue
  1500. // attribute. It should be set to null.
  1501. //
  1502. // Semantic Requirements: 13, 16
  1503. //
  1504. //----------------------------------------------------------------------------
  1505. [Test]
  1506. public void core0036NO()
  1507. {
  1508. object computedValue = null;
  1509. object expectedValue = null;
  1510. System.Xml.XmlNode testNode = null;
  1511. testResults results = new testResults("Core0036NO");
  1512. try
  1513. {
  1514. results.description = "The nodeValue attribute for a Notation node " +
  1515. "should be set to null.";
  1516. //
  1517. // Get the targeted data.
  1518. //
  1519. testNode = util.getNotation("notation1");
  1520. //
  1521. // The nodeValue attribute should be set to null.
  1522. //
  1523. computedValue = testNode.Value;
  1524. }
  1525. catch(System.Exception ex)
  1526. {
  1527. computedValue = "Exception " + ex.Message;
  1528. }
  1529. //
  1530. // write out results.
  1531. //
  1532. results.expected = (expectedValue == null).ToString();
  1533. results.actual = (computedValue == null).ToString();
  1534. Assert.AreEqual (results.expected, results.actual);
  1535. }
  1536. //------------------------ End test case core-0036NO --------------------------
  1537. //
  1538. //------------------------ test case core-0037NO ----------------------------
  1539. //
  1540. // Testing feature - The "attributes" attribute for an Element node is
  1541. // a NamedNodeMap.
  1542. //
  1543. // Testing approach - Retrieve the last child of the third employee
  1544. // and examine its "attributes" attribute. It should be
  1545. // equal to a NamedNodeMap of its attributes.
  1546. //
  1547. // Semantic Requirements: 13, 17
  1548. //
  1549. //----------------------------------------------------------------------------
  1550. [Test]
  1551. public void core0037NO()
  1552. {
  1553. string computedValue = "";
  1554. string expectedValue = "";
  1555. System.Xml.XmlNode testNode = null;
  1556. string testName = "core-0037NO";
  1557. testResults results = new testResults("core0037NO");
  1558. try
  1559. {
  1560. results.description += "The \"attributes\" attribute for an Element node";
  1561. results.description += " should be set to a NamedNodeMap. ";
  1562. //
  1563. // Retrieve the targeted data and its attributes.
  1564. //
  1565. testNode = util.nodeObject(util.THIRD,util.SIXTH);
  1566. computedValue += testNode.Attributes.Item(util.FIRST).Name+" ";
  1567. computedValue += testNode.Attributes.Item(util.SECOND).Name;
  1568. //
  1569. // Determine the order of the NamedNodeMap items.
  1570. //
  1571. if (computedValue.Substring(0,1) == "d" && computedValue.Substring(1,1) == "o")
  1572. expectedValue = "domestic street";
  1573. else
  1574. expectedValue = "street domestic";
  1575. }
  1576. catch(System.Exception ex)
  1577. {
  1578. computedValue = "Exception " + ex.Message;
  1579. }
  1580. //
  1581. // write out results.
  1582. //
  1583. results.expected = expectedValue;
  1584. results.actual = computedValue;
  1585. Assert.AreEqual (results.expected, results.actual);
  1586. }
  1587. //------------------------ End test case core-0037NO --------------------------
  1588. //
  1589. //------------------------- test case core-0038NO -----------------------------
  1590. //
  1591. // Testing feature - The "attributes" attribute for an Attribute node is
  1592. // null.
  1593. //
  1594. // Testing approach - Retrieve the first attribute from the last child of
  1595. // the first employee and. Its "attributes" attribute
  1596. // is then checked. It should be set to null.
  1597. //
  1598. // Semantic Requirements: 13, 17
  1599. //
  1600. //----------------------------------------------------------------------------
  1601. [Test]
  1602. public void core0038NO()
  1603. {
  1604. object computedValue = null;
  1605. object expectedValue = null;
  1606. System.Xml.XmlNode testNode = null;
  1607. System.Xml.XmlAttribute attrNode = null;
  1608. testResults results = new testResults("Core0038NO");
  1609. try
  1610. {
  1611. results.description = "The \"attributes\" attribute for an Attribute node " +
  1612. "should be set to null.";
  1613. //
  1614. // Retrieve the targeted data.
  1615. //
  1616. testNode = util.nodeObject(util.FIRST,util.SIXTH);
  1617. attrNode = (System.Xml.XmlAttribute)testNode.Attributes.Item(util.FIRST);
  1618. //
  1619. // The "attributes" attribute should be set to null.
  1620. //
  1621. computedValue = attrNode.Attributes;
  1622. }
  1623. catch(System.Exception ex)
  1624. {
  1625. computedValue = "Exception " + ex.Message;
  1626. }
  1627. //
  1628. // write out results.
  1629. //
  1630. results.expected = (expectedValue == null).ToString();
  1631. results.actual = (computedValue == null).ToString();
  1632. Assert.AreEqual (results.expected, results.actual);
  1633. }
  1634. //------------------------ End test case core-0038NO --------------------------
  1635. //
  1636. //------------------------- test case core-0039NO -----------------------------
  1637. //
  1638. // Testing feature - The "attributes" attribute for a Text node is
  1639. // null.
  1640. //
  1641. // Testing approach - Retrieve the text data from the last child of the
  1642. // first employee and examine its "attributes"
  1643. // attribute. It should be set to null.
  1644. //
  1645. // Semantic Requirements: 13, 17
  1646. //
  1647. //----------------------------------------------------------------------------
  1648. [Test]
  1649. public void core0039NO()
  1650. {
  1651. object computedValue = null;
  1652. object expectedValue = null;
  1653. System.Xml.XmlNode testNode = null;
  1654. System.Xml.XmlNode textNode = null;
  1655. testResults results = new testResults("Core0039NO");
  1656. try
  1657. {
  1658. results.description = "The \"attributes\" attribute for a Text node "+
  1659. "should be set to null.";
  1660. //
  1661. // Retrieve the targeted data.
  1662. //
  1663. testNode = util.nodeObject(util.FIRST,util.SIXTH);
  1664. textNode = testNode.FirstChild;//.node.
  1665. //
  1666. // The "attributes" attribute should be set to null
  1667. //
  1668. computedValue = textNode.Attributes;
  1669. }
  1670. catch(System.Exception ex)
  1671. {
  1672. computedValue = "Exception " + ex.Message;
  1673. }
  1674. //
  1675. // write out results.
  1676. //
  1677. results.expected = (expectedValue == null).ToString();
  1678. results.actual = (computedValue == null).ToString();
  1679. Assert.AreEqual (results.expected, results.actual);
  1680. }
  1681. //------------------------ End test case core-0039NO --------------------------
  1682. //
  1683. //------------------------- test case core-0040NO -----------------------------
  1684. //
  1685. // Testing feature - The "attributes" attribute for a CDATASection node is
  1686. // null.
  1687. //
  1688. // Testing approach - Retrieve the CDATASection node contained inside
  1689. // the second child of the second employee and
  1690. // examine its "attributes" attribute. It should be
  1691. // set to null.
  1692. //
  1693. // Semantic Requirements: 13, 17
  1694. //
  1695. //----------------------------------------------------------------------------
  1696. [Test]
  1697. public void core0040NO()
  1698. {
  1699. object computedValue = null;
  1700. object expectedValue = null;
  1701. System.Xml.XmlNode testNode = null;
  1702. System.Xml.XmlNode cDataNode = null;
  1703. testResults results = new testResults("Core0040NO");
  1704. try
  1705. {
  1706. results.description = "The \"attributes\" attribute for a CDATASection "+
  1707. "node should be set to null.";
  1708. //
  1709. // Retrieve the targeted data.
  1710. //
  1711. testNode = util.nodeObject(util.SECOND,util.SECOND);
  1712. cDataNode = testNode.LastChild;//.node.
  1713. //
  1714. // The "attributes" attribute should be set to null.
  1715. //
  1716. computedValue = cDataNode.Attributes;
  1717. }
  1718. catch(System.Exception ex)
  1719. {
  1720. computedValue = "Exception " + ex.Message;
  1721. }
  1722. //
  1723. // write out results.
  1724. //
  1725. results.expected = (expectedValue == null).ToString();
  1726. results.actual = (computedValue == null).ToString();
  1727. Assert.AreEqual (results.expected, results.actual);
  1728. }
  1729. //------------------------ End test case core-0040NO --------------------------
  1730. //
  1731. //------------------------- test case core-0041NO -----------------------------
  1732. //
  1733. // Testing feature - The "attributes" attribute for an EntityReference node
  1734. // is null.
  1735. //
  1736. // Testing approach - Retrieve the first Entity Reference node from the last
  1737. // child of the second employee and examine its
  1738. // "attributes" attribute. It should be set to null.
  1739. //
  1740. // Semantic Requirements: 13, 17
  1741. //
  1742. //----------------------------------------------------------------------------
  1743. [Test]
  1744. public void core0041NO()
  1745. {
  1746. object computedValue = null;
  1747. object expectedValue = null;
  1748. System.Xml.XmlNode testNode = null;
  1749. System.Xml.XmlNode entRefNode = null;
  1750. testResults results = new testResults("Core0041NO");
  1751. try
  1752. {
  1753. results.description = "The \"attributes\" attribute for an "+
  1754. "EntityReference node should be set to null.";
  1755. //
  1756. // Retrieve the targeted data.
  1757. //
  1758. testNode = util.nodeObject(util.SECOND,util.SIXTH);
  1759. entRefNode = testNode.FirstChild;//.node.
  1760. //
  1761. // The \"attributes\" attribute should be set to null.
  1762. //
  1763. computedValue = entRefNode.Attributes;
  1764. }
  1765. catch(System.Exception ex)
  1766. {
  1767. computedValue = "Exception " + ex.Message;
  1768. }
  1769. //
  1770. // write out results.
  1771. //
  1772. results.expected = (expectedValue == null).ToString();
  1773. results.actual = (computedValue == null).ToString();
  1774. Assert.AreEqual (results.expected, results.actual);
  1775. }
  1776. //------------------------ End test case core-0041NO --------------------------
  1777. //
  1778. //------------------------- test case core-0042NO -----------------------------
  1779. //
  1780. // Testing feature - The "attributes" attribute for an Entity node
  1781. // is null.
  1782. //
  1783. // Testing approach - Retrieve the first Entity declaration in the
  1784. // "DOCTYPE" section of the XML file and examine
  1785. // its "attributes" attribute. It should be set to
  1786. // null.
  1787. //
  1788. // Semantic Requirements: 13, 17
  1789. //
  1790. //----------------------------------------------------------------------------
  1791. [Test]
  1792. public void core0042NO()
  1793. {
  1794. object computedValue = null;
  1795. object expectedValue = null;
  1796. System.Xml.XmlNode testNode = null;
  1797. testResults results = new testResults("Core0042NO");
  1798. results.description = "The \"attributes\" attribute for an Entity node "+
  1799. "should be set to null.";
  1800. //
  1801. // Get the targeted data.
  1802. //
  1803. testNode = util.getEntity("ent1");
  1804. //
  1805. // The "attributes" attribute should be set to null.
  1806. //
  1807. computedValue = testNode.Attributes;
  1808. //
  1809. // write out results.
  1810. //
  1811. results.expected = (expectedValue == null).ToString();
  1812. results.actual = (computedValue == null).ToString();
  1813. Assert.AreEqual (results.expected, results.actual);
  1814. }
  1815. //------------------------ End test case core-0042NO --------------------------
  1816. //
  1817. //------------------------- test case core-0043NO -----------------------------
  1818. //
  1819. // Testing feature - The "attributes" attribute for a ProcessingInstruction
  1820. // node is null.
  1821. //
  1822. // Testing approach - Retrieve the first declaration in the XML file
  1823. // and examine its "attributes" attribute. It should
  1824. // be set to null.
  1825. //
  1826. // Semantic Requirements: 13, 17
  1827. //
  1828. //----------------------------------------------------------------------------
  1829. [Test]
  1830. public void core0043NO()
  1831. {
  1832. object computedValue = null;
  1833. object expectedValue = null;
  1834. System.Xml.XmlNode testNode = null;
  1835. testResults results = new testResults("Core0043NO");
  1836. results.description = "The \"attributes\" attribute for a "+
  1837. "ProcessingInstruction node is null.";
  1838. //
  1839. // Get the targeted data.
  1840. //
  1841. testNode = util.getDOMDocument().ChildNodes.Item(0);
  1842. //
  1843. // The "attributes" attribute should be set to null.
  1844. //
  1845. computedValue = testNode.Attributes;
  1846. //
  1847. // write out results.
  1848. //
  1849. results.expected = (expectedValue == null).ToString();
  1850. results.actual = (computedValue == null).ToString();
  1851. Assert.AreEqual (results.expected, results.actual);
  1852. }
  1853. //------------------------ End test case core-0043NO --------------------------
  1854. //
  1855. //------------------------- test case core-0044NO -----------------------------
  1856. //
  1857. // Testing feature - The "attributes" attribute for a comment node is
  1858. // null.
  1859. //
  1860. // Testing approach - Retrieve the third child of the DOM document and
  1861. // examine its "attributes" attribute. It should
  1862. // be set to null.
  1863. //
  1864. // Semantic Requirements: 13, 17
  1865. //
  1866. //----------------------------------------------------------------------------
  1867. [Test]
  1868. public void core0044NO()
  1869. {
  1870. object computedValue = null;
  1871. object expectedValue = null;
  1872. System.Xml.XmlNode testNode = null;
  1873. testResults results = new testResults("Core0044NO");
  1874. results.description = "The \"attributes\" attribute for a comment node "+
  1875. "should be set to null.";
  1876. //
  1877. // Get the targeted data.
  1878. //
  1879. testNode = util.getDOMDocument().ChildNodes.Item(2);
  1880. //
  1881. // The "attributes" attribute should be set to null.
  1882. //
  1883. computedValue = testNode.Attributes;
  1884. //
  1885. // write out results.
  1886. //
  1887. results.expected = (expectedValue == null).ToString();
  1888. results.actual = (computedValue == null).ToString();
  1889. Assert.AreEqual (results.expected, results.actual);
  1890. }
  1891. //------------------------ End test case core-0044NO --------------------------
  1892. //
  1893. //------------------------- test case core-0045NO -----------------------------
  1894. //
  1895. // Testing feature - The "attributes" attribute for a Document node is
  1896. // null.
  1897. //
  1898. // Testing approach - Retrieve the DOM Document and examine its
  1899. // "attributes" attribute. It should be set to null.
  1900. //
  1901. // Semantic Requirements: 13, 17
  1902. //
  1903. //----------------------------------------------------------------------------
  1904. [Test]
  1905. public void core0045NO()
  1906. {
  1907. object computedValue = null;
  1908. object expectedValue = null;
  1909. System.Xml.XmlNode testNode = null;
  1910. testResults results = new testResults("Core0045NO");
  1911. results.description = "The \"attributes\" attribute for a Document node "+
  1912. "should be set to null.";
  1913. //
  1914. // Get the targeted data.
  1915. //
  1916. testNode = util.getDOMDocument();
  1917. //
  1918. // The "attributes" attribute should be set to null.
  1919. //
  1920. computedValue = testNode.Attributes;
  1921. //
  1922. // write out results.
  1923. //
  1924. results.expected = (expectedValue == null).ToString();
  1925. results.actual = (computedValue == null).ToString();
  1926. Assert.AreEqual (results.expected, results.actual);
  1927. }
  1928. //------------------------ End test case core-0045NO --------------------------
  1929. //
  1930. //------------------------- test case core-0046NO -----------------------------
  1931. //
  1932. // Testing feature - The "attributes" attribute for a DocumentType node is
  1933. // null.
  1934. //
  1935. // Testing approach - Retrieve the DOCTYPE declaration (second child) from
  1936. // the XML file and examine its "attribute" attribute.
  1937. // It should be set to null.
  1938. //
  1939. // Semantic Requirements: 13, 17
  1940. //
  1941. //----------------------------------------------------------------------------
  1942. [Test]
  1943. public void core0046NO()
  1944. {
  1945. object computedValue = null;
  1946. object expectedValue = null;
  1947. System.Xml.XmlNode testNode = null;
  1948. testResults results = new testResults("Core0046NO");
  1949. results.description = "The \"attribute\" attribute for a DocumentType "+
  1950. "node should be set to null.";
  1951. //
  1952. // Get the targeted data.
  1953. //
  1954. testNode = util.getDocType();
  1955. //
  1956. // The "attributes" attribute should be set to null.
  1957. //
  1958. computedValue = testNode.Attributes;
  1959. //
  1960. // write out results.
  1961. //
  1962. results.expected = (expectedValue == null).ToString();
  1963. results.actual = (computedValue == null).ToString();
  1964. Assert.AreEqual (results.expected, results.actual);
  1965. }
  1966. //------------------------ End test case core-0046NO ------------------------
  1967. //
  1968. //------------------------- test case core-0047NO ---------------------------
  1969. //
  1970. // Testing feature - The "attributes" attribute for a DocumentFragment node
  1971. // is null.
  1972. //
  1973. // Testing approach - Retrieve the whole DOM document and invoke its
  1974. // "createDocumentFragment()" method and examine the
  1975. // "attributes" attribute of the returned node. It
  1976. // should be set to null.
  1977. //
  1978. // Semantic Requirements: 13, 17
  1979. //
  1980. //----------------------------------------------------------------------------
  1981. [Test]
  1982. public void core0047NO()
  1983. {
  1984. object computedValue = null;
  1985. object expectedValue = null;
  1986. System.Xml.XmlNode testNode = null;
  1987. testResults results = new testResults("Core0047NO");
  1988. results.description = "The \"attributes\" attribute for a DocumentFragment "+
  1989. "node should be set to null.";
  1990. //
  1991. // Get the targeted data.
  1992. //
  1993. testNode = util.getDOMDocument().CreateDocumentFragment();
  1994. //
  1995. // The "attributes" attribute should be set to null.
  1996. //
  1997. computedValue = testNode.Attributes;
  1998. //
  1999. // write out results.
  2000. //
  2001. results.expected = (expectedValue == null).ToString();
  2002. results.actual = (computedValue == null).ToString();
  2003. Assert.AreEqual (results.expected, results.actual);
  2004. }
  2005. //------------------------ End test case core-0047NO --------------------------
  2006. //
  2007. //------------------------- test case core-0048NO -----------------------------
  2008. //
  2009. // Testing feature - The "attributes" attribute for a notation node is
  2010. // null.
  2011. //
  2012. // Testing approach - Retrieve the Notation declaration inside the
  2013. // DocumentType node and examine its "attributes"
  2014. // attribute. It should be set to null.
  2015. //
  2016. // Semantic Requirements: 13, 17
  2017. //
  2018. //----------------------------------------------------------------------------
  2019. [Test]
  2020. public void core0048NO()
  2021. {
  2022. object computedValue = null;
  2023. object expectedValue = null;
  2024. System.Xml.XmlNode testNode = null;
  2025. testResults results = new testResults("Core0048NO");
  2026. try
  2027. {
  2028. results.description = "The \"attributes\" attribute for a Notation node "+
  2029. "should be set to null.";
  2030. //
  2031. // Get the targeted data.
  2032. //
  2033. testNode = util.getNotation("notation1");
  2034. //
  2035. // The "attributes" attribute should be set to null.
  2036. //
  2037. computedValue = testNode.Attributes;
  2038. }
  2039. catch(System.Exception ex)
  2040. {
  2041. computedValue = "Exception " + ex.Message;
  2042. }
  2043. //
  2044. // write out results.
  2045. //
  2046. results.expected = (expectedValue == null).ToString();
  2047. results.actual = (computedValue == null).ToString();
  2048. Assert.AreEqual (results.expected, results.actual);
  2049. }
  2050. //------------------------ End test case core-0048NO --------------------------
  2051. //
  2052. //------------------------- test case core-0049NO -----------------------------
  2053. //
  2054. // Testing feature - The "parentNode" attribute contains the parent of
  2055. // this node.
  2056. //
  2057. // Testing approach - Retrieve the second employee and examine its
  2058. // "parentNode" attribute. It should be set
  2059. // to "staff".
  2060. //
  2061. // Semantic Requirements: 18
  2062. //
  2063. //----------------------------------------------------------------------------
  2064. [Test]
  2065. public void core0049NO()
  2066. {
  2067. string computedValue = "";
  2068. string expectedValue = "staff";
  2069. System.Xml.XmlNode testNode = null;
  2070. System.Xml.XmlNode testNodeParent = null;
  2071. testResults results = new testResults("Core0049NO");
  2072. try
  2073. {
  2074. results.description = "The parentNode attribute contains the parent "+
  2075. "node of this node.";
  2076. //
  2077. // Retrieve the targeted data and access its parent node.
  2078. //
  2079. testNode = util.nodeObject(util.SECOND,-1);
  2080. testNodeParent = testNode.ParentNode; //.node.
  2081. //
  2082. // The nodeName attribute should be "staff".
  2083. //
  2084. computedValue = testNodeParent.Name;
  2085. }
  2086. catch(System.Exception ex)
  2087. {
  2088. computedValue = "Exception " + ex.Message;
  2089. }
  2090. //
  2091. // Write out results
  2092. //
  2093. results.expected = expectedValue;
  2094. results.actual = computedValue;
  2095. Assert.AreEqual (results.expected, results.actual);
  2096. }
  2097. //------------------------ End test case core-0049NO --------------------------
  2098. //
  2099. //------------------------- test case core-0050NO -----------------------------
  2100. //
  2101. // Testing feature - The "parentNode" attribute of a node that has just
  2102. // been created and not yet added to the tree is null.
  2103. //
  2104. // Testing approach - Create a new "employee" Element node using the
  2105. // "createElement(name)" method from the Document
  2106. // interface. Since this new node has not yet been
  2107. // added to the tree, its parentNode attribute should
  2108. // be null.
  2109. //
  2110. // Semantic Requirements: 19
  2111. //
  2112. //----------------------------------------------------------------------------
  2113. [Test]
  2114. public void core0050NO()
  2115. {
  2116. object computedValue = null;
  2117. object expectedValue = null;
  2118. System.Xml.XmlNode testNode = null;
  2119. testResults results = new testResults("Core0050NO");
  2120. results.description = "The parentNode attribute of a node that has just "+
  2121. "been created, but not yet added to the tree is "+
  2122. "null.";
  2123. //
  2124. // Create new node and access its parentNode attribute.
  2125. //
  2126. testNode = util.createNode(util.ELEMENT_NODE,"employee");
  2127. computedValue = testNode.ParentNode;
  2128. //
  2129. // Write out results.
  2130. //
  2131. results.expected = (expectedValue == null).ToString();
  2132. results.actual = (computedValue == null).ToString();
  2133. util.resetData();
  2134. Assert.AreEqual (results.expected, results.actual);
  2135. }
  2136. //------------------------ End test case core-0050NO --------------------------
  2137. //
  2138. //------------------------- test case core-0051NO -----------------------------
  2139. //
  2140. // Testing feature - The "parentNode" attribute of a node that has been
  2141. // been removed from the tree is null.
  2142. //
  2143. // Testing approach - Remove the first employee by invoking the
  2144. // "removeChild(oldChild)" method and examine its
  2145. // parentNode attribute. It should be set to null.
  2146. //
  2147. // Semantic Requirements: 20
  2148. //
  2149. //----------------------------------------------------------------------------
  2150. [Test]
  2151. public void core0051NO()
  2152. {
  2153. object computedValue = null;
  2154. object expectedValue = null;
  2155. System.Xml.XmlNode testNode = null;
  2156. System.Xml.XmlNode removedNode = null;
  2157. testResults results = new testResults("Core0051NO");
  2158. results.description = "The parentNode attribute of a node that has "+
  2159. "been removed from the tree is null.";
  2160. //
  2161. // Remove the targeted data and access its parentNode attribute.
  2162. //
  2163. testNode = util.nodeObject(util.FIRST,-1);
  2164. removedNode = util.getRootNode().RemoveChild(testNode);//.node
  2165. computedValue = removedNode.ParentNode;
  2166. //
  2167. // Write out results.
  2168. //
  2169. results.expected = (expectedValue == null).ToString();
  2170. results.actual = (computedValue == null).ToString();
  2171. util.resetData();
  2172. Assert.AreEqual (results.expected, results.actual);
  2173. }
  2174. //------------------------ End test case core-0051NO --------------------------
  2175. //
  2176. //------------------------- test case core-0052NO -----------------------------
  2177. //
  2178. // Testing feature - The "childNodes" attribute of a node contains a
  2179. // NodeList of all the children of this node.
  2180. //
  2181. // Testing approach - Retrieve the second employee and examine its
  2182. // childNodes attribute. It should be NodeList
  2183. // containing all of its children. The length of
  2184. // the list should be 9.
  2185. //
  2186. // Semantic Requirements: 21
  2187. //
  2188. //----------------------------------------------------------------------------
  2189. [Test]
  2190. public void core0052NO()
  2191. {
  2192. int computedValue = 0;
  2193. int expectedValue = 6;
  2194. System.Xml.XmlNode testNode = null;
  2195. System.Xml.XmlNodeList nodeList = null;
  2196. testResults results = new testResults("Core0052NO");
  2197. results.description = "The childNodes attribute of a node contains a "+
  2198. "NodeList of all the children of this node.";
  2199. //
  2200. // Retrieve targeted data and examine the list length.
  2201. //
  2202. testNode = util.nodeObject(util.SECOND,-1);
  2203. nodeList = testNode.ChildNodes;//.node.
  2204. computedValue = nodeList.Count;
  2205. //
  2206. // Write out results.
  2207. //
  2208. results.expected = expectedValue.ToString();
  2209. results.actual = computedValue.ToString();
  2210. Assert.AreEqual (results.expected, results.actual);
  2211. }
  2212. //------------------------ End test case core-0052NO --------------------------
  2213. //
  2214. //------------------------- test case core-0053NO -----------------------------
  2215. //
  2216. // Testing feature - If a node has no children then the NodeList returned
  2217. // by its childNodes attribute has no nodes.
  2218. //
  2219. // Testing approach - Retrieve the textual data from the first child of
  2220. // of the second employee and examine its childNodes
  2221. // attribute. It should be NodeList with no nodes
  2222. // in it.
  2223. //
  2224. // Semantic Requirements: 22
  2225. //
  2226. //----------------------------------------------------------------------------
  2227. [Test]
  2228. public void core0053NO()
  2229. {
  2230. string computedValue = "";
  2231. string expectedValue = "0";
  2232. string testName = "core-0053NO";
  2233. System.Xml.XmlNode testNode = null;
  2234. System.Xml.XmlNodeList noChildNode = null;
  2235. testResults results = new testResults("Core0053NO");
  2236. try
  2237. {
  2238. results.description = "If a node has no child nodes then the NodeList "+
  2239. "returned by its childNodes attribute has no "+
  2240. "nodes.";
  2241. //
  2242. // Retrieve the targeted data and access its childNodes attribute.
  2243. //
  2244. testNode = util.nodeObject(util.SECOND,util.FIRST);
  2245. noChildNode = testNode.FirstChild.ChildNodes;//.node.
  2246. computedValue = noChildNode.Count.ToString();
  2247. }
  2248. catch(System.Exception ex)
  2249. {
  2250. computedValue = "Exception " + ex.Message;
  2251. }
  2252. //
  2253. // Write out results.
  2254. //
  2255. results.expected = expectedValue;
  2256. results.actual = computedValue;
  2257. Assert.AreEqual (results.expected, results.actual);
  2258. }
  2259. //------------------------ End test case core-0053NO --------------------------
  2260. //
  2261. //------------------------- test case core-0054NO -----------------------------
  2262. //
  2263. // Testing feature - The NodeList returned by the childNodes attribute is live.
  2264. // Changes on the node's children are immediately reflected
  2265. // on the nodes returned by the NodeList.
  2266. //
  2267. // Testing approach - Create a NodeList of the children of the second employee
  2268. // and then add a newly created element (created with the
  2269. // "createElement" method from the Document interface) to
  2270. // the second employee by using the "append" method. The
  2271. // length attribute of the NodeList should reflect this new
  2272. // addition to the child list. It should now return the
  2273. // value 7.
  2274. //
  2275. // Semantic Requirements: 23
  2276. //
  2277. //----------------------------------------------------------------------------
  2278. [Test]
  2279. public void core0054NO()
  2280. {
  2281. int computedValue = 0;
  2282. int expectedValue = 7;
  2283. System.Xml.XmlNode testNode = null;
  2284. System.Xml.XmlNodeList nodeList = null;
  2285. testResults results = new testResults("Core0054NO");
  2286. results.description = "The NodeList returned by the childNodes attribute "+
  2287. "is live. Changes in the children node are "+
  2288. "immediately reflected in the NodeList.";
  2289. //
  2290. // Retrieve the targeted data and append a new Element node to it.
  2291. //
  2292. testNode = util.nodeObject(util.SECOND,-1);
  2293. nodeList = testNode.ChildNodes;//.node.
  2294. testNode.AppendChild(util.createNode(util.ELEMENT_NODE,"text3"));//.node.
  2295. computedValue = nodeList.Count;
  2296. //
  2297. // Write out results.
  2298. //
  2299. results.expected = expectedValue.ToString();
  2300. results.actual = computedValue.ToString();
  2301. util.resetData();
  2302. Assert.AreEqual (results.expected, results.actual);
  2303. }
  2304. //------------------------ End test case core-0054NO --------------------------
  2305. //
  2306. //------------------------- test case core-0055NO -----------------------------
  2307. //
  2308. // Testing feature - The firstChild attribute contains the first child of this
  2309. // node.
  2310. //
  2311. // Testing approach - Retrieve the second employee and examine its firstChild
  2312. // attribute. It should be set to a node whose tag name
  2313. // "employeeId".
  2314. //
  2315. // Semantic Requirements: 24
  2316. //
  2317. //----------------------------------------------------------------------------
  2318. [Test]
  2319. public void core0055NO()
  2320. {
  2321. string computedValue = "";
  2322. string expectedValue = "employeeId";
  2323. System.Xml.XmlNode testNode = null;
  2324. System.Xml.XmlNode firstChildNode = null;
  2325. testResults results = new testResults("Core0055NO");
  2326. results.description = "The firstChild attribute contains the first "+
  2327. "child of this node.";
  2328. //
  2329. // Retrieve the targeted data.
  2330. //
  2331. testNode = util.nodeObject(util.SECOND,-1);
  2332. firstChildNode = testNode.FirstChild;//.node.
  2333. //
  2334. // Its firstChild attribute's tagName should be "employeeId".
  2335. //
  2336. computedValue = firstChildNode.Name;
  2337. //
  2338. // Write out results.
  2339. //
  2340. results.expected = expectedValue;
  2341. results.actual = computedValue;
  2342. Assert.AreEqual (results.expected, results.actual);
  2343. }
  2344. //------------------------ End test case core-0055NO --------------------------
  2345. //
  2346. //------------------------- test case core-0056NO -----------------------------
  2347. //
  2348. // Testing feature - If there is no first child then the firstChild attribute
  2349. // returns null.
  2350. //
  2351. // Testing approach - Retrieve the Text node from the first child of the first
  2352. // employee and examine its firstChild attribute. It
  2353. // should be set to null.
  2354. //
  2355. // Semantic Requirements: 25
  2356. //
  2357. //----------------------------------------------------------------------------
  2358. [Test]
  2359. public void core0056NO()
  2360. {
  2361. object computedValue = null;
  2362. object expectedValue = null;
  2363. System.Xml.XmlNode testNode = null;
  2364. System.Xml.XmlNode noChildNode = null;
  2365. testResults results = new testResults("Core0056NO");
  2366. try
  2367. {
  2368. results.description = "If a node does not have a first child then its "+
  2369. "firstChild attribute returns null.";
  2370. //
  2371. // Get the targeted data.
  2372. //
  2373. testNode = util.nodeObject(util.FIRST,util.FIRST);
  2374. noChildNode = testNode.FirstChild;//.node.
  2375. //
  2376. // Its firstChild attribute should be equal to null.
  2377. //
  2378. computedValue = noChildNode.FirstChild;
  2379. }
  2380. catch(System.Exception ex)
  2381. {
  2382. computedValue = "Exception " + ex.Message;
  2383. }
  2384. //
  2385. // Write out results.
  2386. //
  2387. results.expected = (expectedValue == null).ToString();
  2388. results.actual = (computedValue == null).ToString();
  2389. Assert.AreEqual (results.expected, results.actual);
  2390. }
  2391. //------------------------ End test case core-0056NO --------------------------
  2392. //
  2393. //------------------------- test case core-0057NO -----------------------------
  2394. //
  2395. // Testing feature - The lastChild attribute contains the last child of this
  2396. // node.
  2397. //
  2398. // Testing approach - Retrieve the second employee and examine its lastChild
  2399. // attribute. It should be set to a node whose tag name
  2400. // is "address".
  2401. //
  2402. // Semantic Requirements: 26
  2403. //
  2404. //----------------------------------------------------------------------------
  2405. [Test]
  2406. public void core0057NO()
  2407. {
  2408. string computedValue = "";
  2409. string expectedValue = "address";
  2410. System.Xml.XmlNode testNode = null;
  2411. System.Xml.XmlNode lastChildNode = null;
  2412. testResults results = new testResults("Core0057NO");
  2413. results.description = "The lastChild attribute contains the last "+
  2414. "child of this node.";
  2415. //
  2416. // Retrieve the targeted data and access its lastChild attribute.
  2417. //
  2418. testNode = util.nodeObject(util.SECOND,-1);
  2419. //
  2420. // Its lastChild attribute should be equal to a node with tag name = "address".
  2421. //
  2422. lastChildNode = testNode.LastChild;//.node.
  2423. computedValue = lastChildNode.Name;
  2424. //
  2425. // Write out results.
  2426. //
  2427. results.expected = expectedValue;
  2428. results.actual = computedValue;
  2429. Assert.AreEqual (results.expected, results.actual);
  2430. }
  2431. //------------------------ End test case core-0057NO --------------------------
  2432. //
  2433. //------------------------- test case core-0058NO -----------------------------
  2434. //
  2435. // Testing feature - If there is no last child then the lastChild attribute
  2436. // returns null.
  2437. //
  2438. // Testing approach - Retrieve the Text node inside the first child of the
  2439. // second employee and examine its lastChild attribute.
  2440. // It should be set to null.
  2441. //
  2442. // Semantic Requirements: 27
  2443. //
  2444. //----------------------------------------------------------------------------
  2445. [Test]
  2446. public void core0058NO()
  2447. {
  2448. object computedValue = null;
  2449. object expectedValue = null;
  2450. System.Xml.XmlNode testNode = null;
  2451. System.Xml.XmlNode noChildNode = null;
  2452. testResults results = new testResults("Core0058NO");
  2453. try
  2454. {
  2455. results.description = "If a node does not have a last child then its "+
  2456. "lastChild attribute returns null.";
  2457. //
  2458. // Retrieve the targeted data.
  2459. //
  2460. testNode = util.nodeObject(util.SECOND,util.FIRST);
  2461. noChildNode = testNode.FirstChild;//.node.
  2462. //
  2463. // Its lastChild attribute should be equal to null.
  2464. //
  2465. computedValue = noChildNode.LastChild;
  2466. }
  2467. catch(System.Exception ex)
  2468. {
  2469. computedValue = "Exception " + ex.Message;
  2470. }
  2471. //
  2472. // Write out results.
  2473. //
  2474. results.expected = (expectedValue == null).ToString();
  2475. results.actual = (computedValue == null).ToString();
  2476. Assert.AreEqual (results.expected, results.actual);
  2477. }
  2478. //------------------------ End test case core-0058NO --------------------------
  2479. //
  2480. //------------------------- test case core-0059NO -----------------------------
  2481. //
  2482. // Testing feature - The previousSibling attribute contains the node
  2483. // immediately preceding this node.
  2484. //
  2485. // Testing approach - Retrieve the second child of the second employee and
  2486. // examine its previousSibling attribute. It should be set
  2487. // to a node whose tag name is "employeeId".
  2488. //
  2489. // Semantic Requirements: 28
  2490. //
  2491. //----------------------------------------------------------------------------
  2492. [Test]
  2493. public void core0059NO()
  2494. {
  2495. string computedValue = "";
  2496. string expectedValue = "employeeId";
  2497. System.Xml.XmlNode testNode = null;
  2498. System.Xml.XmlNode itsPreviousSibling = null;
  2499. testResults results = new testResults("Core0059NO");
  2500. try
  2501. {
  2502. results.description = "The previousSibling attribute contains the node "+
  2503. "immediately preceding this node.";
  2504. //
  2505. // Retrieve the targeted data and accesss its previousiSibling attribute.
  2506. //
  2507. testNode = util.nodeObject(util.SECOND,util.SECOND);
  2508. itsPreviousSibling = testNode.PreviousSibling;//.node.
  2509. //
  2510. // Its previousSibling attribute should have a tag name = "employeeId".
  2511. //
  2512. computedValue = itsPreviousSibling.Name;
  2513. }
  2514. catch(System.Exception ex)
  2515. {
  2516. computedValue = "Exception " + ex.Message;
  2517. }
  2518. //
  2519. // Write out results.
  2520. //
  2521. results.expected = expectedValue;
  2522. results.actual = computedValue;
  2523. Assert.AreEqual (results.expected, results.actual);
  2524. }
  2525. //------------------------ End test case core-0059NO --------------------------
  2526. //
  2527. //------------------------- test case core-0060NO -----------------------------
  2528. //
  2529. // Testing feature - If there is no immediately preceding node then the
  2530. // previousSibling attribute returns null.
  2531. //
  2532. // Testing approach - Retrieve the first child of the of the second employee
  2533. // employee and examine its previousSibling attribute.
  2534. // It should be set to null.
  2535. //
  2536. // Semantic Requirements: 29
  2537. //
  2538. //----------------------------------------------------------------------------
  2539. [Test]
  2540. public void core0060NO()
  2541. {
  2542. object computedValue = null;
  2543. object expectedValue = null;
  2544. System.Xml.XmlNode testNode = null;
  2545. testResults results = new testResults("Core0060NO");
  2546. try
  2547. {
  2548. results.description = "If there is no node immediately preceding this "+
  2549. "node then the previousSibling attribute returns "+
  2550. "null.";
  2551. //
  2552. // Retrieve the targeted data.
  2553. //
  2554. testNode = util.nodeObject(util.SECOND,util.FIRST);
  2555. //
  2556. // Its previousSibling attribute should be equal to null.
  2557. //
  2558. computedValue = testNode.PreviousSibling;//.node.
  2559. }
  2560. catch(System.Exception ex)
  2561. {
  2562. computedValue = "Exception " + ex.Message;
  2563. }
  2564. //
  2565. // Write out results.
  2566. //
  2567. results.expected = (expectedValue == null).ToString();
  2568. results.actual = (computedValue == null).ToString();
  2569. Assert.AreEqual (results.expected, results.actual);
  2570. }
  2571. //------------------------ End test case core-0060NO --------------------------
  2572. //
  2573. //------------------------- test case core-0061NO -----------------------------
  2574. //
  2575. // Testing feature - The nextSibling attribute contains the node
  2576. // immediately following this node.
  2577. //
  2578. // Testing approach - Retrieve the first child of the second employee and
  2579. // examine its nextSibling attribute. It should be set
  2580. // to a node whose tag name is "name".
  2581. //
  2582. // Semantic Requirements: 30
  2583. //
  2584. //----------------------------------------------------------------------------
  2585. [Test]
  2586. public void core0061NO()
  2587. {
  2588. string computedValue = "";
  2589. string expectedValue = "name";
  2590. System.Xml.XmlNode testNode = null;
  2591. System.Xml.XmlNode itsNextSibling = null;
  2592. testResults results = new testResults("Core0061NO");
  2593. try
  2594. {
  2595. results.description = "The nextSibling attribute contains the node "+
  2596. "immediately following this node.";
  2597. //
  2598. // Retrieve the targeted data and access its nextSibling attribute.
  2599. //
  2600. testNode = util.nodeObject(util.SECOND,util.FIRST);
  2601. itsNextSibling = testNode.NextSibling;//.node.
  2602. //
  2603. // Its nextSibling attribute should be a node with tag name = "name".
  2604. //
  2605. computedValue = itsNextSibling.Name;
  2606. }
  2607. catch(System.Exception ex)
  2608. {
  2609. computedValue = "Exception " + ex.Message;
  2610. }
  2611. //
  2612. // Write out results.
  2613. //
  2614. results.expected = expectedValue;
  2615. results.actual = computedValue;
  2616. Assert.AreEqual (results.expected, results.actual);
  2617. }
  2618. //------------------------ End test case core-0061NO --------------------------
  2619. //
  2620. //------------------------- test case core-0062NO -----------------------------
  2621. //
  2622. // Testing feature - If there is no node immediately following this node
  2623. // then the nextSibling attribute returns null.
  2624. //
  2625. // Testing approach - Retrieve the last child of the second employee
  2626. // and examine its nextSibling attribute. It should
  2627. // be set to null.
  2628. //
  2629. // Semantic Requirements: 31
  2630. //
  2631. //----------------------------------------------------------------------------
  2632. [Test]
  2633. public void core0062NO()
  2634. {
  2635. object computedValue = null;
  2636. object expectedValue = null;
  2637. System.Xml.XmlNode testNode = null;
  2638. testResults results = new testResults("Core0062NO");
  2639. try
  2640. {
  2641. results.description = "If there is no node immediately following this "+
  2642. "node then the nextSibling attribute returns null.";
  2643. //
  2644. // Retrieve the targeted data.
  2645. //
  2646. testNode = util.nodeObject(util.SECOND,util.SIXTH);
  2647. //
  2648. // Its NextSibling attribute should be equal to null.
  2649. //
  2650. computedValue = testNode.NextSibling;//.node.
  2651. }
  2652. catch(System.Exception ex)
  2653. {
  2654. computedValue = "Exception " + ex.Message;
  2655. }
  2656. //
  2657. // Write out results.
  2658. //
  2659. results.expected = (expectedValue == null).ToString();
  2660. results.actual = (computedValue == null).ToString();
  2661. Assert.AreEqual (results.expected, results.actual);
  2662. }
  2663. //------------------------ End test case core-0062NO --------------------------
  2664. //
  2665. //------------------------- test case core-0063NO -----------------------------
  2666. //
  2667. // Testing feature - The ownerDocument attribute contains the Document
  2668. // associated with this node.
  2669. //
  2670. // Testing approach - Retrieve the second employee and examine its
  2671. // ownerDocument attribute. It should contain a
  2672. // document whose documentElement attribute is equal
  2673. // to "staff".
  2674. //
  2675. // Semantic Requirements: 32
  2676. //
  2677. //----------------------------------------------------------------------------
  2678. [Test]
  2679. public void core0063NO()
  2680. {
  2681. string computedValue = "";
  2682. string expectedValue = "staff";
  2683. System.Xml.XmlNode testNode = null;
  2684. System.Xml.XmlDocument ownerDoc = null;
  2685. testResults results = new testResults("Core0063NO");
  2686. results.description = "The ownerDocument attribute contains the Document "+
  2687. "associated with this node.";
  2688. //
  2689. // Retrieve the targeted data and access its ownerDocument attribute.
  2690. //
  2691. testNode = util.nodeObject(util.SECOND,-1);
  2692. ownerDoc = testNode.OwnerDocument;//.node.
  2693. //
  2694. // the nodeName of its root node should be "staff";
  2695. //
  2696. computedValue = ownerDoc.DocumentElement.Name;
  2697. //
  2698. // Write out results.
  2699. //
  2700. results.expected = expectedValue;
  2701. results.actual = computedValue;
  2702. Assert.AreEqual (results.expected, results.actual);
  2703. }
  2704. //------------------------ End test case core-0063NO --------------------------
  2705. //
  2706. //------------------------- test case core-0064NO -----------------------------
  2707. //
  2708. // Testing feature - The ownerDocument attribute returns null if the
  2709. // target node is itself a Document.
  2710. //
  2711. // Testing approach - Retrieve the master document by invoking the
  2712. // "getDOMDocument()" method then examine the
  2713. // ownerDocument attribute of the returned object.
  2714. // It should be null.
  2715. //
  2716. // Semantic Requirements: 33
  2717. //
  2718. //----------------------------------------------------------------------------
  2719. [Test]
  2720. public void core0064NO()
  2721. {
  2722. object computedValue = null;
  2723. object expectedValue = null;
  2724. System.Xml.XmlNode testNode = null;
  2725. testResults results = new testResults("Core0064NO");
  2726. results.description = "The ownerDocument attribute returns null if the "+
  2727. "target node is itself a Document.";
  2728. //
  2729. // Retrieve the targeted data.
  2730. //
  2731. testNode = util.getDOMDocument();
  2732. //
  2733. // Its ownerDocument attribute should be null.
  2734. //
  2735. computedValue = testNode.OwnerDocument;
  2736. //
  2737. // Write out results.
  2738. //
  2739. results.expected = (expectedValue == null).ToString();
  2740. results.actual = (computedValue == null).ToString();
  2741. Assert.AreEqual (results.expected, results.actual);
  2742. }
  2743. //------------------------ End test case core-0064NO --------------------------
  2744. //
  2745. //------------------------- test case core-0065NO -----------------------------
  2746. //
  2747. // Testing feature - The insertBefore(newChild,refChild) method inserts the
  2748. // node newChild before the node refChild.
  2749. //
  2750. // Testing approach - Insert a newly created Element node before the fourth
  2751. // child of the second employee and examine the new child
  2752. // and the reference child after the insertion for correct
  2753. // placement.
  2754. //
  2755. // Semantic Requirements: 34
  2756. //
  2757. //----------------------------------------------------------------------------
  2758. [Test]
  2759. public void core0065NO()
  2760. {
  2761. string computedValue = "";
  2762. string expectedValue = "newChild salary";
  2763. System.Xml.XmlNode refChild = null;
  2764. System.Xml.XmlElement newChild = null;
  2765. System.Xml.XmlElement testNode = null;
  2766. testResults results = new testResults("Core0065NO");
  2767. try
  2768. {
  2769. results.description = "The insertBefore(newChild,refChild) method inserts "+
  2770. "the node newChild before the node refChild.";
  2771. //
  2772. // Retrieve targeted data, create a new Element node to insert, define the
  2773. // reference node, and insert the newly created element.
  2774. //
  2775. testNode = (System.Xml.XmlElement)util.nodeObject(util.SECOND,-1);
  2776. refChild = util.nodeObject(util.SECOND,util.FOURTH);
  2777. newChild = (System.Xml.XmlElement)util.createNode(util.ELEMENT_NODE,"newChild");
  2778. testNode.InsertBefore(newChild, refChild);//.node.
  2779. //
  2780. // Check that each node is in the proper position.
  2781. //
  2782. computedValue += util.getSubNodes(testNode).Item(util.FOURTH).Name+" ";
  2783. computedValue += util.getSubNodes(testNode).Item(util.FIFTH).Name;
  2784. }
  2785. catch(System.Exception ex)
  2786. {
  2787. computedValue = "Exception " + ex.Message;
  2788. }
  2789. //
  2790. // Write out results.
  2791. //
  2792. results.expected = expectedValue;
  2793. results.actual = computedValue;
  2794. util.resetData();
  2795. Assert.AreEqual (results.expected, results.actual);
  2796. }
  2797. //------------------------ End test case core-0065NO --------------------------
  2798. //
  2799. //------------------------- test case core-0066NO -----------------------------
  2800. //
  2801. // Testing feature - If the refChild is null then the
  2802. // insertBefore(newChild,refChild) method inserts the
  2803. // node newChild at the end of the list of children.
  2804. //
  2805. // Testing approach - Retrieve the second employee and invoke the the
  2806. // insertBefore(newChild,refChild) method with
  2807. // refChild = null. Under these conditions the
  2808. // newChild should be added at the end of the list.
  2809. // The last item in the list is examined after the
  2810. // insertion. The last Element node of the list
  2811. // should be "newChild".
  2812. //
  2813. // Semantic Requirements: 35
  2814. //
  2815. //----------------------------------------------------------------------------
  2816. [Test]
  2817. public void core0066NO()
  2818. {
  2819. string computedValue = "";
  2820. string expectedValue = "newChild";
  2821. System.Xml.XmlNode refChild = null;
  2822. System.Xml.XmlNode newChild = null;
  2823. System.Xml.XmlNode testNode = null;
  2824. testResults results = new testResults("Core0066NO");
  2825. results.description = "If refChild is null then the insertBefore("+
  2826. "newChild,refChild) method inserts the node "+
  2827. "newChild at the end of the list.";
  2828. //
  2829. // Retrieve targeted data, create a new Element node to insert, define
  2830. // the reference node and insert the newly created element
  2831. //
  2832. testNode = util.nodeObject(util.SECOND,-1);
  2833. newChild = util.createNode(util.ELEMENT_NODE,"newChild");
  2834. testNode.InsertBefore(newChild, refChild);//.node.
  2835. //
  2836. // Retrieve the node at the end of the list.
  2837. //
  2838. computedValue = testNode.LastChild.Name;//.node.
  2839. //
  2840. // Write out results.
  2841. //
  2842. results.expected = expectedValue;
  2843. results.actual = computedValue;
  2844. util.resetData();
  2845. Assert.AreEqual (results.expected, results.actual);
  2846. }
  2847. //------------------------ End test case core-0066NO --------------------------
  2848. //
  2849. //------------------------- test case core-0067NO -----------------------------
  2850. //
  2851. // Testing feature - If the refChild is a DocumentFragment object then all
  2852. // its children are inserted in the same order before
  2853. // the refChild.
  2854. //
  2855. // Testing approach - Create a DocumentFragment object and populate it with
  2856. // two element nodes. Retrieve the second employee
  2857. // and insert the newly created DocumentFragment before
  2858. // its fourth child. The second employee should now
  2859. // have two extra children ("childNode1" and "childNode2")
  2860. // at positions fourth and fifth respectively.
  2861. //
  2862. // Semantic Requirements: 36
  2863. //
  2864. //----------------------------------------------------------------------------
  2865. [Test]
  2866. public void core0067NO()
  2867. {
  2868. string computedValue = "";
  2869. string expectedValue = "newChild1 newChild2";
  2870. System.Xml.XmlElement testNode = null;
  2871. System.Xml.XmlNode refChild = null;
  2872. System.Xml.XmlDocumentFragment newDocFragment = util.getDOMDocument().CreateDocumentFragment();
  2873. testResults results = new testResults("Core0067NO");
  2874. try
  2875. {
  2876. results.description = "If newChild is a DocumentFragment object, then all "+
  2877. "its children are inserted in the same order before "+
  2878. "the refChild node.";
  2879. //
  2880. // Populate the DocumentFragment object.
  2881. //
  2882. newDocFragment.AppendChild(util.createNode(util.ELEMENT_NODE,"newChild1"));
  2883. newDocFragment.AppendChild(util.createNode(util.ELEMENT_NODE,"newChild2"));
  2884. //
  2885. // Retrieve targeted data, define reference node and insert new child.
  2886. //
  2887. testNode = (System.Xml.XmlElement)util.nodeObject(util.SECOND,-1);
  2888. refChild = util.nodeObject(util.SECOND,util.FOURTH);
  2889. testNode.InsertBefore(newDocFragment,refChild);//.node.
  2890. //
  2891. // Check that all the new nodes are in the proper position.
  2892. //
  2893. computedValue += util.getSubNodes(testNode).Item(util.FOURTH).Name+" ";
  2894. computedValue += util.getSubNodes(testNode).Item(util.FIFTH).Name;
  2895. }
  2896. catch(System.Exception ex)
  2897. {
  2898. computedValue = "Exception " + ex.Message;
  2899. }
  2900. //
  2901. // Write out results.
  2902. //
  2903. results.expected = expectedValue;
  2904. results.actual = computedValue;
  2905. util.resetData();
  2906. Assert.AreEqual (results.expected, results.actual);
  2907. }
  2908. //------------------------ End test case core-0067NO --------------------------
  2909. //
  2910. //------------------------- test case core-0068NO -----------------------------
  2911. //
  2912. // Testing feature - The insertBefore(newChild,refChild) method returns the
  2913. // node being inserted.
  2914. //
  2915. // Testing approach - Insert an Element node before the fourth child
  2916. // of the second employee and examine the returned
  2917. // node from the method. The node Element node
  2918. // returned by the method should be "newChild".
  2919. //
  2920. // Semantic Requirements: 37
  2921. //
  2922. //----------------------------------------------------------------------------
  2923. [Test]
  2924. public void core0068NO()
  2925. {
  2926. string computedValue = "";
  2927. string expectedValue = "newChild";
  2928. System.Xml.XmlNode testNode = null;
  2929. System.Xml.XmlNode refChild = null;
  2930. System.Xml.XmlNode newChild = null;
  2931. System.Xml.XmlNode insertedNode = null;
  2932. testResults results = new testResults("Core0068NO");
  2933. try
  2934. {
  2935. results.description = "The insertBefore(newChild,refChild) method returns "+
  2936. "the node being inserted.";
  2937. //
  2938. // Retrieve targeted data, define reference and new child nodes and insert
  2939. // new child.
  2940. //
  2941. testNode = util.nodeObject(util.SECOND,-1);
  2942. refChild = util.nodeObject(util.SECOND,util.FOURTH);
  2943. newChild = util.createNode(util.ELEMENT_NODE,"newChild");
  2944. insertedNode = testNode.InsertBefore(newChild,refChild);//.node.
  2945. //
  2946. // the returned node should have a nodeName = "newChild"
  2947. //
  2948. computedValue = insertedNode.Name;
  2949. }
  2950. catch(System.Exception ex)
  2951. {
  2952. computedValue = "Exception " + ex.Message;
  2953. }
  2954. //
  2955. // Write out results.
  2956. //
  2957. results.expected = expectedValue;
  2958. results.actual = computedValue;
  2959. util.resetData();
  2960. Assert.AreEqual (results.expected, results.actual);
  2961. }
  2962. //------------------------ End test case core-0068NO --------------------------
  2963. //
  2964. //------------------------- test case core-0069NO -----------------------------
  2965. //
  2966. // Testing feature - If the newChild is already in the tree, The
  2967. // insertBefore(newChild,refChild) method first
  2968. // remove it before the insertion takes place.
  2969. //
  2970. // Testing approach - Insert a node element (employeeId tag) that is already
  2971. // present in the tree. The existing node should be
  2972. // remove first and the new one inserted. The node is
  2973. // inserted at a different position in the tree to assure
  2974. // that it was indeed inserted.
  2975. //
  2976. // Semantic Requirements: 38
  2977. //
  2978. //----------------------------------------------------------------------------
  2979. [Test]
  2980. public void core0069NO()
  2981. {
  2982. string computedValue = "";
  2983. string expectedValue = "name employeeId";
  2984. System.Xml.XmlNode refChild = null;
  2985. System.Xml.XmlNode newChild = null;
  2986. System.Xml.XmlElement testNode = null;
  2987. testResults results = new testResults("Core0069NO");
  2988. try
  2989. {
  2990. results.description = "If newChild is already in the tree, it is first "+
  2991. "removed before the insertion (from insertBefore"+
  2992. "(newChild,refChild) method) takes place.";
  2993. //
  2994. // Retrieve targeted data, define reference and new child and insert the
  2995. // new child.
  2996. //
  2997. testNode = (System.Xml.XmlElement)util.nodeObject(util.SECOND,-1);
  2998. newChild = util.nodeObject(util.SECOND,util.FIRST);
  2999. refChild = util.nodeObject(util.SECOND,util.SIXTH);
  3000. testNode.InsertBefore(newChild,refChild);//.node.
  3001. //
  3002. // the newChild should now be the previous to the last item and the
  3003. // first child should be one that used to be at the second position.
  3004. //
  3005. computedValue += util.getSubNodes(testNode).Item(util.FIRST).Name+" ";
  3006. computedValue += util.getSubNodes(testNode).Item(util.FIFTH).Name;
  3007. }
  3008. catch(System.Exception ex)
  3009. {
  3010. computedValue = "Exception " + ex.Message;
  3011. }
  3012. //
  3013. // Write out results.
  3014. //
  3015. results.expected = expectedValue;
  3016. results.actual = computedValue;
  3017. util.resetData();
  3018. Assert.AreEqual (results.expected, results.actual);
  3019. }
  3020. //------------------------ End test case core-0069NO --------------------------
  3021. //
  3022. //------------------------- test case core-0070NO -----------------------------
  3023. //
  3024. // Testing feature - The replaceChild(newChild,oldChild) method replaces
  3025. // the node oldChild with the node newChild.
  3026. //
  3027. // Testing approach - Replace the first element of the second employee
  3028. // with a newly created node element and examine the
  3029. // first position after the replacement operation is
  3030. // done. The new element should be "newChild".
  3031. //
  3032. // Semantic Requirements: 39
  3033. //
  3034. //----------------------------------------------------------------------------
  3035. [Test]
  3036. public void core0070NO()
  3037. {
  3038. string computedValue = "";
  3039. string expectedValue = "newChild";
  3040. System.Xml.XmlElement testNode = null;
  3041. System.Xml.XmlNode refChild = null;
  3042. System.Xml.XmlNode newChild = null;
  3043. System.Xml.XmlNode oldChild = null;
  3044. testResults results = new testResults("Core0070NO");
  3045. try
  3046. {
  3047. results.description = "The replaceChild(newChild,oldChild) method "+
  3048. "replaces the node oldChild with the node newChild";
  3049. //
  3050. // Create a new Element node to replace, define the node to be
  3051. // replaced and replace it.
  3052. //
  3053. testNode = (System.Xml.XmlElement)util.nodeObject(util.SECOND,-1);
  3054. oldChild = util.nodeObject(util.SECOND,util.FIRST);
  3055. newChild = util.createNode(util.ELEMENT_NODE,"newChild");
  3056. testNode.ReplaceChild(newChild,oldChild);//.node.
  3057. //
  3058. // Check that the first position contains the new node.
  3059. //
  3060. computedValue = util.getSubNodes(testNode).Item(util.FIRST).Name;
  3061. }
  3062. catch(System.Exception ex)
  3063. {
  3064. computedValue = "Exception " + ex.Message;
  3065. }
  3066. //
  3067. // Write out results.
  3068. //
  3069. results.expected = expectedValue;
  3070. results.actual = computedValue;
  3071. util.resetData();
  3072. Assert.AreEqual (results.expected, results.actual);
  3073. }
  3074. //------------------------ End test case core-0070NO ------------------------
  3075. //
  3076. //------------------------- test case core-0071NO ---------------------------
  3077. //
  3078. // Testing feature - If the newChild is already in the tree, it is
  3079. // first removed before the new one is added
  3080. //
  3081. // Testing approach - Retrieve the second employee and replace its last child
  3082. // with its first child. After the replacement operation
  3083. // The first child should now be the one that used to be at
  3084. // the second position in the list and the last one should
  3085. // be the one that used to be at the first position.
  3086. //
  3087. // Semantic Requirements: 40
  3088. //
  3089. //----------------------------------------------------------------------------
  3090. [Test]
  3091. public void core0071NO()
  3092. {
  3093. string computedValue = "";
  3094. string expectedValue = "name employeeId";
  3095. System.Xml.XmlElement testNode = null;
  3096. System.Xml.XmlNode oldChild = null;
  3097. System.Xml.XmlNode newChild = null;
  3098. testResults results = new testResults("Core0071NO");
  3099. try
  3100. {
  3101. results.description = "If newChild is already in the tree, it is first "+
  3102. "removed before the replace(from replaceChild"+
  3103. "(newChild,oldChild) method) takes place.";
  3104. //
  3105. // Retrieve targeted data, identify new and old children and replace
  3106. // last child with the new child.
  3107. //
  3108. testNode = (System.Xml.XmlElement)util.nodeObject(util.SECOND,-1);
  3109. newChild = util.nodeObject(util.SECOND,util.FIRST);
  3110. oldChild = util.nodeObject(util.SECOND,util.SIXTH);
  3111. testNode.ReplaceChild(newChild,oldChild);//.node.
  3112. //
  3113. // The first item in the list should be the one that used to be at the
  3114. // second position and the last one should be the one that used to be at
  3115. // the first position in the list.
  3116. //
  3117. computedValue += util.getSubNodes(testNode).Item(util.FIRST).Name+" ";
  3118. computedValue += util.getSubNodes(testNode).Item(util.FIFTH).Name;
  3119. }
  3120. catch(System.Exception ex)
  3121. {
  3122. computedValue = "Exception " + ex.Message;
  3123. }
  3124. //
  3125. // Write out results.
  3126. //
  3127. results.expected = expectedValue;
  3128. results.actual = computedValue;
  3129. util.resetData();
  3130. Assert.AreEqual (results.expected, results.actual);
  3131. }
  3132. //------------------------ End test case core-0071NO --------------------------
  3133. //
  3134. //------------------------- test case core-0072NO -----------------------------
  3135. //
  3136. // Testing feature - The replaceChild(newChild,oldChild) method returns
  3137. // the node being replaced.
  3138. //
  3139. // Testing approach - Replace the first element of the second employee
  3140. // with a newly created node element and examine the
  3141. // the value returned by the replaceChild(newChild,oldChild)
  3142. // after the replacement operation is done. The returned
  3143. // node should have a nodeName equal to "employeeId".
  3144. //
  3145. // Semantic Requirements: 41
  3146. //
  3147. //----------------------------------------------------------------------------
  3148. [Test]
  3149. public void core0072NO()
  3150. {
  3151. string computedValue = "";
  3152. string expectedValue = "employeeId";
  3153. System.Xml.XmlNode testNode = null;
  3154. System.Xml.XmlNode oldChild = null;
  3155. System.Xml.XmlNode newChild = null;
  3156. System.Xml.XmlNode replacedNode = null;
  3157. testResults results = new testResults("Core0072NO");
  3158. try
  3159. {
  3160. results.description = "The replaceChild(newChild,oldChild) method returns "+
  3161. "the node being replaced.";
  3162. //
  3163. // Retrieve the targeted data, define new and old children and replace
  3164. // old child with new child.
  3165. //
  3166. testNode = util.nodeObject(util.SECOND,-1);
  3167. oldChild = util.nodeObject(util.SECOND,util.FIRST);
  3168. newChild = util.createNode(util.ELEMENT_NODE,"newChild");
  3169. replacedNode = testNode.ReplaceChild(newChild, oldChild);//.node.
  3170. //
  3171. // The returned node should be the one being replaced.
  3172. //
  3173. computedValue = replacedNode.Name;
  3174. }
  3175. catch(System.Exception ex)
  3176. {
  3177. computedValue = "Exception " + ex.Message;
  3178. }
  3179. //
  3180. // Write out results.
  3181. //
  3182. results.expected = expectedValue;
  3183. results.actual = computedValue;
  3184. util.resetData();
  3185. Assert.AreEqual (results.expected, results.actual);
  3186. }
  3187. //------------------------ End test case core-0072NO --------------------------
  3188. //
  3189. //------------------------- test case core-0073NO -----------------------------
  3190. //
  3191. // Testing feature - The removeChild(oldChild) method removes the node
  3192. // indicated by oldChild.
  3193. //
  3194. // Testing approach - Retrieve the second employee and remove its first
  3195. // child. After the removal operation takes place, the
  3196. // second employee should have 5 children and the first
  3197. // one should be the one that used to be at the second
  3198. // position in the list.
  3199. //
  3200. // Semantic Requirements: 42
  3201. //
  3202. //----------------------------------------------------------------------------
  3203. [Test]
  3204. public void core0073NO()
  3205. {
  3206. string computedValue = "";
  3207. string expectedValue = "name 5";
  3208. System.Xml.XmlElement testNode = null;
  3209. System.Xml.XmlNode oldChild = null;
  3210. testResults results = new testResults("Core0073NO");
  3211. try
  3212. {
  3213. results.description = "The removeChild(oldChild) method removes the "+
  3214. "node indicated by oldChild.";
  3215. //
  3216. // Retrieve targeted data, identify old child and remove it from the
  3217. // list of children.
  3218. //
  3219. testNode = (System.Xml.XmlElement)util.nodeObject(util.SECOND,-1);
  3220. oldChild = util.nodeObject(util.SECOND,util.FIRST);
  3221. testNode.RemoveChild(oldChild);//.node.
  3222. //
  3223. // Check that the node was indeed removed from the list.
  3224. //
  3225. computedValue += util.getSubNodes(testNode).Item(util.FIRST).Name+" ";
  3226. computedValue += util.getSubNodes(testNode).Count;
  3227. }
  3228. catch(System.Exception ex)
  3229. {
  3230. computedValue = "Exception " + ex.Message;
  3231. }
  3232. //
  3233. // Write out results.
  3234. //
  3235. results.expected = expectedValue;
  3236. results.actual = computedValue;
  3237. util.resetData();
  3238. Assert.AreEqual (results.expected, results.actual);
  3239. }
  3240. //------------------------ End test case core-0073NO --------------------------
  3241. //
  3242. //------------------------- test case core-0074NO -----------------------------
  3243. //
  3244. // Testing feature - The removeChild(oldChild) method returns the node
  3245. // removed.
  3246. //
  3247. // Testing approach - Remove the first element of the second employee
  3248. // and examine the value returned by the
  3249. // removeChild(oldChild) after removal operation is
  3250. // done. The returned node should have a tag name equal
  3251. // to "employeeId".
  3252. //
  3253. // Semantic Requirements: 43
  3254. //
  3255. //----------------------------------------------------------------------------
  3256. [Test]
  3257. public void core0074NO()
  3258. {
  3259. string computedValue = "";
  3260. string expectedValue = "employeeId";
  3261. System.Xml.XmlNode testNode = null;
  3262. System.Xml.XmlNode oldChild = null;
  3263. System.Xml.XmlNode removedNode = null;
  3264. testResults results = new testResults("Core0074NO");
  3265. try
  3266. {
  3267. results.description = "The removeChild(oldChild) method returns the "+
  3268. "node removed.";
  3269. //
  3270. // Retrieve the targeted data and remove it.
  3271. //
  3272. testNode = util.nodeObject(util.SECOND,-1);
  3273. oldChild = util.nodeObject(util.SECOND,util.FIRST);
  3274. removedNode = testNode.RemoveChild(oldChild);//.node.
  3275. //
  3276. // The returned node should be the node removed.
  3277. //
  3278. computedValue = removedNode.Name;
  3279. }
  3280. catch(System.Exception ex)
  3281. {
  3282. computedValue = "Exception " + ex.Message;
  3283. }
  3284. //
  3285. // Write out results.
  3286. //
  3287. results.expected = expectedValue;
  3288. results.actual = computedValue;
  3289. util.resetData();
  3290. Assert.AreEqual (results.expected, results.actual);
  3291. }
  3292. //------------------------ End test case core-0074NO --------------------------
  3293. //
  3294. //------------------------- test case core-0075NO -----------------------------
  3295. //
  3296. // Testing feature - The appendChild(newChild) method adds the node newChild
  3297. // the end of the list of children of the node.
  3298. //
  3299. // Testing approach - Retrieve the second employee and append a new Element
  3300. // node to its list of children. The last node in the
  3301. // list is then retrieved and its nodeName attribute
  3302. // examined. It should be equal to "newChild".
  3303. //
  3304. // Semantic Requirements: 44
  3305. //
  3306. //----------------------------------------------------------------------------
  3307. [Test]
  3308. public void core0075NO()
  3309. {
  3310. string computedValue = "";
  3311. string expectedValue = "newChild";
  3312. System.Xml.XmlElement testNode = null;
  3313. System.Xml.XmlNode newChild = null;
  3314. testResults results = new testResults("Core0075NO");
  3315. try
  3316. {
  3317. results.description = "The appendChild(newChild) method adds the node "+
  3318. "newChild to the end of the list of children of "+
  3319. "the node.";
  3320. //
  3321. // Create a new Element node and append it to the end of the list.
  3322. //
  3323. testNode = (System.Xml.XmlElement)util.nodeObject(util.SECOND,-1);
  3324. newChild = util.createNode(util.ELEMENT_NODE,"newChild");
  3325. testNode.AppendChild(newChild);//.node.
  3326. //
  3327. // Retrieve the new last child.
  3328. //
  3329. computedValue = util.getSubNodes(testNode).Item(util.SEVENTH).Name;
  3330. }
  3331. catch(System.Exception ex)
  3332. {
  3333. computedValue = "Exception " + ex.Message;
  3334. }
  3335. //
  3336. // Write out results.
  3337. //
  3338. results.expected = expectedValue;
  3339. results.actual = computedValue;
  3340. util.resetData();
  3341. Assert.AreEqual (results.expected, results.actual);
  3342. }
  3343. //------------------------ End test case core-0075NO ------------------------
  3344. //
  3345. //------------------------- test case core-0076NO ---------------------------
  3346. //
  3347. // Testing feature - If the newChild is already in the tree, it is first
  3348. // removed before the new one is appended.
  3349. //
  3350. // Testing approach - Retrieve the second employee and its first child, then
  3351. // append the first child to the end of the list. After
  3352. // the append operation is done, retrieve the element at
  3353. // at the top of the list and the one at the end of the
  3354. // list. The last node should be the one that used to be
  3355. // at the top of the list and the first one should be the
  3356. // one that used to be second in the list.
  3357. //
  3358. // Semantic Requirements: 45
  3359. //
  3360. //----------------------------------------------------------------------------
  3361. [Test]
  3362. public void core0076NO()
  3363. {
  3364. string computedValue = "";
  3365. string expectedValue = "name employeeId";
  3366. System.Xml.XmlElement testNode = null;
  3367. System.Xml.XmlNode newChild = null;
  3368. testResults results = new testResults("Core0076NO");
  3369. try
  3370. {
  3371. results.description = "If newChild is already in the tree, it is first " + "removed before the append takes place.";
  3372. //
  3373. // Retrieve targeted data, define the new child and append it to the
  3374. // end of the list.
  3375. //
  3376. testNode = (System.Xml.XmlElement)util.nodeObject(util.SECOND,-1);
  3377. newChild = util.nodeObject(util.SECOND,util.FIRST);
  3378. testNode.AppendChild(newChild);//.node.
  3379. //
  3380. // Access the relevant new nodes and its nodeName attributes.
  3381. //
  3382. computedValue += util.getSubNodes(testNode).Item(util.FIRST).Name+" ";
  3383. computedValue += util.getSubNodes(testNode).Item(util.SIXTH).Name;
  3384. }
  3385. catch(System.Exception ex)
  3386. {
  3387. computedValue = "Exception " + ex.Message;
  3388. }
  3389. //
  3390. // Write out results.
  3391. //
  3392. results.expected = expectedValue;
  3393. results.actual = computedValue;
  3394. util.resetData();
  3395. Assert.AreEqual (results.expected, results.actual);
  3396. }
  3397. //------------------------ End test case core-0076NO --------------------------
  3398. //
  3399. //------------------------- test case core-0077NO -----------------------------
  3400. //
  3401. // Testing feature - If the newChild is a DocumentFragment object then all
  3402. // its content is added to the child list of this node.
  3403. //
  3404. // Testing approach - Create and populate a new DocumentFragment object and
  3405. // append it to the second employee. After the append
  3406. // operation is done then retrieve the new nodes at the
  3407. // end of the list, they should be the two Element nodes
  3408. // from the DocumentFragment.
  3409. //
  3410. // Semantic Requirements: 46
  3411. //
  3412. //----------------------------------------------------------------------------
  3413. [Test]
  3414. public void core0077NO()
  3415. {
  3416. string computedValue = "";
  3417. string expectedValue = "newChild1 newChild2";
  3418. System.Xml.XmlElement testNode = null;
  3419. System.Xml.XmlDocumentFragment newDocFragment = util.getDOMDocument().CreateDocumentFragment();
  3420. testResults results = new testResults("Core0077NO");
  3421. try
  3422. {
  3423. results.description = "If newChild is a DocumentFragment object, then the "+
  3424. "entire content of the DocumentFragment is appended "+
  3425. "to the child list of this node.";
  3426. //
  3427. // Populate the DocumentFragment object.
  3428. //
  3429. newDocFragment.AppendChild(util.createNode(util.ELEMENT_NODE,"newChild1"));
  3430. newDocFragment.AppendChild(util.createNode(util.ELEMENT_NODE,"newChild2"));
  3431. //
  3432. // Retrieve targeted data and append new DocumentFragment object.
  3433. //
  3434. testNode = (System.Xml.XmlElement)util.nodeObject(util.SECOND,-1);
  3435. testNode.AppendChild(newDocFragment);//.node.
  3436. //
  3437. // Retrieve all the new nodes from the proper position.
  3438. //
  3439. computedValue += util.getSubNodes(testNode).Item(util.SEVENTH).Name+" ";
  3440. computedValue += util.getSubNodes(testNode).Item(util.EIGHT).Name;
  3441. }
  3442. catch(System.Exception ex)
  3443. {
  3444. computedValue = "Exception " + ex.Message;
  3445. }
  3446. //
  3447. // Write out results.
  3448. //
  3449. results.expected = expectedValue;
  3450. results.actual = computedValue;
  3451. util.resetData();
  3452. Assert.AreEqual (results.expected, results.actual);
  3453. }
  3454. //------------------------ End test case core-0077NO --------------------------
  3455. //
  3456. //------------------------- test case core-0078NO -----------------------------
  3457. //
  3458. // Testing feature - The appendChild(newChild) method returns the node
  3459. // added.
  3460. //
  3461. // Testing approach - Append a newly created node to the child list of the
  3462. // second employee and examine the returned value
  3463. // The returned value should be "newChild".
  3464. //
  3465. // Semantic Requirements: 47
  3466. //
  3467. //----------------------------------------------------------------------------
  3468. [Test]
  3469. public void core0078NO()
  3470. {
  3471. string computedValue = "";
  3472. string expectedValue = "newChild";
  3473. System.Xml.XmlNode testNode = null;
  3474. System.Xml.XmlNode appendedNode = null;
  3475. System.Xml.XmlNode newChild = null;
  3476. testResults results = new testResults("Core0078NO");
  3477. results.description = "The appendChild(newChild) method returns the node "+
  3478. "added.";
  3479. //
  3480. // Retrieve the targeted data and append a new node to it.
  3481. //
  3482. testNode = util.nodeObject(util.SECOND,-1);
  3483. newChild = util.createNode(util.ELEMENT_NODE,"newChild");
  3484. appendedNode = testNode.AppendChild(newChild);//.node.
  3485. //
  3486. // The returned node should be the node appended.
  3487. //
  3488. computedValue = appendedNode.Name;
  3489. //
  3490. // Write out results.
  3491. //
  3492. results.expected = expectedValue;
  3493. results.actual = computedValue;
  3494. util.resetData();
  3495. Assert.AreEqual (results.expected, results.actual);
  3496. }
  3497. //------------------------ End test case core-0078NO --------------------------
  3498. //
  3499. //------------------------- test case core-0079NO -----------------------------
  3500. //
  3501. // Testing feature - The hasChildNodes method returns true if the node has
  3502. // any children.
  3503. //
  3504. // Testing approach - Retrieve the root node (tag name = "staff") and
  3505. // invoke its hasChildNodes.Item() method. It should return
  3506. // the value true.
  3507. //
  3508. // Semantic Requirements: 48
  3509. //
  3510. //----------------------------------------------------------------------------
  3511. [Test]
  3512. public void core0079NO()
  3513. {
  3514. string computedValue = "";
  3515. string expectedValue = "True";
  3516. System.Xml.XmlNode testNode = null;
  3517. testResults results = new testResults("Core0079NO");
  3518. results.description = "The hasChildNodes method returns true if the "+
  3519. "node has any children.";
  3520. //
  3521. // Retrieve the targeted data and access its hasChilNodes method.
  3522. //
  3523. testNode = util.nodeObject(util.SECOND,-1);
  3524. computedValue = testNode.HasChildNodes.ToString();//.Item();//.node.
  3525. //
  3526. // Write out results.
  3527. //
  3528. results.expected = expectedValue;
  3529. results.actual = computedValue;
  3530. Assert.AreEqual (results.expected, results.actual);
  3531. }
  3532. //------------------------ End test case core-0079NO --------------------------
  3533. //
  3534. //------------------------- test case core-0080NO -----------------------------
  3535. //
  3536. // Testing feature - The hasChildNodes method returns false if the node has
  3537. // no children.
  3538. //
  3539. // Testing approach - Retrieve the Text node inside the first child of the
  3540. // second employee and invoke its hasChildNodes.Item() method.
  3541. // It should return the value false as this node has no
  3542. // children.
  3543. //
  3544. // Semantic Requirements: 49
  3545. //
  3546. //----------------------------------------------------------------------------
  3547. [Test]
  3548. public void core0080NO()
  3549. {
  3550. string computedValue = "";
  3551. string expectedValue = "False";
  3552. System.Xml.XmlNode testNode = null;
  3553. testResults results = new testResults("Core0080NO");
  3554. try
  3555. {
  3556. results.description = "The hasChildNodes method returns false if the "+
  3557. "node has no children.";
  3558. //
  3559. // Retrieve the targeted data and access its hasChildNodes method.
  3560. //
  3561. testNode = util.nodeObject(util.SECOND,util.FIRST);
  3562. System.Xml.XmlNode textNode = testNode.FirstChild;//.node.
  3563. computedValue = textNode.HasChildNodes.ToString();//.Item();
  3564. }
  3565. catch(System.Exception ex)
  3566. {
  3567. computedValue = "Exception " + ex.Message;
  3568. }
  3569. //
  3570. // Write out results.
  3571. //
  3572. results.expected = expectedValue;
  3573. results.actual = computedValue;
  3574. Assert.AreEqual (results.expected, results.actual);
  3575. }
  3576. //------------------------ End test case core-0080NO --------------------------
  3577. //
  3578. //------------------------- test case core-0081NO -----------------------------
  3579. //
  3580. // Testing feature - The cloneNode(deep) method returns a copy of the node only
  3581. // if deep = false.
  3582. //
  3583. // Testing approach - Retrieve the second employee and invoke its
  3584. // cloneNode(deep) method with deep = false. The
  3585. // method should clone this node only. The nodeName,
  3586. // and length of the childNode list are checked,
  3587. // they should be "employee" and 0.
  3588. //
  3589. // Semantic Requirements: 50
  3590. //
  3591. //----------------------------------------------------------------------------
  3592. [Test]
  3593. public void core0081NO()
  3594. {
  3595. string computedValue = "";
  3596. string expectedValue = "employee 0";
  3597. System.Xml.XmlNode testNode = null;
  3598. System.Xml.XmlNode clonedNode = null;
  3599. testResults results = new testResults("Core0081NO");
  3600. try
  3601. {
  3602. results.description = "The cloneNode(deep) method returns a copy of this "+
  3603. "node only if deep = false.";
  3604. //
  3605. // Retrieve the targeted data and access its cloneNode method.
  3606. //
  3607. testNode = util.nodeObject(util.SECOND,-1);
  3608. clonedNode = testNode.CloneNode(false);//.node.
  3609. //
  3610. // Retrieve values of the cloned node.
  3611. //
  3612. computedValue += clonedNode.Name+" ";
  3613. computedValue += clonedNode.ChildNodes.Count;
  3614. }
  3615. catch(System.Exception ex)
  3616. {
  3617. computedValue = "Exception " + ex.Message;
  3618. }
  3619. //
  3620. // Write out results.
  3621. //
  3622. results.expected = expectedValue;
  3623. results.actual = computedValue;
  3624. Assert.AreEqual (results.expected, results.actual);
  3625. }
  3626. //------------------------ End test case core-0081NO --------------------------
  3627. //
  3628. //------------------------- test case core-0082NO -----------------------------
  3629. //
  3630. // Testing feature - The cloneNode(deep) method returns a copy of the node and
  3631. // the subtree under it if deep = true.
  3632. //
  3633. // Testing approach - Retrieve the second employee and invoke its
  3634. // cloneNode(deep) method with deep = true. The
  3635. // method should clone this node and the subtree under
  3636. // it. The tag name of each child of the returned
  3637. // node is checked to insure the entire subtree under
  3638. // the second employee was cloned.
  3639. //
  3640. // Semantic Requirements: 51
  3641. //
  3642. //----------------------------------------------------------------------------
  3643. [Test]
  3644. public void core0082NO()
  3645. {
  3646. string computedValue = "";
  3647. string expectedValue = "employeeId name position salary gender address ";
  3648. System.Xml.XmlNode testNode = null;
  3649. System.Xml.XmlNodeList subTree = null;
  3650. System.Xml.XmlNode clonedNode = null;
  3651. testResults results = new testResults("Core0082NO");
  3652. try
  3653. {
  3654. results.description = "The cloneNode(deep) method returns a copy of this "+
  3655. "node and the subtree under it if deep = true.";
  3656. //
  3657. // Retrieve the targeted data and invoke its cloneNode method.
  3658. //
  3659. testNode = util.nodeObject(util.SECOND,-1);
  3660. clonedNode = testNode.CloneNode(true);//.node.
  3661. subTree = clonedNode.ChildNodes;
  3662. //
  3663. // Retrieve the cloned node children.
  3664. //
  3665. for (int index = 0;index < subTree.Count; index++)
  3666. computedValue += subTree.Item(index).Name+" ";
  3667. }
  3668. catch(System.Exception ex)
  3669. {
  3670. computedValue = "Exception " + ex.Message;
  3671. }
  3672. //
  3673. // Write out results.
  3674. //
  3675. results.expected = expectedValue;
  3676. results.actual = computedValue;
  3677. Assert.AreEqual (results.expected, results.actual);
  3678. }
  3679. //------------------------ End test case core-0082NO --------------------------
  3680. //
  3681. //------------------------- test case core-0083NO -----------------------------
  3682. //
  3683. // Testing feature - The duplicate node returned by the cloneNode(deep) method
  3684. // has no parent (parentNode = null).
  3685. //
  3686. // Testing approach - Retrieve the second employee and invoke its
  3687. // cloneNode(deep) method with deep = false. The
  3688. // duplicate node returned by the method should have its
  3689. // parentNode attribute set to null.
  3690. //
  3691. // Semantic Requirements: 52
  3692. //
  3693. //----------------------------------------------------------------------------
  3694. [Test]
  3695. public void core0083NO()
  3696. {
  3697. object computedValue = null;
  3698. object expectedValue = null;
  3699. System.Xml.XmlNode testNode = null;
  3700. System.Xml.XmlNode clonedNode = null;
  3701. testResults results = new testResults("Core0083NO");
  3702. try
  3703. {
  3704. results.description = "The duplicate node returned by the cloneNode(deep) "+
  3705. "method has no parent (parentNode = null).";
  3706. //
  3707. // Retrieve the targeted data and invoke the cloneNode method.
  3708. //
  3709. testNode = util.nodeObject(util.SECOND,-1);
  3710. clonedNode = testNode.CloneNode(false);//.node.
  3711. //
  3712. // Its parentNode attribute should be null.
  3713. //
  3714. computedValue = clonedNode.ParentNode;
  3715. }
  3716. catch(System.Exception ex)
  3717. {
  3718. computedValue = "Exception " + ex.Message;
  3719. }
  3720. //
  3721. // Write out results.
  3722. //
  3723. results.expected = (expectedValue == null).ToString();
  3724. results.actual = (computedValue == null).ToString();
  3725. util.resetData();
  3726. Assert.AreEqual (results.expected, results.actual);
  3727. }
  3728. //------------------------ End test case core-0083NO --------------------------
  3729. //
  3730. //------------------------- test case core-0084NO -----------------------------
  3731. //
  3732. // Testing feature - The cloneNode(deep) method does not copy text unless it is
  3733. // deep cloned. (test for deep clone = false)
  3734. //
  3735. // Testing approach - Retrieve the fourth child of the second employee and
  3736. // invoke its cloneNode(deep) method with deep = false. The
  3737. // duplicate node returned by the method should not copy any
  3738. // text data contained in this node.
  3739. //
  3740. // Semantic Requirements: 53
  3741. //
  3742. //----------------------------------------------------------------------------
  3743. [Test]
  3744. public void core0084NO()
  3745. {
  3746. string testName = "core-0084NO";
  3747. object computedValue = null;
  3748. object expectedValue = null;
  3749. System.Xml.XmlNode testNode = null;
  3750. System.Xml.XmlNode clonedNode = null;
  3751. testResults results = new testResults("Core0084NO");
  3752. try
  3753. {
  3754. results.description = "The cloneNode(deep) method does not copy any text "+
  3755. "unless it is deep cloned(deep = false).";
  3756. //
  3757. // Retrieve the targeted data and invoke its clonedNode method.
  3758. //
  3759. testNode = util.nodeObject(util.SECOND,util.FOURTH);
  3760. clonedNode = testNode.CloneNode(false);//.node.
  3761. //
  3762. // The cloned node should have no text data in it.
  3763. //
  3764. computedValue = clonedNode.LastChild;
  3765. }
  3766. catch(System.Exception ex)
  3767. {
  3768. computedValue = "Exception " + ex.Message;
  3769. }
  3770. //
  3771. // Write out results.
  3772. //
  3773. results.expected = (expectedValue == null).ToString();
  3774. results.actual = (computedValue == null).ToString();
  3775. Assert.AreEqual (results.expected, results.actual);
  3776. }
  3777. //------------------------ End test case core-0084NO --------------------------
  3778. //
  3779. //------------------------- test case core-0085NO -----------------------------
  3780. //
  3781. // Testing feature - The cloneNode(deep) method does not copy text unless it is
  3782. // deep cloned. (test for deep clone = true)
  3783. //
  3784. // Testing approach - Retrieve the fourth child of the second employee and
  3785. // invoke its cloneNode(deep) method with deep = true. The
  3786. // duplicate node returned by the method should copy any
  3787. // text data contained in this node.
  3788. //
  3789. // Semantic Requirements: 53
  3790. //
  3791. //----------------------------------------------------------------------------
  3792. [Test]
  3793. public void core0085NO()
  3794. {
  3795. string computedValue = "";
  3796. string expectedValue = "35,000";
  3797. System.Xml.XmlNode testNode = null;
  3798. System.Xml.XmlNode clonedNode = null;
  3799. testResults results = new testResults("Core0085NO");
  3800. try
  3801. {
  3802. results.description = "The cloneNode(deep) method does not copy any text "+
  3803. "unless it is deep cloned(deep = true).";
  3804. //
  3805. // Retrieve the targeted data and invoke its cloneNode method.
  3806. //
  3807. testNode = util.nodeObject(util.SECOND,util.FOURTH);
  3808. clonedNode = testNode.CloneNode(true);//.node.
  3809. //
  3810. // Retrieve the text data inside the cloned node.
  3811. //
  3812. computedValue = clonedNode.LastChild.Value;
  3813. }
  3814. catch(System.Exception ex)
  3815. {
  3816. computedValue = "Exception " + ex.Message;
  3817. }
  3818. //
  3819. // Write out results.
  3820. //
  3821. results.expected = expectedValue;
  3822. results.actual = computedValue;
  3823. Assert.AreEqual (results.expected, results.actual);
  3824. }
  3825. //------------------------ End test case core-0085NO --------------------------
  3826. //
  3827. //------------------------- test case core-0086NO -----------------------------
  3828. //
  3829. // Testing feature - If the cloneNode(deep) method was used to clone an Element
  3830. // node, all the attributes of the Element are copied (and
  3831. // their values).
  3832. //
  3833. // Testing approach - Retrieve the last child of the second employee and
  3834. // invoke its cloneNode(deep) method with deep = true. The
  3835. // duplicate node returned by the method should copy the
  3836. // attributes associated with this node.
  3837. //
  3838. // Semantic Requirements: 54
  3839. //
  3840. //----------------------------------------------------------------------------
  3841. [Test]
  3842. public void core0086NO()
  3843. {
  3844. string testName = "core-0086NO";
  3845. string computedValue = "";
  3846. string expectedValue = "";
  3847. System.Xml.XmlNode testNode = null;
  3848. System.Xml.XmlNode clonedNode = null;
  3849. testResults results = new testResults("Core0086NO");
  3850. try
  3851. {
  3852. results.description = "If the cloneNode(deep) method was used to clone an "+
  3853. "Element node then all the attributes associated "+
  3854. "associated with this node are copied too.";
  3855. //
  3856. // Retrieve the targeted data and invoke its cloneNode method.
  3857. //
  3858. testNode = util.nodeObject(util.SECOND,util.SIXTH);
  3859. clonedNode = testNode.CloneNode(true);//.node.
  3860. //
  3861. // Retreive cloned node and its attributes.
  3862. //
  3863. computedValue += clonedNode.Attributes.Item(0).Name+" ";
  3864. computedValue += clonedNode.Attributes.Item(1).Name;
  3865. //
  3866. // Determine order of NamedNodeMap items.
  3867. //
  3868. if (computedValue.Substring(0,1) == "d" && computedValue.Substring(1,1) == "o")
  3869. expectedValue = "domestic street";
  3870. else
  3871. expectedValue = "street domestic";
  3872. }
  3873. catch(Exception ex)
  3874. {
  3875. computedValue = "Exception " + ex.Message;
  3876. }
  3877. //
  3878. // Write out results.
  3879. //
  3880. results.expected = expectedValue;
  3881. results.actual = computedValue;
  3882. Assert.AreEqual (results.expected, results.actual);
  3883. }
  3884. //------------------------ End test case core-0086NO --------------------------
  3885. //
  3886. //------------------------- test case core-0087NO -----------------------------
  3887. //
  3888. // Testing feature - The "nodeValue" attribute of a node raises a
  3889. // NO_MODIFICATION_ALLOWED_ERR DOM exception
  3890. // if the node is readonly.
  3891. //
  3892. // Testing approach - Retrieve the Text node inside the Entity node named
  3893. // "ent1" and attempt to change its nodeValue attribute.
  3894. // Since the descendants of Entity nodes are readonly, the
  3895. // desired exception should be raised.
  3896. //
  3897. // Semantic Requirements: 55
  3898. //
  3899. //----------------------------------------------------------------------------
  3900. [Test]
  3901. public void core0087NO()
  3902. {
  3903. string computedValue = "";
  3904. System.Xml.XmlEntity testNode = null;
  3905. System.Xml.XmlText entityDesc = null;
  3906. string expectedValue = "System.ArgumentException";//util.NO_MODIFICATION_ALLOWED_ERR;
  3907. testResults results = new testResults("Core0087NO");
  3908. try
  3909. {
  3910. results.description = "The \"Value\" attribute of a node raises a "+
  3911. "NO_MODIFICATION_ALLOWED_ERR Exception if the "+
  3912. "node is readonly.";
  3913. //
  3914. // Retrieve the targeted data.
  3915. //
  3916. testNode = util.getEntity("ent1");
  3917. entityDesc = (System.Xml.XmlText)testNode.FirstChild;
  3918. //
  3919. // attempt to set a value on a readonly node should raise an exception.
  3920. //
  3921. try
  3922. {
  3923. entityDesc.Value = "ABCD";
  3924. }
  3925. catch(System.Exception ex)
  3926. {
  3927. computedValue = ex.GetType ().FullName;
  3928. }
  3929. }
  3930. catch(System.Exception ex)
  3931. {
  3932. computedValue = "Exception " + ex.Message;
  3933. }
  3934. results.expected = expectedValue;
  3935. results.actual = computedValue;
  3936. util.resetData();
  3937. Assert.AreEqual (results.expected, results.actual);
  3938. }
  3939. //------------------------ End test case core-0087NO -------------------------
  3940. //
  3941. //------------------------- test case core-0088NO -----------------------------
  3942. //
  3943. // Testing feature - The "insertBefore" method of a node raises a
  3944. // NO_MODIFICATION_ALLOWED_ERR Exception if
  3945. // the node is readonly.
  3946. //
  3947. // Testing approach - Retrieve the first EntityReference inside the second
  3948. // employee and invoke the insertBefore(newChild,refChild)
  3949. // method on its first descendant. Descendants of
  3950. // EntityReference nodes are readonly and therefore the
  3951. // desired exception should be raised. This test also
  3952. // makes use of the "createElement" method from the
  3953. // Document interface.
  3954. //
  3955. // Semantic Requirements: 56
  3956. //
  3957. //----------------------------------------------------------------------------
  3958. [Test]
  3959. public void core0088NO()
  3960. {
  3961. string computedValue = "";
  3962. System.Xml.XmlNode testNode = null;
  3963. System.Xml.XmlEntityReference entityRefNode = null;
  3964. System.Xml.XmlNode refChild = null;
  3965. System.Xml.XmlElement newChild = (System.Xml.XmlElement)util.createNode(util.ELEMENT_NODE,"newChild");
  3966. string expectedValue = "System.InvalidOperationException";//util.NO_MODIFICATION_ALLOWED_ERR;
  3967. testResults results = new testResults("Core0088NO");
  3968. try
  3969. {
  3970. results.description = "The \"insertBefore()\" method of a node raises "+
  3971. "a NO_MODIFICATION_ALLOWED_ERR Exception "+
  3972. "if this node is readonly.";
  3973. //
  3974. // Retrieve targeted data and define reference child.
  3975. //
  3976. testNode = util.nodeObject(util.SECOND,util.SIXTH);
  3977. entityRefNode = (System.Xml.XmlEntityReference)testNode.FirstChild;//.node.
  3978. refChild = entityRefNode.FirstChild;
  3979. //
  3980. // Attempt to insert a node to an EntityReference descendant should raise
  3981. // an exception.
  3982. //
  3983. try
  3984. {
  3985. entityRefNode.InsertBefore(newChild,refChild);
  3986. }
  3987. catch(InvalidOperationException ex)
  3988. {
  3989. computedValue = ex.GetType ().FullName;
  3990. }
  3991. }
  3992. catch(System.Exception ex)
  3993. {
  3994. computedValue = "Exception " + ex.Message;
  3995. }
  3996. results.expected = expectedValue;
  3997. results.actual = computedValue;
  3998. util.resetData();
  3999. Assert.AreEqual (results.expected, results.actual);
  4000. }
  4001. //------------------------ End test case core-0088NO -------------------------
  4002. //
  4003. //------------------------- test case core-0089NO ----------------------------
  4004. //
  4005. // Testing feature - The "replaceChild" method of a node raises a
  4006. // NO_MODIFICATION_ALLOWED_ERR Exception if the
  4007. // node is readonly.
  4008. //
  4009. // Testing approach - Retrieve the first EntityReference inside the second
  4010. // employee and invoke the replaceChild(newChild,oldChild)
  4011. // method where oldChild is one of the EntityReference
  4012. // descendants. Descendants of EntityReference nodes are
  4013. // readonly and therefore the desired exception should be
  4014. // raised. This test also makes use of the "createElement"
  4015. // method from the Document interface.
  4016. //
  4017. // Semantic Requirements: 57
  4018. //
  4019. //----------------------------------------------------------------------------
  4020. [Test]
  4021. public void core0089NO()
  4022. {
  4023. string computedValue = "";
  4024. System.Xml.XmlNode testNode = null;
  4025. System.Xml.XmlEntityReference entityRefNode = null;
  4026. System.Xml.XmlNode oldChild = null;
  4027. System.Xml.XmlElement newChild = (System.Xml.XmlElement)util.createNode(util.ELEMENT_NODE,"newChild");
  4028. string expectedValue = "System.ArgumentException";//util.NO_MODIFICATION_ALLOWED_ERR;
  4029. testResults results = new testResults("Core0089NO");
  4030. try
  4031. {
  4032. results.description = "The \"replaceChild(newChild, oldChild)\" method "+
  4033. "of a node raises a<br>NO_MODIFICATION_ALLOWED_ERR "+
  4034. " Exception if this node is readonly.";
  4035. //
  4036. // Retrieve targeted data and define oldChild.
  4037. //
  4038. testNode = util.nodeObject(util.SECOND,util.SIXTH);
  4039. entityRefNode = (System.Xml.XmlEntityReference)testNode.FirstChild; //.node.
  4040. oldChild = entityRefNode.FirstChild;
  4041. //
  4042. // Attempt to replace a descendant of an EntityReference should raise an
  4043. // exception.
  4044. //
  4045. try
  4046. {
  4047. entityRefNode.ReplaceChild(newChild,oldChild);
  4048. }
  4049. catch(ArgumentException ex)
  4050. {
  4051. computedValue = ex.GetType ().FullName;
  4052. }
  4053. }
  4054. catch(System.Exception ex)
  4055. {
  4056. computedValue = "Exception " + ex.Message;
  4057. }
  4058. results.expected = expectedValue;
  4059. results.actual = computedValue;
  4060. util.resetData();
  4061. Assert.AreEqual (results.expected, results.actual);
  4062. }
  4063. //------------------------ End test case core-0089NO -------------------------
  4064. //
  4065. //------------------------- test case core-0090NO ----------------------------
  4066. //
  4067. // Testing feature - The "removeChild" method of a node raises a
  4068. // NO_MODIFICATION_ALLOWED_ERR Exception if the
  4069. // node is readonly.
  4070. //
  4071. // Testing approach - Retrieve the first EntityReference inside the second
  4072. // employee and invoke its removeChild(oldChild) method
  4073. // where oldChild is one of the EntityReference descendants.
  4074. // Descendants of EntityReference nodes are readonly and
  4075. // therefore the desired exception should be raised.
  4076. //
  4077. // Semantic Requirements: 58
  4078. //
  4079. //----------------------------------------------------------------------------
  4080. [Test]
  4081. public void core0090NO()
  4082. {
  4083. string computedValue = "";
  4084. System.Xml.XmlEntityReference entityRefNode = null;
  4085. System.Xml.XmlNode testNode = null;
  4086. System.Xml.XmlNode oldChild = null;
  4087. string expectedValue = "System.ArgumentException";//util.NO_MODIFICATION_ALLOWED_ERR;
  4088. testResults results = new testResults("Core0090NO");
  4089. try
  4090. {
  4091. results.description = "The \"removeChild(oldChild)\" method of a node "+
  4092. "raises NO_MODIFICATION_ALLOWED_ERR Exception "+
  4093. "if this node is readonly.";
  4094. //
  4095. // Retreive targeted data and define oldChild.
  4096. //
  4097. testNode = util.nodeObject(util.SECOND,util.SIXTH);
  4098. entityRefNode = (System.Xml.XmlEntityReference)testNode.FirstChild;//.node.
  4099. oldChild = entityRefNode.FirstChild;
  4100. //
  4101. // Attempt to remove a descendant of an EntityReference node should
  4102. // raise an exception.
  4103. //
  4104. try
  4105. {
  4106. entityRefNode.RemoveChild(oldChild);
  4107. }
  4108. catch(ArgumentException ex)
  4109. {
  4110. computedValue = ex.GetType ().FullName;
  4111. }
  4112. }
  4113. catch(System.Exception ex)
  4114. {
  4115. computedValue = "Exception " + ex.Message;
  4116. }
  4117. results.expected = expectedValue;
  4118. results.actual = computedValue;
  4119. util.resetData();
  4120. Assert.AreEqual (results.expected, results.actual);
  4121. }
  4122. //------------------------ End test case core-0090NO -------------------------
  4123. //
  4124. //------------------------- test case core-0091NO ----------------------------
  4125. //
  4126. // Testing feature - The "appendChild" method of a node raises a
  4127. // NO_MODIFICATION_ALLOWED_ERR Exception if
  4128. // the node is readonly.
  4129. //
  4130. // Testing approach - Retrieve the first EntityReference inside the second
  4131. // employee and invoke its append(newChild) method.
  4132. // Descendants of EntityReference nodes are readonly and
  4133. // therefore attempts to append nodes to such podes
  4134. // should raise the desired exception. This test
  4135. // also makes use of the "createElement" method from
  4136. // the Document interface.
  4137. //
  4138. // Semantic Requirements: 59
  4139. //
  4140. //----------------------------------------------------------------------------
  4141. [Test]
  4142. public void core0091NO()
  4143. {
  4144. string computedValue = "";
  4145. System.Xml.XmlEntityReference entityRefNode = null;
  4146. System.Xml.XmlNode testNode = null;
  4147. System.Xml.XmlElement newChild = (System.Xml.XmlElement)util.createNode(util.ELEMENT_NODE,"newChild");
  4148. string expectedValue = "System.InvalidOperationException";//util.NO_MODIFICATION_ALLOWED_ERR;
  4149. testResults results = new testResults("Core0091NO");
  4150. try
  4151. {
  4152. results.description = "The \"appendChild(newChild)\" method of a node "+
  4153. "raises NO_MODIFICATION_ALLOWED_ERR Exception "+
  4154. "if this node is readonly.";
  4155. //
  4156. // Retrieve targeted data.
  4157. //
  4158. testNode = util.nodeObject(util.SECOND,util.SIXTH);
  4159. entityRefNode = (System.Xml.XmlEntityReference)testNode.FirstChild;//.node.
  4160. //
  4161. // Attempt to append nodes to descendants of EntityReference nodes should
  4162. // raise an exception.
  4163. //
  4164. try
  4165. {
  4166. entityRefNode.AppendChild(newChild);
  4167. }
  4168. catch(InvalidOperationException ex)
  4169. {
  4170. computedValue = ex.GetType ().FullName;
  4171. }
  4172. }
  4173. catch(System.Exception ex)
  4174. {
  4175. computedValue = "Exception " + ex.Message;
  4176. }
  4177. results.expected = expectedValue;
  4178. results.actual = computedValue;
  4179. util.resetData();
  4180. Assert.AreEqual (results.expected, results.actual);
  4181. }
  4182. //------------------------ End test case core-0091NO -------------------------
  4183. //
  4184. //------------------------- test case core-0092NO -----------------------------
  4185. //
  4186. // Testing feature - The "insertBefore()" method of a node raises
  4187. // a System.ArgumentException Exception if this node
  4188. // is of a type that does not allow children of the
  4189. // type of "newChild" to be inserted.
  4190. //
  4191. // Testing Approach - Retrieve the root node and attempt to insert a newly
  4192. // created Attr node. An Element node can not have
  4193. // children of the "Attr" type, therefore the desired
  4194. // exception should be raised.
  4195. //
  4196. // Semantic Requirements: 60
  4197. //
  4198. //----------------------------------------------------------------------------
  4199. [Test]
  4200. public void core0092NO()
  4201. {
  4202. string computedValue = "";
  4203. System.Xml.XmlElement rootNode = null;
  4204. System.Xml.XmlAttribute newChild = (System.Xml.XmlAttribute)util.createNode(util.ATTRIBUTE_NODE,"newAttribute");
  4205. System.Xml.XmlNode refChild = null;
  4206. string expectedValue = "System.InvalidOperationException";
  4207. testResults results = new testResults("Core0092NO");
  4208. try
  4209. {
  4210. results.description = "The \"insertBefore()\" method of a node raises "+
  4211. "a System.ArgumentException Exception if this node "+
  4212. "does not allow nodes of type of \"newChild\" to be "+
  4213. "inserted.";
  4214. //
  4215. // Retrieve targeted data.
  4216. //
  4217. rootNode = util.getRootNode();
  4218. refChild = util.nodeObject(util.SECOND,-1);
  4219. //
  4220. // Attempt to insert an invalid child should raise an exception.
  4221. //
  4222. try
  4223. {
  4224. rootNode.InsertBefore(newChild,refChild);//.node
  4225. }
  4226. catch(System.Exception ex)
  4227. {
  4228. computedValue = ex.GetType().ToString();
  4229. }
  4230. }
  4231. catch(System.Exception ex)
  4232. {
  4233. computedValue = "Exception " + ex.Message;
  4234. }
  4235. results.expected = expectedValue;
  4236. results.actual = computedValue;
  4237. util.resetData();
  4238. Assert.AreEqual (results.expected, results.actual);
  4239. }
  4240. //------------------------ End test case core-0092NO -------------------------
  4241. //
  4242. //------------------------- test case core-0093NO ----------------------------
  4243. //
  4244. // Testing feature - The "insertBefore()" method of a node raises
  4245. // a System.ArgumentException Exception if the node
  4246. // to be inserted is one of this node's ancestors.
  4247. //
  4248. // Testing Approach - Retrieve the second employee and attempt to insert
  4249. // a node that is one of its ancestors (root node).
  4250. // An attempt to insert such a node should raise the
  4251. // desired exception.
  4252. //
  4253. // Semantic Requirements: 61
  4254. //
  4255. //----------------------------------------------------------------------------
  4256. [Test]
  4257. public void core0093NO()
  4258. {
  4259. string computedValue = "";
  4260. System.Xml.XmlNode newChild = null;
  4261. System.Xml.XmlNode refChild = null;
  4262. string expectedValue = "System.ArgumentException";
  4263. testResults results = new testResults("Core0093NO");
  4264. try
  4265. {
  4266. results.description = "The \"insertBefore()\" method of a node raises "+
  4267. "an System.ArgumentException Exception if the node "+
  4268. "to be inserted is one of this node's ancestors.";
  4269. //
  4270. // Retrieve targeted data and define reference and new childs.
  4271. //
  4272. newChild = util.getRootNode();
  4273. System.Xml.XmlElement testNode = (System.Xml.XmlElement)util.nodeObject(util.SECOND,-1);
  4274. refChild = util.getSubNodes(testNode).Item(util.FIRST);
  4275. //
  4276. // Attempt to insert a node that is one of this node ancestors should
  4277. // raise an exception.
  4278. //
  4279. try
  4280. {
  4281. testNode.InsertBefore(newChild, refChild);//.node.
  4282. }
  4283. catch(System.Exception ex)
  4284. {
  4285. computedValue = ex.GetType().ToString();
  4286. }
  4287. }
  4288. catch(System.Exception ex)
  4289. {
  4290. computedValue = "Exception " + ex.Message;
  4291. }
  4292. results.expected = expectedValue;
  4293. results.actual = computedValue;
  4294. util.resetData();
  4295. Assert.AreEqual (results.expected, results.actual);
  4296. }
  4297. //------------------------ End test case core-0093NO -------------------------
  4298. //
  4299. //------------------------- test case core-0094NO -----------------------------
  4300. //
  4301. // Testing feature - The "replaceChild" method of a node raises a
  4302. // System.ArgumentException Exception if this node
  4303. // is of a type that does not allow children of the
  4304. // type of "newChild" to be inserted.
  4305. //
  4306. // Testing Approach - Retrieve the root node and attempt to replace one of
  4307. // its children with a newly created Attr node. An
  4308. // Element node can not have children of the "Attr"
  4309. // type, therefore the desired exception should be raised.
  4310. //
  4311. // Semantic Requirements: 62
  4312. //
  4313. //----------------------------------------------------------------------------
  4314. [Test]
  4315. public void core0094NO()
  4316. {
  4317. string computedValue = "";
  4318. System.Xml.XmlElement rootNode = null;
  4319. System.Xml.XmlAttribute newChild = (System.Xml.XmlAttribute)util.createNode(util.ATTRIBUTE_NODE,"newAttribute");
  4320. System.Xml.XmlNode oldChild = null;
  4321. string expectedValue = "System.InvalidOperationException";
  4322. testResults results = new testResults("Core0094NO");
  4323. try
  4324. {
  4325. results.description = "The \"replaceChild()\" method of a node raises "+
  4326. "a System.ArgumentException Exception if this node "+
  4327. "does not allow nodes of type of \"newChild\".";
  4328. //
  4329. // Retrieve targeted data and define oldChild.
  4330. //
  4331. rootNode = util.getRootNode();
  4332. oldChild = util.nodeObject(util.SECOND,-1);
  4333. //
  4334. // Attempt to replace a child with an invalid child should raise an exception.
  4335. //
  4336. try
  4337. {
  4338. rootNode.ReplaceChild(newChild,oldChild);
  4339. }
  4340. catch(System.Exception ex)
  4341. {
  4342. computedValue = ex.GetType().ToString();
  4343. }
  4344. }
  4345. catch(System.Exception ex)
  4346. {
  4347. computedValue = ex.Message;
  4348. }
  4349. results.expected = expectedValue;
  4350. results.actual = computedValue;
  4351. util.resetData();
  4352. Assert.AreEqual (results.expected, results.actual);
  4353. }
  4354. //------------------------ End test case core-0094NO -------------------------
  4355. //
  4356. //------------------------- test case core-0095NO ----------------------------
  4357. //
  4358. // Testing feature - The "replaceChild()" method of a node raises
  4359. // a System.ArgumentException Exception if the node
  4360. // to be inserted is one of this node's ancestors.
  4361. //
  4362. // Testing Approach - Retrieve the second employee and attempt to replace one
  4363. // of its children with an ancestor node (root node).
  4364. // An attempt to make such a replacement should raise the
  4365. // desired exception.
  4366. //
  4367. // Semantic Requirements: 63
  4368. //
  4369. //----------------------------------------------------------------------------
  4370. [Test]
  4371. public void core0095NO()
  4372. {
  4373. string computedValue = "";
  4374. System.Xml.XmlNode newChild = null;
  4375. System.Xml.XmlNode oldChild = null;
  4376. System.Xml.XmlElement testNode = null;
  4377. string expectedValue = "System.InvalidOperationException";
  4378. testResults results = new testResults("Core0095NO");
  4379. try
  4380. {
  4381. results.description = "The \"replaceChild()\" method of a node raises "+
  4382. "a System.ArgumentException Exception if the node "+
  4383. "to be put is one of this node's ancestors.";
  4384. //
  4385. // Retrieve targeted data and define new and old childs.
  4386. //
  4387. newChild = util.getRootNode();
  4388. testNode = (System.Xml.XmlElement)util.nodeObject(util.SECOND,-1);
  4389. oldChild = util.getSubNodes(testNode).Item(util.FIRST);
  4390. //
  4391. // Attempt to replace a child with an ancestor should raise an exception.
  4392. //
  4393. try
  4394. {
  4395. testNode.ReplaceChild(newChild,oldChild);//.node.
  4396. }
  4397. catch(InvalidOperationException ex)
  4398. {
  4399. computedValue = ex.GetType().ToString();
  4400. }
  4401. }
  4402. catch(System.Exception ex)
  4403. {
  4404. computedValue = "Exception " + ex.Message;
  4405. }
  4406. results.expected = expectedValue;
  4407. results.actual = computedValue;
  4408. util.resetData();
  4409. Assert.AreEqual (results.expected, results.actual);
  4410. }
  4411. //------------------------ End test case core-0095NO -------------------------
  4412. //
  4413. //------------------------- test case core-0096NO ----------------------------
  4414. //
  4415. // Testing feature - The "appendChild" method of a node raises a
  4416. // System.ArgumentException Exception if this node
  4417. // is of a type that does not allow children of the
  4418. // type of "newChild".
  4419. //
  4420. // Testing Approach - Retrieve the root node and attempt to append a
  4421. // newly created Attr node to it. An Element
  4422. // node can not have children of the "Attr" type,
  4423. // therefore the desired exception should be raised.
  4424. //
  4425. // Semantic Requirements: 64
  4426. //
  4427. //----------------------------------------------------------------------------
  4428. [Test]
  4429. public void core0096NO()
  4430. {
  4431. string computedValue = "";
  4432. System.Xml.XmlElement rootNode = null;
  4433. System.Xml.XmlAttribute newChild = (System.Xml.XmlAttribute)util.createNode(util.ATTRIBUTE_NODE,"newAttribute");
  4434. string expectedValue = "System.InvalidOperationException";
  4435. testResults results = new testResults("Core0096NO");
  4436. try
  4437. {
  4438. results.description = "The \"appendChild()\" method of a node raises "+
  4439. "a System.ArgumentException Exception if this node "+
  4440. "does not allow nodes of type of \"newChild\".";
  4441. //
  4442. // Retrieve the targeted data.
  4443. //
  4444. rootNode = util.getRootNode();
  4445. //
  4446. // Attempt to append an invalid child should raise an exception.
  4447. //
  4448. try
  4449. {
  4450. rootNode.AppendChild(newChild);
  4451. }
  4452. catch(System.Exception ex)
  4453. {
  4454. computedValue = ex.GetType().ToString();
  4455. }
  4456. }
  4457. catch(System.Exception ex)
  4458. {
  4459. computedValue = "Exception " + ex.Message;
  4460. }
  4461. results.expected = expectedValue;
  4462. results.actual = computedValue;
  4463. util.resetData();
  4464. Assert.AreEqual (results.expected, results.actual);
  4465. }
  4466. //------------------------ End test case core-0096NO -------------------------
  4467. //
  4468. //------------------------- test case core-0097NO ----------------------------
  4469. //
  4470. // Testing feature - The "appendChild" method of a node raises
  4471. // an System.ArgumentException Exception if the node
  4472. // to be appended is one of this node's ancestors.
  4473. //
  4474. // Testing Approach - Retrieve the second employee and attempt to append to
  4475. // it an ancestor node (root node). An attempt to make
  4476. // such an insertion should raise the desired exception.
  4477. //
  4478. // Semantic Requirements: 65
  4479. //
  4480. //----------------------------------------------------------------------------
  4481. [Test]
  4482. public void core0097NO()
  4483. {
  4484. string computedValue = "";
  4485. System.Xml.XmlNode newChild = null;
  4486. System.Xml.XmlNode testNode = null;
  4487. string expectedValue = "System.ArgumentException";
  4488. testResults results = new testResults("Core0097NO");
  4489. try
  4490. {
  4491. results.description = "The \"appendChild()\" method of a node raises "+
  4492. "a System.ArgumentException Exception if the node "+
  4493. "to append is one of this node's ancestors.";
  4494. //
  4495. // Retrieve the targeted data and define the new child.
  4496. //
  4497. newChild = util.getRootNode();
  4498. testNode = util.nodeObject(util.SECOND,-1);
  4499. //
  4500. // Attempt to replace a child with an ancestor should raise an exception.
  4501. //
  4502. try
  4503. {
  4504. testNode.AppendChild(newChild);//.node.
  4505. }
  4506. catch(System.Exception ex)
  4507. {
  4508. computedValue = ex.GetType().ToString();
  4509. }
  4510. }
  4511. catch(System.Exception ex)
  4512. {
  4513. computedValue = "Exception " + ex.Message;
  4514. }
  4515. results.expected = expectedValue;
  4516. results.actual = computedValue;
  4517. util.resetData();
  4518. Assert.AreEqual (results.expected, results.actual);
  4519. }
  4520. //------------------------ End test case core-0097NO -------------------------
  4521. //
  4522. //------------------------- test case core-0098NO ----------------------------
  4523. //
  4524. // Testing feature - The "insertBefore" method of a node raises a
  4525. // NOT_FOUND_ERR Exception if the reference child is not
  4526. // child of this node.
  4527. //
  4528. // Testing Approach - Retrieve the second employee and attempt to insert
  4529. // a new node before a reference node that is not
  4530. // a child of this node. An attempt to insert before a
  4531. // non child node should raise the desired exception.
  4532. //
  4533. // Semantic Requirements: 66
  4534. //
  4535. //----------------------------------------------------------------------------
  4536. [Test]
  4537. public void core0098NO()
  4538. {
  4539. string computedValue = "";
  4540. System.Xml.XmlElement newChild = (System.Xml.XmlElement)util.createNode(util.ELEMENT_NODE,"newChild");
  4541. System.Xml.XmlElement refChild = (System.Xml.XmlElement)util.createNode(util.ELEMENT_NODE,"refChild");
  4542. System.Xml.XmlNode testNode = null;
  4543. string expectedValue = "System.ArgumentException";//util.NOT_FOUND2_ERR;
  4544. testResults results = new testResults("Core0098NO");
  4545. try
  4546. {
  4547. results.description = "The \"insertBefore\" method of a node raises "+
  4548. "a NOT_FOUND_ERR Exception if the reference "+
  4549. "child is not a child of this node.";
  4550. //
  4551. // Retrieve targeted data.
  4552. //
  4553. testNode = util.nodeObject(util.SECOND,-1);
  4554. //
  4555. // Attempt to insert before a reference child that is not a child of
  4556. // this node should raise an exception.
  4557. //
  4558. try
  4559. {
  4560. testNode.InsertBefore(newChild,refChild);//.node.
  4561. }
  4562. catch(ArgumentException ex)
  4563. {
  4564. computedValue = ex.GetType ().FullName;
  4565. }
  4566. }
  4567. catch(System.Exception ex)
  4568. {
  4569. computedValue = "Exception " + ex.Message;
  4570. }
  4571. results.expected = expectedValue;
  4572. results.actual = computedValue;
  4573. util.resetData();
  4574. Assert.AreEqual (results.expected, results.actual);
  4575. }
  4576. //------------------------ End test case core-0098NO -----------------------
  4577. //
  4578. //------------------------- test case core-0099NO --------------------------
  4579. //
  4580. // Testing feature - The "replaceChild" method of a node raises a
  4581. // NOT_FOUND_ERR Exception if the old child is not
  4582. // child of this node.
  4583. //
  4584. // Testing Approach - Retrieve the second employee and attempt to replace
  4585. // a node that is not one of its children. An attempt
  4586. // to replace such a node should raise the desired
  4587. // exception.
  4588. //
  4589. // Semantic Requirements: 67
  4590. //
  4591. //----------------------------------------------------------------------------
  4592. [Test]
  4593. public void core0099NO()
  4594. {
  4595. string computedValue = "";
  4596. System.Xml.XmlElement newChild = (System.Xml.XmlElement)util.createNode(util.ELEMENT_NODE,"newChild");
  4597. System.Xml.XmlElement oldChild = (System.Xml.XmlElement)util.createNode(util.ELEMENT_NODE,"oldChild");
  4598. System.Xml.XmlNode testNode = null;
  4599. string expectedValue = "System.ArgumentException";//util.NOT_FOUND2_ERR;
  4600. testResults results = new testResults("Core0099NO");
  4601. try
  4602. {
  4603. results.description = "The \"replaceChild\" method of a node raises "+
  4604. "a NOT_FOUND_ERR Exception if the old child "+
  4605. "is not a child of this node.";
  4606. //
  4607. // Retrieve the targeted data..
  4608. //
  4609. testNode = util.nodeObject(util.SECOND,-1);
  4610. //
  4611. // Attempt to replace a non child node should raise an exception.
  4612. //
  4613. try
  4614. {
  4615. testNode.ReplaceChild(newChild,oldChild);//.node.
  4616. }
  4617. catch(ArgumentException ex)
  4618. {
  4619. computedValue = ex.GetType ().FullName;
  4620. }
  4621. }
  4622. catch(System.Exception ex)
  4623. {
  4624. computedValue = "Exception " + ex.Message;
  4625. }
  4626. results.expected = expectedValue;
  4627. results.actual = computedValue;
  4628. util.resetData();
  4629. Assert.AreEqual (results.expected, results.actual);
  4630. }
  4631. //------------------------ End test case core-0099NO -----------------------
  4632. //
  4633. //------------------------- test case core-0100NO --------------------------
  4634. //
  4635. // Testing feature - The "removeChild" method of a node raises a
  4636. // NOT_FOUND_ERR Exception if the old child is not
  4637. // child of this node.
  4638. //
  4639. // Testing Approach - Retrieve the second employee and attempt to remove
  4640. // a node that is not one of its children. An attempt
  4641. // to remove such a node should raise the desired
  4642. // exception.
  4643. //
  4644. // Semantic Requirements: 68
  4645. //
  4646. //----------------------------------------------------------------------------
  4647. [Test]
  4648. public void core0100NO()
  4649. {
  4650. string computedValue = "";
  4651. System.Xml.XmlElement oldChild = (System.Xml.XmlElement)util.createNode(util.ELEMENT_NODE,"oldChild");
  4652. System.Xml.XmlNode testNode = null;
  4653. string expectedValue = typeof (ArgumentException).FullName;//util.NOT_FOUND3_ERR;
  4654. testResults results = new testResults("Core0100NO");
  4655. try
  4656. {
  4657. results.description = "The \"removeChild\" method of a node raises "+
  4658. "a NOT_FOUND_ERR Exception if the old "+
  4659. "child is not a child of this node.";
  4660. //
  4661. // Retrieve targeted data.
  4662. //
  4663. testNode = util.nodeObject(util.SECOND,-1);
  4664. //
  4665. // Attempt to remove a non child node should raise an exception.
  4666. //
  4667. try
  4668. {
  4669. testNode.RemoveChild(oldChild);//.node.
  4670. }
  4671. catch(ArgumentException ex)
  4672. {
  4673. computedValue = ex.GetType ().FullName;
  4674. }
  4675. }
  4676. catch(System.Exception ex)
  4677. {
  4678. computedValue = "Exception " + ex.Message;
  4679. }
  4680. results.expected = expectedValue;
  4681. results.actual = computedValue;
  4682. util.resetData();
  4683. Assert.AreEqual (results.expected, results.actual);
  4684. }
  4685. //------------------------ End test case core-0100NO -----------------------
  4686. //
  4687. //------------------------- test case core-0101NO ----------------------------
  4688. //
  4689. // Testing feature - The "insertBefore" method of a node raises a
  4690. // System.ArgumentException Exception if the new child was
  4691. // created from a different document than the one that
  4692. // created this node.
  4693. //
  4694. // Testing Approach - Retrieve the second employee and attempt to insert
  4695. // a new child that was created from a different
  4696. // document than the one that created the second employee.
  4697. // An attempt to insert such a child should raise
  4698. // the desired exception.
  4699. //
  4700. // Semantic Requirements: 69
  4701. //
  4702. //----------------------------------------------------------------------------
  4703. [Test]
  4704. public void core0101NO()
  4705. {
  4706. string computedValue = "";
  4707. System.Xml.XmlElement newChild = util.getOtherDOMDocument().CreateElement("newChild");
  4708. System.Xml.XmlNode refChild = null;
  4709. System.Xml.XmlElement testNode = null;
  4710. string expectedValue = "System.ArgumentException";
  4711. testResults results = new testResults("Core0101NO");
  4712. try
  4713. {
  4714. results.description = "The \"insertBefore\" method of a node raises "+
  4715. "a System.ArgumentException Exception if the new "+
  4716. "child was created from a document different "+
  4717. "from the one that created this node.";
  4718. //
  4719. // Retrieve targeted data and define reference child.
  4720. //
  4721. testNode = (System.Xml.XmlElement)util.nodeObject(util.SECOND,-1);
  4722. refChild = util.getSubNodes(testNode).Item(util.FOURTH);
  4723. //
  4724. // Attempt to insert a child from a different document should raise an
  4725. // exception.
  4726. //
  4727. try
  4728. {
  4729. testNode.InsertBefore(newChild,refChild);//.node.
  4730. }
  4731. catch(System.Exception ex)
  4732. {
  4733. computedValue = ex.GetType().ToString();
  4734. }
  4735. }
  4736. catch(System.Exception ex)
  4737. {
  4738. computedValue = "Exception " + ex.Message;
  4739. }
  4740. results.expected = expectedValue;
  4741. results.actual = computedValue;
  4742. util.resetData();
  4743. Assert.AreEqual (results.expected, results.actual);
  4744. }
  4745. //------------------------ End test case core-0101NO -----------------------
  4746. //
  4747. //------------------------- test case core-0102NO --------------------------
  4748. //
  4749. // Testing feature - The "replaceChild" method of a node raises a
  4750. // System.ArgumentException Exception if the new child was
  4751. // created from a different document than the one that
  4752. // created this node.
  4753. //
  4754. // Testing Approach - Retrieve the second employee and attempt to
  4755. // replace one of its children with a node created
  4756. // from a different document. An attempt to make such
  4757. // replacement should raise the desired exception.
  4758. //
  4759. // Semantic Requirements: 70
  4760. //
  4761. //----------------------------------------------------------------------------
  4762. [Test]
  4763. public void core0102NO()
  4764. {
  4765. string computedValue = "";
  4766. System.Xml.XmlElement newChild = util.getOtherDOMDocument().CreateElement("newChild");
  4767. System.Xml.XmlNode oldChild = null;
  4768. System.Xml.XmlElement testNode = null;
  4769. string expectedValue = "System.ArgumentException";
  4770. testResults results = new testResults("Core0102NO");
  4771. try
  4772. {
  4773. results.description = "The \"replaceChild\" method of a node raises "+
  4774. "a System.ArgumentException Exception if the new "+
  4775. "child was created from a document different "+
  4776. "from the one that created this node.";
  4777. //
  4778. // Retrieve targeted data and define oldChild.
  4779. //
  4780. testNode = (System.Xml.XmlElement)util.nodeObject(util.SECOND,-1);
  4781. oldChild = util.getSubNodes(testNode).Item(util.FIRST);
  4782. //
  4783. // Attempt to replace a child with a child from a different document
  4784. // should raise an exception.
  4785. //
  4786. try
  4787. {
  4788. testNode.ReplaceChild(newChild,oldChild);//.node.
  4789. }
  4790. catch(System.Exception ex)
  4791. {
  4792. computedValue = ex.GetType().ToString();
  4793. }
  4794. }
  4795. catch(System.Exception ex)
  4796. {
  4797. computedValue = "Exception " + ex.Message;
  4798. }
  4799. results.expected = expectedValue;
  4800. results.actual = computedValue;
  4801. util.resetData();
  4802. Assert.AreEqual (results.expected, results.actual);
  4803. }
  4804. //------------------------ End test case core-0102NO -----------------------
  4805. //
  4806. //------------------------- test case core-0103NO --------------------------
  4807. //
  4808. // Testing feature - The "appendChild" method of a node raises a
  4809. // System.ArgumentException Exception if the new child was
  4810. // created from a different document than the one that
  4811. // created this node.
  4812. //
  4813. // Testing Approach - Retrieve the second employee and attempt to append
  4814. // to it a node that was created from different
  4815. // document. An attempt to make such an insertion
  4816. // should raise the desired exception.
  4817. //
  4818. // Semantic Requirements: 71
  4819. //
  4820. //----------------------------------------------------------------------------
  4821. [Test]
  4822. public void core0103NO()
  4823. {
  4824. string computedValue = "";
  4825. System.Xml.XmlElement newChild = util.getOtherDOMDocument().CreateElement("newChild");
  4826. System.Xml.XmlNode testNode = null;
  4827. string expectedValue = "System.ArgumentException";
  4828. testResults results = new testResults("Core0103NO");
  4829. try
  4830. {
  4831. results.description = "The \"appendChild\" method of a node raises a "+
  4832. "a System.ArgumentException Exception if the new "+
  4833. "child was created from a document different "+
  4834. "from the one that created this node.";
  4835. //
  4836. // Retrieve the targeted data.
  4837. //
  4838. testNode = util.nodeObject(util.SECOND,-1);
  4839. //
  4840. // Attempt to append a child from a different document should raise an
  4841. // exception.
  4842. //
  4843. try
  4844. {
  4845. testNode.AppendChild(newChild);//.node.
  4846. }
  4847. catch(System.Exception ex)
  4848. {
  4849. computedValue = ex.GetType().ToString();
  4850. }
  4851. }
  4852. catch(System.Exception ex)
  4853. {
  4854. computedValue = "Exception " + ex.Message;
  4855. }
  4856. results.expected = expectedValue;
  4857. results.actual = computedValue;
  4858. util.resetData();
  4859. Assert.AreEqual (results.expected, results.actual);
  4860. }
  4861. //------------------------ End test case core-0103NO -----------------------
  4862. }
  4863. }