* Makefile: Build the make-map.exe in Mono.Unix.Native; add /nowarn:0618 to
[mono.git] / mcs / class / System.Web / Test / System.Web / HttpParseExceptionCas.cs
1 //
2 // HttpParseExceptionCas.cs 
3 //      - CAS unit tests for System.Web.HttpParseException
4 //
5 // Author:
6 //      Sebastien Pouliot  <sebastien@ximian.com>
7 //
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 // 
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 // 
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30 #if NET_2_0
31
32 // Note: class exists in 1.x but has no public ctor
33
34 using NUnit.Framework;
35
36 using System;
37 using System.CodeDom.Compiler;
38 using System.Runtime.Serialization;
39 using System.Security;
40 using System.Security.Permissions;
41 using System.Web;
42
43 namespace MonoCasTests.System.Web {
44
45         [TestFixture]
46         [Category ("CAS")]
47         public class HttpParseExceptionCas : AspNetHostingMinimal {
48
49                 private HttpParseException hpe;
50
51                 [TestFixtureSetUp]
52                 public void FixtureSetUp ()
53                 {
54                         hpe = new HttpParseException ();
55                 }
56
57
58                 [Test]
59                 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
60                 public void Constructor0_Deny_Unrestricted ()
61                 {
62                         HttpParseException e = new HttpParseException ();
63                         Assert.IsNull (e.FileName, "FileName");
64                         Assert.AreEqual (0, e.Line, "Line");
65                         Assert.IsNull (e.VirtualPath, "VirtualPath");
66                         Assert.AreEqual (1, e.ParserErrors.Count, "ParserErrors");
67                 }
68
69                 [Test]
70                 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
71                 public void Constructor1_Deny_Unrestricted ()
72                 {
73                         HttpParseException e = new HttpParseException ("message");
74                         Assert.IsNull (e.FileName, "FileName");
75                         Assert.AreEqual (0, e.Line, "Line");
76                         Assert.IsNull (e.VirtualPath, "VirtualPath");
77                         Assert.AreEqual (1, e.ParserErrors.Count, "ParserErrors");
78                 }
79
80                 [Test]
81                 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
82                 public void Constructor2_Deny_Unrestricted ()
83                 {
84                         HttpParseException e = new HttpParseException ("message", new Exception ());
85                         Assert.IsNull (e.FileName, "FileName");
86                         Assert.AreEqual (0, e.Line, "Line");
87                         Assert.IsNull (e.VirtualPath, "VirtualPath");
88                         Assert.AreEqual (1, e.ParserErrors.Count, "ParserErrors");
89                 }
90
91                 [Test]
92                 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
93                 public void Constructor5_Deny_Unrestricted ()
94                 {
95                         HttpParseException e = new HttpParseException ("message", new Exception (), "virtualPath", "sourceCode", 100);
96                         Assert.IsNull (e.FileName, "FileName");
97                         Assert.AreEqual (100, e.Line, "Line");
98                         Assert.AreEqual ("virtualPath", e.VirtualPath, "VirtualPath");
99                         Assert.AreEqual (1, e.ParserErrors.Count, "ParserErrors");
100                 }
101
102                 [Test]
103                 [SecurityPermission (SecurityAction.Deny, SerializationFormatter = true)]
104                 [ExpectedException (typeof (SecurityException))]
105                 public void GetObjectData_Deny_SerializationFormatter ()
106                 {
107                         hpe.GetObjectData (null, new StreamingContext ());
108                 }
109
110                 [Test]
111                 [SecurityPermission (SecurityAction.PermitOnly, SerializationFormatter = true)]
112                 [ExpectedException (typeof (ArgumentNullException))]
113                 public void GetObjectData_PermitOnly_SerializationFormatter ()
114                 {
115                         hpe.GetObjectData (null, new StreamingContext ());
116                 }
117
118                 // LinkDemand
119
120                 public override Type Type {
121                         get { return typeof (HttpParseException); }
122                 }
123         }
124 }
125
126 #endif