File: WebReferenceOptionsTest.cs

package info (click to toggle)
mono 4.6.2.7+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 778,148 kB
  • ctags: 914,052
  • sloc: cs: 5,779,509; xml: 2,773,713; ansic: 432,645; sh: 14,749; makefile: 12,361; perl: 2,488; python: 1,434; cpp: 849; asm: 531; sql: 95; sed: 16; php: 1
file content (84 lines) | stat: -rw-r--r-- 1,771 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// WebReferenceOptionsTest.cs
//
// Author:
//	Atsushi Enomoto  <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc.
//

#if !MOBILE

using NUnit.Framework;

using System;
using System.IO;
using System.Web.Services.Description;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Collections;

namespace MonoTests.System.Web.Services.Description
{
	[TestFixture]
	public class WebReferenceOptionsTest
	{
		string xml1 = "<webReferenceOptions xmlns='http://microsoft.com/webReference/' />";
		string xml2 = @"
<webReferenceOptions xmlns='http://microsoft.com/webReference/'>
  <codeGenerationOptions>properties newAsync</codeGenerationOptions>
  <style>client</style>
  <verbose>false</verbose>
</webReferenceOptions>
		";
		string xml3 = @"
<webReferenceOptions xmlns='http://microsoft.com/webReference/'>
  <gyabo/>
  <hoge/>
</webReferenceOptions>";

		[Test]
		[Category ("NotDotNet")] // why on earth does it allow invalid xml?
		public void Schema ()
		{
			Validate (xml1);
			Validate (xml2);
			try {
				Validate (xml3);
				Assert.Fail ("xml3 is invalid.");
			} catch (XmlSchemaValidationException) {
			}
		}

		void Validate (string xml)
		{
			XmlReaderSettings s = new XmlReaderSettings ();
			s.ValidationType = ValidationType.Schema;
			s.Schemas.Add (WebReferenceOptions.Schema);
			XmlReader r = XmlReader.Create (new StringReader (xml), s);
			while (!r.EOF)
				r.Read ();
		}

		[Test]
		public void Read ()
		{
			Read (xml1);
			Read (xml2);
			try {
				Read (xml3);
				Assert.Fail ("xml3 is invalid.");
			} catch (InvalidOperationException) {
			}
		}

		void Read (string xml)
		{
			XmlReader r = XmlReader.Create (new StringReader (xml));
			WebReferenceOptions.Read (r, null);
		}
	}
}

#endif