/mcs/class/System.XML/Test/System.Xml/nist_dom/fundamental/Node/Node.cs
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
- //**************************************************************************
- //
- //
- // National Institute Of Standards and Technology
- // DTS Version 1.0
- //
- // Node Interface
- //
- // Written by: Carmelo Montanez
- // Modified by: Mary Brady
- //
- // Ported to System.Xml by: Mizrahi Rafael rafim@mainsoft.com
- // Mainsoft Corporation (c) 2003-2004
- //**************************************************************************
- using System;
- using System.Xml;
-
- using nist_dom;
- using NUnit.Framework;
-
- namespace nist_dom.fundamental
- {
- [TestFixture]
- public class NodeTest
- {
- public static int i = 2;
- /*
- public testResults[] RunTests()
- {
- testResults[] tests = new testResults[] {core0001NO(), core0002NO(), core0003NO(),core0004NO(),
- core0005NO(), core0006NO(), core0007NO(), core0008NO(),
- core0009NO(), core0010NO(), core0011NO(), core0012NO(),
- core0013NO(), core0014NO(), core0015NO(), core0016NO(),
- core0017NO(), core0018NO(), core0019NO(), core0020NO(),
- core0021NO(), core0022NO(), core0023NO(), core0024NO(),
- core0025NO(), core0026NO(), core0027NO(), core0028NO(),
- core0029NO(), core0030NO(), core0031NO(), core0032NO(),
- core0033NO(), core0034NO(), core0035NO(), core0036NO(),
- core0038NO(), core0039NO(), core0040NO(),
- core0041NO(), core0042NO(), core0043NO(), core0044NO(),
- core0045NO(), core0046NO(), core0047NO(), core0048NO(),
- core0049NO(), core0050NO(), core0051NO(), core0052NO(),
- core0053NO(), core0054NO(), core0055NO(), core0056NO(),
- core0057NO(), core0058NO(), core0059NO(), core0060NO(),
- core0061NO(), core0062NO(), core0063NO(), core0064NO(),
- core0065NO(), core0066NO(), core0067NO(), core0068NO(),
- core0069NO(), core0070NO(), core0071NO(), core0072NO(),
- core0073NO(), core0074NO(), core0075NO(), core0076NO(),
- core0077NO(), core0078NO(), core0079NO(), core0080NO(),
- core0081NO(), core0082NO(), core0083NO(), core0084NO(),
- core0085NO(), core0087NO(), core0088NO(),
- core0089NO(), core0090NO(), core0091NO(), core0092NO(),
- core0093NO(), core0094NO(), core0095NO(), core0096NO(),
- core0097NO(), core0098NO(), core0099NO(), core0100NO(),
- core0101NO(), core0102NO(), core0103NO()};
-
- return tests;
- }
- */
-
- //------------------------ test case core-0001NO------------------------
- //
- // Testing feature - The "nodeType" attribute for an Element node is
- // 1 (ELEMENT_NODE).
- //
- // Testing approach - Retrieve the root node and check its "nodeType"
- // attribute. It should be set to 1.
- //
- // Semantic Requirements: 1, 14
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0001NO()
- {
- int computedValue = 0;
- int expectedValue = util.ELEMENT_NODE;
-
- testResults results = new testResults("Core0001NO");
-
- results.description = "The nodeType attribute for an Element Node "+
- " should be set to the constant 1.";
- //
- // The nodeType attribute for the root node should be set to the value 1.
- //
- computedValue = (int)util.getRootNode().NodeType;
- //
- // write out results.
- //
- results.expected = expectedValue.ToString();
- results.actual = computedValue.ToString();
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0001NO --------------------------
- //
- //------------------------- test case core-0002NO -----------------------------
- //
- // Testing feature - The "nodeType" attribute for an Attribute node is
- // 2 (ATTRIBUTE_NODE).
- //
- // Testing approach - Retrieve the first attribute from the last child of
- // the first employee. Its "nodeType" attribute is then
- // checked, it should be set to 2.
- //
- // Semantic Requirements: 2, 14
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0002NO()
- {
- string computedValue = "";
- System.Xml.XmlElement testNode = null;
- System.Xml.XmlAttribute attrNode = null;
- string expectedValue = util.ATTRIBUTE_NODE.ToString();
-
- testResults results = new testResults("Core0002NO");
- try
- {
- results.description = "The nodeType attribute for an Attribute Node "+
- " should be set to the constant 2.";
- //
- // Retrieve the targeted data and its type.
- //
- testNode = (System.Xml.XmlElement)util.nodeObject(util.FIRST,util.SIXTH);
- attrNode = testNode.GetAttributeNode("domestic");//.node.
- computedValue = ((int)attrNode.NodeType).ToString();
- }
- catch(System.Exception ex)
- {
- computedValue = "Exception " + ex.Message;
- }
- //
- // write out results.
- //
- results.expected = expectedValue.ToString();
- results.actual = computedValue;
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0002NO --------------------------
- //
- //------------------------- test case core-0003NO -----------------------------
- //
- // Testing feature - The "nodeType" attribute for a Text node is
- // 3 (TEXT_NODE).
- //
- // Testing approach - Retrieve the Text data from the last child of the
- // first employee and and examine its "nodeType"
- // attribute. It should be set to 3.
- //
- // Semantic Requirements: 3, 14
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0003NO()
- {
- string computedValue = "";
- System.Xml.XmlNode testNode = null;
- System.Xml.XmlNode textNode = null;
- string expectedValue = util.TEXT_NODE.ToString();
-
- testResults results = new testResults("Core0003NO");
- try
- {
- results.description = "The nodeType attribute for a Text Node "+
- " should be set to the constant 3.";
-
- //
- // Retrieve the targeted data.
- //
- testNode = util.nodeObject(util.FIRST,util.SIXTH);
- textNode = testNode.FirstChild;//.node.
- //
- // The nodeType attribute should be set to the value 3.
- //
- computedValue = ((int)textNode.NodeType).ToString();
- }
- catch(System.Exception ex)
- {
- computedValue = "Exception " + ex.Message;
- }
- //
- // write out results.
- //
- results.expected = expectedValue.ToString();
- results.actual = computedValue;
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0003NO --------------------------
- //
- //------------------------- test case core-0004NO -----------------------------
- //
- // Testing feature - The "nodeType" attribute for a CDATASection node is
- // 4 (CDATA_SECTION_NODE).
- //
- // Testing approach - Retrieve the CDATASection node contained inside
- // the second child of the second employee and
- // examine its "nodeType" attribute. It should be
- // set to 4.
- //
- // Semantic Requirements: 4, 14
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0004NO()
- {
- string computedValue = "";
- System.Xml.XmlNode testNode = null;
- System.Xml.XmlNode cDataNode = null;
- string expectedValue = util.CDATA_SECTION_NODE.ToString();
-
- testResults results = new testResults("Core0004NO");
- try
- {
- results.description = "The nodeType attribute for a CDATASection Node "+
- " should be set to the constant 4.";
- //
- // Retrieve the targeted data.
- //
- testNode = util.nodeObject(util.SECOND,util.SECOND);
- cDataNode = testNode.LastChild; //.node.
- //
- // The nodeType attribute should be set to the value 3.
- //
- computedValue = ((int)cDataNode.NodeType).ToString();
- }
- catch(System.Exception ex)
- {
- computedValue = "Exception " + ex.Message;
- }
- //
- // write out results.
- //
- results.expected = expectedValue.ToString();
- results.actual = computedValue.ToString();
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0004NO --------------------------
- //
- //------------------------- test case core-0005NO -----------------------------
- //
- // Testing feature - The "nodeType" attribute for an EntityReference node
- // is 5 (ENTITY_REFERENCE_NODE).
- //
- // Testing approach - Retrieve the first Entity Reference node from the
- // last child of the second employee and examine its
- // "nodeType" attribute. It should be set to 5.
- //
- // Semantic Requirements: 5, 14
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0005NO()
- {
- string computedValue = "";
- System.Xml.XmlNode testNode = null;
- System.Xml.XmlNode entRefNode = null;
- string expectedValue = XmlNodeType.EntityReference.ToString ();//util.ENTITY_REFERENCE_NODE;
-
- testResults results = new testResults("Core0005NO");
- try
- {
- results.description = "The nodeType attribute for an EntityReference Node "+
- " should be set to the constant 5.";
-
- //
- // Retrieve the targeted data.
- //
- testNode = util.nodeObject(util.SECOND,util.SIXTH);
- entRefNode = testNode.FirstChild;//.node.
- //
- // The nodeType attribute should be set to the value 5.
- //
- computedValue = entRefNode.NodeType.ToString();
- }
- catch(System.Exception ex)
- {
- computedValue = "Exception " + ex.Message;
- }
- //
- // write out results.
- //
- results.expected = expectedValue.ToString();
- results.actual = computedValue.ToString();
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0005NO --------------------------
- //
- //------------------------- test case core-0006NO -----------------------------
- //
- // Testing feature - The "nodeType" attribute for an Entity node
- // 6 (ENTITY_NODE).
- //
- // Testing approach - Retrieve the first Entity declaration in the
- // "DOCTYPE" section of the XML file and examine
- // its "nodeType" attribute. It should be set to 6.
- //
- // Semantic Requirements: 6, 14
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0006NO()
- {
- int computedValue = 0;
- System.Xml.XmlNode testNode = null;
- int expectedValue = util.ENTITY_NODE;
-
- testResults results = new testResults("Core0006NO");
- results.description = "The nodeType attribute for an Entity Node "+
- " should be set to the constant 6.";
- //
- // Get the targeted data and its type.
- //
- testNode = util.getEntity("ent1");
- //
- // The nodeType attribute should be set to the value 6.
- //
- computedValue = (int)testNode.NodeType;
-
- //
- // write out results.
- //
- results.expected = expectedValue.ToString();
- results.actual = computedValue.ToString();
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0006NO --------------------------
- //
- //------------------------- test case core-0007NO -----------------------------
- //
- // Testing feature - The "nodeType" attribute for a ProcessingInstruction.
- //
- // Testing approach - Retrieve the first declaration in the XML file
- // and examine its "nodeType" attribute. It should
- // be set to ProcessingInstruction.
- //
- // Semantic Requirements: 7, 14
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0007NO()
- {
- string computedValue = "";
- System.Xml.XmlNode testNode = null;
- string expectedValue = util.XML_DECLARATION_NODE.ToString(); //util.PROCESSING_INSTRUCTION_NODE.ToString();
-
- testResults results = new testResults("Core0007NO");
- results.description = "The nodeType attribute for an ProcessingInstruction Node.";
- //
- // Get the targeted data.
- //
- testNode = util.getDOMDocument().ChildNodes.Item(0);
- //
- // The nodeType attribute should be set to the value 7.
- //
- computedValue = ((int)testNode.NodeType).ToString();
- //
- // write out results.
- //
- results.expected = expectedValue.ToString();
- results.actual = computedValue.ToString();
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0007NO --------------------------
- //
- //------------------------- test case core-0008NO -----------------------------
- //
- // Testing feature - The "nodeType" attribute for a comment node is
- // 8 (COMMENT_NODE).
- //
- // Testing approach - Retrieve the only comment (third child) from the
- // main DOM document and examine its "nodeType" attribute.
- // It should be set to 8.
- //
- // Semantic Requirements: 8, 14
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0008NO()
- {
- int computedValue = 0;
- System.Xml.XmlNode testNode = null;
- int expectedValue = util.COMMENT_NODE;
-
- testResults results = new testResults("Core0008NO");
- results.description = "The nodeType attribute for a Comment Node "+
- " should be set to the constant 8.";
- //
- // Get the targeted data.
- //
- testNode = util.getDOMDocument().ChildNodes.Item(2);
- //
- // The nodeType attribute should be set to the value 8.
- //
- computedValue = (int)testNode.NodeType;
- //
- // write out results.
- //
- results.expected = expectedValue.ToString();
- results.actual = computedValue.ToString();
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0008NO --------------------------
- //
- //------------------------- test case core-0009NO -----------------------------
- //
- // Testing feature - The "nodeType" attribute for a Document node is
- // 9 (DOCUMENT_NODE).
- //
- // Testing approach - Retrieve the DOM Document and examine its
- // "nodeType" attribute. It should be set to 9.
- //
- // Semantic Requirements: 9, 14
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0009NO()
- {
- int computedValue = 0;
- System.Xml.XmlNode testNode = null;
- int expectedValue = util.DOCUMENT_NODE;
-
- testResults results = new testResults("Core0009NO");
- results.description = "The nodeType attribute for an Document Node "+
- " should be set to the constant 9.";
- //
- // Get the targeted data.
- //
- testNode = util.getDOMDocument();
- //
- // The nodeType attribute should be set to the value 9.
- //
- computedValue = (int)testNode.NodeType;
- //
- // write out results.
- //
- results.expected = expectedValue.ToString();
- results.actual = computedValue.ToString();
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0009NO --------------------------
- //
- //------------------------- test case core-0010NO -----------------------------
- //
- // Testing feature - The "nodeType" attribute for a DocumentType node is
- // 10 (DOCUMENT_TYPE_NODE).
- //
- // Testing approach - Retrieve the DOCTYPE declaration (second child) from
- // the XML file and examine its "nodeType" attribute.
- // It should be set to 10.
- //
- // Semantic Requirements: 10, 14
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0010NO()
- {
- int computedValue = 0;
- System.Xml.XmlNode testNode = null;
- int expectedValue = util.DOCUMENT_TYPE_NODE;
-
- testResults results = new testResults("Core0010NO");
- results.description = "The nodeType attribute for an DocumentType Node "+
- " should be set to the constant 10.";
- //
- // Get the targeted data.
- //
- testNode = util.getDocType();
- //
- // The nodeType attribute should be set to the value 10.
- //
- computedValue = (int)testNode.NodeType;
- //
- // write out results.
- //
- results.expected = expectedValue.ToString();
- results.actual = computedValue.ToString();
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0010NO --------------------------
- //
- //------------------------- test case core-0011NO -----------------------------
- //
- // Testing feature - The "nodeType" attribute for a DocumentFragment node
- // is 11 (DOCUMENT_FRAGMENT_NODE).
- //
- // Testing approach - Retrieve the whole DOM document and invoke its
- // "createDocumentFragment()" method and examine the
- // "nodeType" attribute of the returned node. It should
- // be set to 11.
- //
- // Semantic Requirements: 11, 14
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0011NO()
- {
- int computedValue = 0;
- System.Xml.XmlNode testNode = null;
- int expectedValue = util.DOCUMENT_FRAGMENT_NODE;
-
- testResults results = new testResults("Core0011NO");
- results.description = "The nodeType attribute for a DocumentFragment Node "+
- " should be set to the constant 11.";
- //
- // Get the targeted data.
- //
- testNode = util.getDOMDocument().CreateDocumentFragment();
- //
- // The nodeType attribute should be set to the value 11.
- //
- computedValue = (int)testNode.NodeType;
- //
- // write out results.
- //
- results.expected = expectedValue.ToString();
- results.actual = computedValue.ToString();
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0011NO --------------------------
- //
- //------------------------- test case core-0012NO -----------------------------
- //
- // Testing feature - The "nodeType" attribute for a notation node is
- // 12 (NOTATION_NODE).
- //
- // Testing approach - Retrieve the Notation declaration inside the
- // DocumentType node and examine its "nodeType"
- // attribute. It should be set to 12.
- //
- // Semantic Requirements: 12, 14
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0012NO()
- {
- string computedValue = "";
- System.Xml.XmlNode testNode = null;
- string expectedValue = util.NOTATION_NODE.ToString();
-
- testResults results = new testResults("Core0012NO");
- try
- {
- results.description = "The nodeType attribute for a Notation Node "+
- " should be set to the constant 12.";
- //
- // Get the targeted data.
- //
- testNode = util.getNotation("notation1");
- //
- // The nodeType attribute should be set to the value 12.
- //
- computedValue = ((int)testNode.NodeType).ToString();
- }
- catch(System.Exception ex)
- {
- computedValue = "Exception " + ex.Message;
- }
- //
- // write out results.
- //
- results.expected = expectedValue.ToString();
- results.actual = computedValue.ToString();
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0012NO --------------------------
- //
- //------------------------ test case core-0013NO ----------------------------
- //
- // Testing feature - The "nodeName" attribute for an Element node is
- // its tagName.
- //
- // Testing approach - Retrieve the first Element node (root node) of the
- // DOM object and check its "nodeName" attribute.
- // It should be equal to its tagName.
- //
- // Semantic Requirements: 13, 15
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0013NO()
- {
- string computedValue = "0";
- string expectedValue = "staff";
-
- testResults results = new testResults("Core0013NO");
- results.description = "The nodeName attribute for an Element Node " +
- "should be set to its tagName.";
- //
- // The nodeName attribute should be set to "staff".
- //
- computedValue = util.getRootNode().Name;
- //
- // write out results.
- //
- results.expected = expectedValue;
- results.actual = computedValue;
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0013NO --------------------------
- //
- //------------------------- test case core-0014NO -----------------------------
- //
- // Testing feature - The "nodeName" attribute for an Attribute node is
- // the name of the attribute.
- //
- // Testing approach - Retrieve the attribute named "domestic" from the last
- // child of the first employee. Its "nodeName" attribute
- // is then checked. It should be set to "domestic".
- //
- // Semantic Requirements: 13, 15
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0014NO()
- {
- string computedValue = "0";
- string expectedValue = "domestic";
- System.Xml.XmlElement testNode = null;
- System.Xml.XmlAttribute attrNode = null;
-
- testResults results = new testResults("Core0014NO");
- try
- {
- results.description = "The nodeName attribute for an Attribute Node " +
- "should be set to the name of the attribute.";
- //
- // Retrieve the targeted data.
- //
- testNode = (System.Xml.XmlElement)util.nodeObject(util.FIRST,util.SIXTH);
- attrNode = testNode.GetAttributeNode("domestic"); //.node.
- //
- // The nodeName attribute should be set to the value "domestic".
- //
- computedValue = attrNode.Name;
- }
- catch(System.Exception ex)
- {
- computedValue = "Exception " + ex.Message;
- }
- //
- // write out results.
- //
- results.expected = expectedValue;
- results.actual = computedValue;
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0014NO --------------------------
- //
- //------------------------- test case core-0015NO -----------------------------
- //
- // Testing feature - The "nodeName" attribute for a text node is
- // "#text".
- //
- // Testing approach - Retrieve the Text data from the last child of the
- // first employee and and examine its "nodeName"
- // attribute. It should be set to "#text".
- //
- // Semantic Requirements: 13, 15
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0015NO()
- {
- string computedValue = "0";
- string expectedValue = "#text";
- System.Xml.XmlNode testNode = null;
- System.Xml.XmlNode textNode = null;
-
- testResults results = new testResults("Core0015NO");
- try
- {
- results.description = "The nodeName attribute for a Text Node " +
- "should be set to \"#text\".";
- //
- // Retrieve the targeted data.
- //
- testNode = util.nodeObject(util.FIRST,util.SIXTH);
- textNode = testNode.FirstChild;//.node.
- //
- // The nodeName attribute should be set to the value "#text".
- //
- computedValue = textNode.Name;
- }
- catch(System.Exception ex)
- {
- computedValue = "Exception " + ex.Message;
- }
- //
- // write out results.
- //
- results.expected = expectedValue;
- results.actual = computedValue;
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0015NO --------------------------
- //
- //------------------------- test case core-0016NO -----------------------------
- //
- // Testing feature - The "nodeName" attribute for a CDATASection node is
- // "#cdata-section".
- //
- // Testing approach - Retrieve the CDATASection node inside the second
- // child of the second employee and examine its "nodeName"
- // attribute. It should be set to "#cdata-section".
- //
- // Semantic Requirements: 13, 15
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0016NO()
- {
- string computedValue = "0";
- string expectedValue = "#cdata-section";
- System.Xml.XmlNode testNode = null;
- System.Xml.XmlNode cDataNode = null;
-
- testResults results = new testResults("Core0016NO");
- try
- {
- results.description = "The nodeName attribute for a CDATASection Node " +
- "should be set to \"#cdata-section\".";
- //
- // Retrieve the targeted data.
- //
- testNode = util.nodeObject(util.SECOND,util.SECOND);
- cDataNode = testNode.LastChild;;//.node.
- //
- // The nodeName attribute should be set to "#cdata-section".
- //
- computedValue = cDataNode.Name;
- }
- catch(System.Exception ex)
- {
- computedValue = "Exception " + ex.Message;
- }
- //
- // write out results.
- //
- results.expected = expectedValue;
- results.actual = computedValue;
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0016NO --------------------------
- //
- //------------------------- test case core-0017NO -----------------------------
- //
- // Testing feature - The "nodeName" attribute for an EntityReference node
- // is the name of the entity referenced.
- //
- // Testing approach - Retrieve the first Entity Reference node from the last
- // child of the second employee and examine its
- // "nodeName" attribute. It should be set to "ent2".
- //
- // Semantic Requirements: 13, 15
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0017NO()
- {
- string computedValue = "";
- string expectedValue = "ent2";
- System.Xml.XmlNode testNode = null;
- System.Xml.XmlNode entRefNode = null;
-
- testResults results = new testResults("Core0017NO");
- try
- {
- results.description = "The nodeName attribute for an EntityReference Node " +
- "should be set to the name of the entity referenced.";
- //
- // Retrieve the targeted data.
- //
- testNode = util.nodeObject(util.SECOND,util.SIXTH);
- entRefNode = testNode.FirstChild;//.node.
- //
- // The nodeName attribute should be set to "ent2".
- //
- computedValue = entRefNode.Name;
- }
- catch(System.Exception ex)
- {
- computedValue = "Exception " + ex.Message;
- }
- //
- // write out results.
- //
- results.expected = expectedValue;
- results.actual = computedValue;
-
- Assert.AreEqual (results.expected, results.actual);
- }
- //------------------------ End test case core-0017NO --------------------------
- //
- //------------------------- test case core-0018NO -----------------------------
- //
- // Testing feature - The "nodeName" attribute for an Entity node is
- // the entity name.
- //
- // Testing approach - Retrieve the first Entity declaration in the
- // "DOCTYPE" section of the XML file and examine
- // its "nodeName" attribute. It should be set to
- // "ent1" .
- //
- // Semantic Requirements: 13, 15
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0018NO()
- {
- string computedValue = "";
- string expectedValue = "ent1";
- System.Xml.XmlNode testNode = null;
-
- testResults results = new testResults("Core0018NO");
- results.description = "The nodeName attribute for an Entity Node " +
- "should be set to the entity name.";
- //
- // Get the targeted data.
- //
- testNode = util.getEntity("ent1");
- //
- // The nodeName attribute should be set to "ent1".
- //
- computedValue = testNode.Name;
- //
- // write out results.
- //
- results.expected = expectedValue;
- results.actual = computedValue;
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0018NO --------------------------
- //
- //------------------------- test case core-0019NO -----------------------------
- //
- // Testing feature - The "nodeName" attribute for a ProcessingInstruction
- // node is the target.
- //
- // Testing approach - Retrieve the first declaration in the XML file
- // and examine its "nodeName" attribute. It should
- // be set to "xml".
- //
- // Semantic Requirements: 13, 15
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0019NO()
- {
- string computedValue = "0";
- string expectedValue = "xml";
- System.Xml.XmlNode testNode = null;
-
- testResults results = new testResults("Core0019NO");
- results.description = "The nodeName attribute for a ProcessingInstruction "+
- "Node should be set to the target.";
- //
- // Get the targeted data.
- //
- testNode = util.getDOMDocument().ChildNodes.Item(0);
- //
- // The nodeName attribute should be set to "xml".
- //
- computedValue = testNode.Name;
- //
- // write out results.
- //
- results.expected = expectedValue;
- results.actual = computedValue;
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0019NO --------------------------
- //
- //------------------------- test case core-0020NO -----------------------------
- //
- // Testing feature - The "nodeName" attribute for a comment node is
- // "#comment".
- //
- // Testing approach - Retrieve the only comment in the XML file (third child)
- // and examine its "nodeName" attribute. It should
- // be set to "#comment".
- //
- // Semantic Requirements: 13, 15
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0020NO()
- {
- string computedValue = "0";
- string expectedValue = "#comment";
- System.Xml.XmlNode testNode = null;
-
- testResults results = new testResults("Core0020NO");
- results.description = "The nodeName attribute for a comment Node "+
- "should be set to \"#comment\".";
- //
- // Get the targeted data.
- //
- testNode = util.getDOMDocument().ChildNodes.Item(2);
- //
- // The nodeName attribute should be set to "#comment".
- //
- computedValue = testNode.Name;
- //
- // write out results.
- //
- results.expected = expectedValue;
- results.actual = computedValue;
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0020NO --------------------------
- //
- //------------------------- test case core-0021NO -----------------------------
- //
- // Testing feature - The "nodeName" attribute for a Document node is
- // "#document".
- //
- // Testing approach - Retrieve the DOM Document and examine its
- // "nodeName" attribute. It should be set to "#document".
- //
- // Semantic Requirements: 13, 15
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0021NO()
- {
- string computedValue = "";
- string expectedValue = "#document";
- System.Xml.XmlNode testNodeNode = null;
-
- testResults results = new testResults("Core0021NO");
- results.description = "The nodeName attribute for a Document Node "+
- "should be set to \"#document\".";
- //
- // Get the targeted data.
- //
- System.Xml.XmlNode testNode = util.getDOMDocument();
- //
- // The nodeName attribute should be set to "#document".
- //
- computedValue = testNode.Name;
- //
- // write out results.
- //
- results.expected = expectedValue;
- results.actual = computedValue;
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0021NO --------------------------
- //
- //------------------------- test case core-0022NO -----------------------------
- //
- // Testing feature - The "nodeName" attribute for a DocumentType node is
- // the document type name.
- //
- // Testing approach - Retrieve the DOCTYPE declaration (second child) from
- // the XML file and examine its "nodeName" attribute.
- // It should be set to "staff".
- //
- // Semantic Requirements: 13, 15
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0022NO()
- {
- string computedValue = "";
- string expectedValue = "staff";
- System.Xml.XmlNode testNode = null;
-
- testResults results = new testResults("Core0022NO");
- results.description = "The nodeName attribute for a DocumentType Node " +
- "should be set to the document type name.";
- //
- // Get the targeted data.
- //
- testNode = util.getDocType();
- //
- // The nodeName attribute should be set to "staff".
- //
- computedValue = testNode.Name;
- //
- // write out results.
- //
- results.expected = expectedValue;
- results.actual = computedValue;
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0022NO ------------------------
- //
- //------------------------- test case core-0023NO -----------------------------
- //
- // Testing feature - The "nodeName" attribute for a DocumentFragment node
- // is "#document-fragment".
- //
- // Testing approach - Retrieve the whole DOM document and invoke its
- // "createDocumentFragment()" method and examine the
- // "nodeName" attribute of the returned node. It should
- // be set to "#document-fragment".
- //
- // Semantic Requirements: 13, 15
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0023NO()
- {
- string computedValue = "";
- string expectedValue = "#document-fragment";
- System.Xml.XmlNode testNode = null;
-
- testResults results = new testResults("Core0023NO");
- results.description = "The nodeName attribute for a DocumentFragment Node "+
- "should be set to \"#document-fragment\".";
- //
- // Get the targeted data.
- //
- testNode = util.getDOMDocument().CreateDocumentFragment();
- //
- // The nodeName attribute should be set to "#document-fragment".
- //
- computedValue = testNode.Name;
- //
- // write out results.
- //
- results.expected = expectedValue;
- results.actual = computedValue;
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0023NO --------------------------
- //
- //------------------------- test case core-0024NO -----------------------------
- //
- // Testing feature - The "nodeName" attribute for a notation node is
- // the name of the notation.
- //
- // Testing approach - Retrieve the Notation declaration inside the
- // DocumentType node and examine its "nodeName"
- // attribute. It should be set to "notation1".
- //
- // Semantic Requirements: 13, 15
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0024NO()
- {
- string computedValue = "";
- string expectedValue = "notation1";
- System.Xml.XmlNode testNode = null;
-
- testResults results = new testResults("Core0024NO");
- try
- {
- results.description = "The nodeName attribute for a Notation Node " +
- "should be set to the notation name.";
- //
- // Get the targeted data.
- //
- testNode = util.getNotation("notation1");
- //
- // The nodeName attribute should be set to "notation1".
- //
- computedValue = testNode.Name;
- }
- catch(System.Exception ex)
- {
- computedValue = "Exception " + ex.Message;
- }
- //
- // write out results.
- //
- results.expected = expectedValue;
- results.actual = computedValue;
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0024NO --------------------------
- //
- //------------------------ test case core-0025NO ----------------------------
- //
- // Testing feature - The "nodeValue" attribute for an Element node is
- // null.
- //
- // Testing approach - Retrieve the root node of the DOM object and check
- // its "nodeValue" attribute. It should be equal
- // to null.
- //
- // Semantic Requirements: 13, 16
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0025NO()
- {
- object computedValue = null;
- object expectedValue = null;
-
- testResults results = new testResults("Core0025NO");
- results.description = "The nodeValue attribute for an Element Node " +
- "should be set to null.";
- //
- // The nodeValue attribute should be set to null.
- //
- computedValue = util.getRootNode().Value;
- //
- // write out results.
- //
- results.expected = (expectedValue == null).ToString();
- results.actual = (computedValue == null).ToString();
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test case core-0025NO --------------------------
- //
- //------------------------- test case core-0026NO -----------------------------
- //
- // Testing feature - The "nodeValue" attribute for an Attribute node is
- // the value of the attribute.
- //
- // Testing approach - Retrieve the attribute named "domestic" from the last
- // child of the first employee. Its "nodeValue" attribute
- // is then checked, it should be set to "Yes".
- //
- // Semantic Requirements: 13, 16
- //
- //----------------------------------------------------------------------------
-
- [Test]
- public void core0026NO()
- {
- string computedValue = "";
- string expectedValue = "Yes";
- System.Xml.XmlElement testNode = null;
- System.Xml.XmlAttribute attrNode = null;
-
- testResults results = new testResults("Core0026NO");
- try
- {
- results.description = "The nodeValue attribute for an Attribute Node " +
- "should be set to the value of the attribute.";
- //
- // Get the targeted data.
- //
- testNode = (System.Xml.XmlElement)util.nodeObject(util.FIRST,util.SIXTH);
- attrNode = testNode.GetAttributeNode("domestic");//.node.
- //
- // The nodeType attribute should be set to "Yes".
- //
- computedValue = attrNode.Value;
- }
- catch(System.Exception ex)
- {
- computedValue = "Exception " + ex.Message;
- }
- //
- // write out results.
- //
- results.expected = expectedValue;
- results.actual = computedValue;
-
- Assert.AreEqual (results.expected, results.actual);
- }
-
- //------------------------ End test ca…
Large files files are truncated, but you can click here to view the full file