DOMImplementation.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. //**************************************************************************
  2. //
  3. //
  4. // National Institute Of Standards and Technology
  5. // DTS Version 1.0
  6. //
  7. // DOMImplementation Interface
  8. //
  9. // Written by: Carmelo Montanez
  10. // Modified by: Mary Brady
  11. //
  12. // Ported to System.Xml by: Mizrahi Rafael [email protected]
  13. // Mainsoft Corporation (c) 2003-2004
  14. //**************************************************************************
  15. using System;
  16. using nist_dom;
  17. using NUnit.Framework;
  18. namespace nist_dom.fundamental
  19. {
  20. /// <summary>
  21. /// Summary description for Comment.
  22. /// </summary>
  23. [TestFixture]
  24. public class DOMImplementationTest : Assertion
  25. {
  26. public static int i = 2;
  27. /*
  28. public testResults[] RunTests()
  29. {
  30. testResults[] tests = new testResults[] {core0001DI(), core0002DI(), core0003DI(),
  31. core0004DI(), core0005DI()};
  32. return tests;
  33. }
  34. */
  35. //------------------------ test case core-0001DI ------------------------
  36. //
  37. // Testing feature - The "feature" parameter in the
  38. // "hasFeature(feature,version)" method is the package
  39. // name of the feature. Legal values are HTML and XML.
  40. // (test for XML, upper case)
  41. //
  42. // Testing approach - Retrieve the entire DOM document and invoke its
  43. // "implementation" attribute. This should create
  44. // a DOMImplementation object whose "hasFeature(feature,
  45. // version)" method is invoked with feature = "XML". The
  46. // method should return a true value.
  47. //
  48. // Semantic Requirements: 1, 2, 4
  49. //
  50. //----------------------------------------------------------------------------
  51. [Test]
  52. public void core0001DI()
  53. {
  54. bool computedValue = false;
  55. bool expectedValue = true;
  56. System.Xml.XmlDocument testNode = null;
  57. testResults results = new testResults("Core0001DI");
  58. results.description = "Check for feature = XML in the \"hasFeature(feature,version)\" method.";
  59. //
  60. // Retrieve the targeted data and invoke its "hasFeature(feature,version)".
  61. // method.
  62. //
  63. testNode = util.getDOMDocument();
  64. computedValue = testNode.Implementation.HasFeature("XML","1.0");
  65. //
  66. // Write out results.
  67. //
  68. results.expected = expectedValue.ToString();
  69. results.actual = computedValue.ToString();
  70. AssertEquals (results.expected, results.actual);
  71. }
  72. //------------------------ End test case core-0001DI --------------------------
  73. //
  74. //------------------------ test case core-0002DI ------------------------
  75. //
  76. // Testing feature - The "feature" parameter in the
  77. // "hasFeature(feature,version)" method is the package
  78. // name of the feature. Legal values are HTML and XML.
  79. // (test for XML, lower case)
  80. //
  81. // Testing approach - Retrieve the entire DOM document and invoke its
  82. // "implementation" attribute. This should create
  83. // a DOMImplementation object whose "hasFeature(feature,
  84. // version)" method is invoked with feature = "xml". The
  85. // method should return a true value.
  86. //
  87. // Semantic Requirements: 1, 2, 4
  88. //
  89. //----------------------------------------------------------------------------
  90. [Test]
  91. public void core0002DI()
  92. {
  93. bool computedValue = false;
  94. bool expectedValue = true;
  95. System.Xml.XmlDocument testNode = null;
  96. testResults results = new testResults("Core0002DI");
  97. results.description = "Check for feature = xml in the \"hasFeature(feature,version)\" method.";
  98. //
  99. // Retrieve the targeted data and invoke its "hasFeature(feature,version)".
  100. // method.
  101. //
  102. testNode = util.getDOMDocument();
  103. computedValue = testNode.Implementation.HasFeature("xml","1.0");
  104. //
  105. // Write out results.
  106. //
  107. results.expected = expectedValue.ToString();
  108. results.actual = computedValue.ToString();
  109. AssertEquals (results.expected, results.actual);
  110. }
  111. //------------------------ End test case core-0002DI --------------------------
  112. //
  113. //------------------------ test case core-0003DI ------------------------
  114. //
  115. // Testing feature - The "feature" parameter in the
  116. // "hasFeature(feature,version)" method is the package
  117. // name of the feature. Legal values are HTML and XML.
  118. // (test for HTML, upper case)
  119. //
  120. // Testing approach - Retrieve the entire DOM document and invoke its
  121. // "implementation" attribute. This should create
  122. // a DOMImplementation object whose "hasFeature(feature,
  123. // version)" method is invoked with feature = "HTML". The
  124. // method should return a true or false value. Since this
  125. // is the XML section of the specs, either value for the
  126. // HTML feature will be acceptable.
  127. //
  128. // Semantic Requirements: 1, 2, 4, 5
  129. //
  130. //----------------------------------------------------------------------------
  131. [Test]
  132. public void core0003DI()
  133. {
  134. bool computedValue = false;
  135. bool expectedValue = false;//(true, false);
  136. System.Xml.XmlDocument testNode = null;
  137. testResults results = new testResults("Core0003DI");
  138. results.description = "Check for feature = HTML in the \"hasFeature(feature,version)\" method.";
  139. //
  140. // Retrieve the targeted data and invoke its "hasFeature(feature,version)".
  141. // method.
  142. //
  143. testNode = util.getDOMDocument();
  144. computedValue = testNode.Implementation.HasFeature("HTML","1.0");
  145. //
  146. // Write out results.
  147. //
  148. results.expected = expectedValue.ToString();
  149. results.actual = computedValue.ToString();
  150. AssertEquals (results.expected, results.actual);
  151. }
  152. //------------------------ End test case core-0003DI --------------------------
  153. //
  154. //------------------------ test case core-0004DI ------------------------
  155. //
  156. // Testing feature - The "feature" parameter in the
  157. // "hasFeature(feature,version)" method is the package
  158. // name of the feature. Legal values are HTML and XML.
  159. // (test for HTML, lower case)
  160. //
  161. // Testing approach - Retrieve the entire DOM document and invoke its
  162. // "implementation" attribute. This should create
  163. // a DOMImplementation object whose "hasFeature(feature,
  164. // version)" method is invoked with feature = "html". The
  165. // method should return a true or false value. Since this
  166. // is the XML section of the specs, either value for the
  167. // HTML feature will be acceptable.
  168. //
  169. // Semantic Requirements: 1, 2, 4, 5
  170. //
  171. //----------------------------------------------------------------------------
  172. [Test]
  173. public void core0004DI()
  174. {
  175. bool computedValue = false;
  176. bool expectedValue = false;//(true, false);
  177. System.Xml.XmlDocument testNode = null;
  178. testResults results = new testResults("Core0004DI");
  179. results.description = "Check for feature = html in the \"hasFeature(feature,version)\" method.";
  180. //
  181. // Retrieve the targeted data and invoke its "hasFeature(feature,version)".
  182. // method.
  183. //
  184. testNode = util.getDOMDocument();
  185. computedValue = testNode.Implementation.HasFeature("html","1.0");
  186. //
  187. // Write out results.
  188. //
  189. results.expected = expectedValue.ToString();
  190. results.actual = computedValue.ToString();
  191. AssertEquals (results.expected, results.actual);
  192. }
  193. //------------------------ End test case core-0004DI --------------------------
  194. //
  195. //------------------------ test case core-0005DI ------------------------
  196. //
  197. // Testing feature - if the The "version" parameter is not specified in the
  198. // "hasFeature(feature,version)" method then supporting
  199. // any version of the feature will cause the method to
  200. // return true.
  201. //
  202. // Testing approach - Retrieve the entire DOM document and invoke its
  203. // "implementation" attribute. This should create
  204. // a DOMImplementation object whose "hasFeature(feature,
  205. // version)" method is invoked with version = "". The
  206. // method should return a true value for any supported
  207. // version of the feature.
  208. //
  209. // Semantic Requirements: 3
  210. //
  211. //----------------------------------------------------------------------------
  212. [Test]
  213. public void core0005DI()
  214. {
  215. bool computedValue = false;
  216. bool expectedValue = true;
  217. string NullString = null;
  218. System.Xml.XmlDocument testNode = null;
  219. testResults results = new testResults("Core0005DI");
  220. results.description = "Check for version not specified in the " +
  221. "\"hasFeature(feature,version)\" method.";
  222. //
  223. // Retrieve the targeted data and invoke its "hasFeature(feature,version)".
  224. // method.
  225. //
  226. testNode = util.getDOMDocument();
  227. computedValue = testNode.Implementation.HasFeature("XML", NullString);
  228. //
  229. // Write out results.
  230. //
  231. results.expected = expectedValue.ToString();
  232. results.actual = computedValue.ToString();
  233. AssertEquals (results.expected, results.actual);
  234. }
  235. //------------------------ End test case core-0005DI --------------------------
  236. }
  237. }