2009-06-12 Bill Holmes <billholmes54@gmail.com>
[mono.git] / mcs / class / System.XML / Test / System.Xml / nist_dom / fundamental / DOMImplementation / DOMImplementation.cs
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 rafim@mainsoft.com
13 // Mainsoft Corporation (c) 2003-2004
14 //**************************************************************************
15 using System;
16 using nist_dom;
17 using NUnit.Framework;
18
19 namespace nist_dom.fundamental
20 {
21     /// <summary>
22     /// Summary description for Comment.
23     /// </summary>
24     [TestFixture]
25     public class DOMImplementationTest : Assertion
26     {
27         public static int i = 2;
28 /*
29         public testResults[] RunTests()
30         {
31             testResults[] tests = new testResults[] {core0001DI(), core0002DI(), core0003DI(),
32                                                         core0004DI(), core0005DI()};
33             return tests;
34         }
35 */
36         //------------------------ test case core-0001DI ------------------------
37         //
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)
42         //
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. 
48         //
49         // Semantic Requirements: 1, 2, 4
50         //
51         //----------------------------------------------------------------------------
52
53         [Test]
54         public void core0001DI()
55         {
56             bool computedValue = false;
57             bool expectedValue = true;
58             System.Xml.XmlDocument testNode = null;
59
60             testResults results = new testResults("Core0001DI");
61
62             results.description = "Check for feature = XML in the \"hasFeature(feature,version)\" method."; 
63             //
64             // Retrieve the targeted data and invoke its "hasFeature(feature,version)".
65             // method.
66             //
67             testNode = util.getDOMDocument();
68             computedValue = testNode.Implementation.HasFeature("XML","1.0");
69             //
70             // Write out results.
71             //
72
73             results.expected = expectedValue.ToString();
74             results.actual = computedValue.ToString();
75
76             AssertEquals (results.expected, results.actual);
77         }
78         //------------------------ End test case core-0001DI --------------------------
79         //
80         //------------------------ test case core-0002DI ------------------------
81         //
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)
86         //
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.
92         //
93         // Semantic Requirements: 1, 2, 4
94         //
95         //----------------------------------------------------------------------------
96
97         [Test]
98         public void core0002DI()
99         {
100             bool computedValue = false;
101             bool expectedValue = true;
102             System.Xml.XmlDocument testNode = null;
103
104             testResults results = new testResults("Core0002DI");
105
106             results.description = "Check for feature = xml in the \"hasFeature(feature,version)\" method."; 
107             //
108             // Retrieve the targeted data and invoke its "hasFeature(feature,version)".
109             // method.
110             //
111             testNode = util.getDOMDocument();
112             computedValue = testNode.Implementation.HasFeature("xml","1.0");
113             //
114             // Write out results.
115             //
116
117             results.expected = expectedValue.ToString();
118             results.actual = computedValue.ToString();
119
120             AssertEquals (results.expected, results.actual);
121         }
122         //------------------------ End test case core-0002DI --------------------------
123         //
124         //------------------------ test case core-0003DI ------------------------
125         //
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)
130         //
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.
138         //
139         // Semantic Requirements: 1, 2, 4, 5
140         //
141         //----------------------------------------------------------------------------
142
143         [Test]
144         public void core0003DI()
145         {
146             bool computedValue = false;
147             bool expectedValue = false;//(true, false);
148             System.Xml.XmlDocument testNode = null;
149
150             testResults results = new testResults("Core0003DI");
151
152             results.description = "Check for feature = HTML in the \"hasFeature(feature,version)\" method."; 
153             //
154             // Retrieve the targeted data and invoke its "hasFeature(feature,version)".
155             // method.
156             //
157             testNode = util.getDOMDocument();
158             computedValue = testNode.Implementation.HasFeature("HTML","1.0");
159             //
160             // Write out results.
161             //
162
163             results.expected = expectedValue.ToString();
164             results.actual = computedValue.ToString();
165
166             AssertEquals (results.expected, results.actual);
167         }
168         //------------------------ End test case core-0003DI --------------------------
169         //
170         //------------------------ test case core-0004DI ------------------------
171         //
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)
176         //
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.
184         //
185         // Semantic Requirements: 1, 2, 4, 5
186         //
187         //----------------------------------------------------------------------------
188
189         [Test]
190         public void core0004DI()
191         {
192             bool computedValue = false;
193             bool expectedValue = false;//(true, false);
194             System.Xml.XmlDocument testNode = null;
195
196             testResults results = new testResults("Core0004DI");
197
198             results.description = "Check for feature = html in the \"hasFeature(feature,version)\" method."; 
199             //
200             // Retrieve the targeted data and invoke its "hasFeature(feature,version)".
201             // method.
202             //
203             testNode = util.getDOMDocument();
204             computedValue = testNode.Implementation.HasFeature("html","1.0");
205             //
206             // Write out results.
207             //
208             results.expected = expectedValue.ToString();
209             results.actual = computedValue.ToString();
210
211             AssertEquals (results.expected, results.actual);
212         }
213         //------------------------ End test case core-0004DI --------------------------
214         //
215         //------------------------ test case core-0005DI ------------------------
216         //
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 
220         //                   return true.
221         //
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.
228         //
229         // Semantic Requirements: 3
230         //
231         //----------------------------------------------------------------------------
232
233         [Test]
234         public void core0005DI()
235         {
236             bool computedValue = false;
237             bool expectedValue = true;
238             string NullString = null;
239             System.Xml.XmlDocument testNode = null;
240
241             testResults results = new testResults("Core0005DI");
242
243             results.description = "Check for version not specified in the " +
244                 "\"hasFeature(feature,version)\" method."; 
245             //
246             // Retrieve the targeted data and invoke its "hasFeature(feature,version)".
247             // method.
248             //
249             testNode = util.getDOMDocument();
250             computedValue = testNode.Implementation.HasFeature("XML", NullString);
251             //
252             // Write out results.
253             //
254
255             results.expected = expectedValue.ToString();
256             results.actual = computedValue.ToString();
257
258             AssertEquals (results.expected, results.actual);
259         }
260         //------------------------ End test case core-0005DI --------------------------
261     }
262
263 }