PageRenderTime 58ms CodeModel.GetById 30ms 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

Large files files are truncated, but you can click here to view the full file

  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 ca…

Large files files are truncated, but you can click here to view the full file