[corlib] Update ValueTuple implementation
[mono.git] / mcs / class / System.Web.Services / Test / System.Web.Services.Description / WebReferenceOptionsTest.cs
1 //
2 // WebReferenceOptionsTest.cs
3 //
4 // Author:
5 //      Atsushi Enomoto  <atsushi@ximian.com>
6 //
7 // Copyright (C) 2006 Novell, Inc.
8 //
9
10 #if !MOBILE
11
12 using NUnit.Framework;
13
14 using System;
15 using System.IO;
16 using System.Web.Services.Description;
17 using System.Xml;
18 using System.Xml.Schema;
19 using System.Xml.Serialization;
20 using System.Collections;
21
22 namespace MonoTests.System.Web.Services.Description
23 {
24         [TestFixture]
25         public class WebReferenceOptionsTest
26         {
27                 string xml1 = "<webReferenceOptions xmlns='http://microsoft.com/webReference/' />";
28                 string xml2 = @"
29 <webReferenceOptions xmlns='http://microsoft.com/webReference/'>
30   <codeGenerationOptions>properties newAsync</codeGenerationOptions>
31   <style>client</style>
32   <verbose>false</verbose>
33 </webReferenceOptions>
34                 ";
35                 string xml3 = @"
36 <webReferenceOptions xmlns='http://microsoft.com/webReference/'>
37   <gyabo/>
38   <hoge/>
39 </webReferenceOptions>";
40
41                 [Test]
42                 [Category ("NotDotNet")] // why on earth does it allow invalid xml?
43                 public void Schema ()
44                 {
45                         Validate (xml1);
46                         Validate (xml2);
47                         try {
48                                 Validate (xml3);
49                                 Assert.Fail ("xml3 is invalid.");
50                         } catch (XmlSchemaValidationException) {
51                         }
52                 }
53
54                 void Validate (string xml)
55                 {
56                         XmlReaderSettings s = new XmlReaderSettings ();
57                         s.ValidationType = ValidationType.Schema;
58                         s.Schemas.Add (WebReferenceOptions.Schema);
59                         XmlReader r = XmlReader.Create (new StringReader (xml), s);
60                         while (!r.EOF)
61                                 r.Read ();
62                 }
63
64                 [Test]
65                 public void Read ()
66                 {
67                         Read (xml1);
68                         Read (xml2);
69                         try {
70                                 Read (xml3);
71                                 Assert.Fail ("xml3 is invalid.");
72                         } catch (InvalidOperationException) {
73                         }
74                 }
75
76                 void Read (string xml)
77                 {
78                         XmlReader r = XmlReader.Create (new StringReader (xml));
79                         WebReferenceOptions.Read (r, null);
80                 }
81         }
82 }
83
84 #endif