1 //**************************************************************************
4 // National Institute Of Standards and Technology
7 // DOMImplementation Interface
9 // Written by: Carmelo Montanez
10 // Modified by: Mary Brady
12 // Ported to System.Xml by: Mizrahi Rafael rafim@mainsoft.com
13 // Mainsoft Corporation (c) 2003-2004
14 //**************************************************************************
17 using NUnit.Framework;
19 namespace nist_dom.fundamental
22 /// Summary description for Comment.
25 public class DOMImplementationTest : Assertion
27 public static int i = 2;
29 public testResults[] RunTests()
31 testResults[] tests = new testResults[] {core0001DI(), core0002DI(), core0003DI(),
32 core0004DI(), core0005DI()};
36 //------------------------ test case core-0001DI ------------------------
38 // Testing feature - The "feature" parameter in the
39 // "hasFeature(feature,version)" method is the package
40 // name of the feature. Legal values are HTML and XML.
41 // (test for XML, upper case)
43 // Testing approach - Retrieve the entire DOM document and invoke its
44 // "implementation" attribute. This should create
45 // a DOMImplementation object whose "hasFeature(feature,
46 // version)" method is invoked with feature = "XML". The
47 // method should return a true value.
49 // Semantic Requirements: 1, 2, 4
51 //----------------------------------------------------------------------------
54 public void core0001DI()
56 bool computedValue = false;
57 bool expectedValue = true;
58 System.Xml.XmlDocument testNode = null;
60 testResults results = new testResults("Core0001DI");
62 results.description = "Check for feature = XML in the \"hasFeature(feature,version)\" method.";
64 // Retrieve the targeted data and invoke its "hasFeature(feature,version)".
67 testNode = util.getDOMDocument();
68 computedValue = testNode.Implementation.HasFeature("XML","1.0");
73 results.expected = expectedValue.ToString();
74 results.actual = computedValue.ToString();
76 AssertEquals (results.expected, results.actual);
78 //------------------------ End test case core-0001DI --------------------------
80 //------------------------ test case core-0002DI ------------------------
82 // Testing feature - The "feature" parameter in the
83 // "hasFeature(feature,version)" method is the package
84 // name of the feature. Legal values are HTML and XML.
85 // (test for XML, lower case)
87 // Testing approach - Retrieve the entire DOM document and invoke its
88 // "implementation" attribute. This should create
89 // a DOMImplementation object whose "hasFeature(feature,
90 // version)" method is invoked with feature = "xml". The
91 // method should return a true value.
93 // Semantic Requirements: 1, 2, 4
95 //----------------------------------------------------------------------------
98 public void core0002DI()
100 bool computedValue = false;
101 bool expectedValue = true;
102 System.Xml.XmlDocument testNode = null;
104 testResults results = new testResults("Core0002DI");
106 results.description = "Check for feature = xml in the \"hasFeature(feature,version)\" method.";
108 // Retrieve the targeted data and invoke its "hasFeature(feature,version)".
111 testNode = util.getDOMDocument();
112 computedValue = testNode.Implementation.HasFeature("xml","1.0");
114 // Write out results.
117 results.expected = expectedValue.ToString();
118 results.actual = computedValue.ToString();
120 AssertEquals (results.expected, results.actual);
122 //------------------------ End test case core-0002DI --------------------------
124 //------------------------ test case core-0003DI ------------------------
126 // Testing feature - The "feature" parameter in the
127 // "hasFeature(feature,version)" method is the package
128 // name of the feature. Legal values are HTML and XML.
129 // (test for HTML, upper case)
131 // Testing approach - Retrieve the entire DOM document and invoke its
132 // "implementation" attribute. This should create
133 // a DOMImplementation object whose "hasFeature(feature,
134 // version)" method is invoked with feature = "HTML". The
135 // method should return a true or false value. Since this
136 // is the XML section of the specs, either value for the
137 // HTML feature will be acceptable.
139 // Semantic Requirements: 1, 2, 4, 5
141 //----------------------------------------------------------------------------
144 public void core0003DI()
146 bool computedValue = false;
147 bool expectedValue = false;//(true, false);
148 System.Xml.XmlDocument testNode = null;
150 testResults results = new testResults("Core0003DI");
152 results.description = "Check for feature = HTML in the \"hasFeature(feature,version)\" method.";
154 // Retrieve the targeted data and invoke its "hasFeature(feature,version)".
157 testNode = util.getDOMDocument();
158 computedValue = testNode.Implementation.HasFeature("HTML","1.0");
160 // Write out results.
163 results.expected = expectedValue.ToString();
164 results.actual = computedValue.ToString();
166 AssertEquals (results.expected, results.actual);
168 //------------------------ End test case core-0003DI --------------------------
170 //------------------------ test case core-0004DI ------------------------
172 // Testing feature - The "feature" parameter in the
173 // "hasFeature(feature,version)" method is the package
174 // name of the feature. Legal values are HTML and XML.
175 // (test for HTML, lower case)
177 // Testing approach - Retrieve the entire DOM document and invoke its
178 // "implementation" attribute. This should create
179 // a DOMImplementation object whose "hasFeature(feature,
180 // version)" method is invoked with feature = "html". The
181 // method should return a true or false value. Since this
182 // is the XML section of the specs, either value for the
183 // HTML feature will be acceptable.
185 // Semantic Requirements: 1, 2, 4, 5
187 //----------------------------------------------------------------------------
190 public void core0004DI()
192 bool computedValue = false;
193 bool expectedValue = false;//(true, false);
194 System.Xml.XmlDocument testNode = null;
196 testResults results = new testResults("Core0004DI");
198 results.description = "Check for feature = html in the \"hasFeature(feature,version)\" method.";
200 // Retrieve the targeted data and invoke its "hasFeature(feature,version)".
203 testNode = util.getDOMDocument();
204 computedValue = testNode.Implementation.HasFeature("html","1.0");
206 // Write out results.
208 results.expected = expectedValue.ToString();
209 results.actual = computedValue.ToString();
211 AssertEquals (results.expected, results.actual);
213 //------------------------ End test case core-0004DI --------------------------
215 //------------------------ test case core-0005DI ------------------------
217 // Testing feature - if the The "version" parameter is not specified in the
218 // "hasFeature(feature,version)" method then supporting
219 // any version of the feature will cause the method to
222 // Testing approach - Retrieve the entire DOM document and invoke its
223 // "implementation" attribute. This should create
224 // a DOMImplementation object whose "hasFeature(feature,
225 // version)" method is invoked with version = "". The
226 // method should return a true value for any supported
227 // version of the feature.
229 // Semantic Requirements: 3
231 //----------------------------------------------------------------------------
234 public void core0005DI()
236 bool computedValue = false;
237 bool expectedValue = true;
238 string NullString = null;
239 System.Xml.XmlDocument testNode = null;
241 testResults results = new testResults("Core0005DI");
243 results.description = "Check for version not specified in the " +
244 "\"hasFeature(feature,version)\" method.";
246 // Retrieve the targeted data and invoke its "hasFeature(feature,version)".
249 testNode = util.getDOMDocument();
250 computedValue = testNode.Implementation.HasFeature("XML", NullString);
252 // Write out results.
255 results.expected = expectedValue.ToString();
256 results.actual = computedValue.ToString();
258 AssertEquals (results.expected, results.actual);
260 //------------------------ End test case core-0005DI --------------------------