[bcl] Remove more NET_2_0 checks from class libs
[mono.git] / mcs / class / System.Web / Test / System.Web / HttpCompileExceptionCas.cs
1 //
2 // HttpCompileExceptionCas.cs 
3 //      - CAS unit tests for System.Web.HttpCompileException
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
31 // Note: class exists in 1.x but has no public ctor
32
33 using NUnit.Framework;
34
35 using System;
36 using System.CodeDom.Compiler;
37 using System.Runtime.Serialization;
38 using System.Security;
39 using System.Security.Permissions;
40 using System.Web;
41
42 namespace MonoCasTests.System.Web {
43
44         [TestFixture]
45         [Category ("CAS")]
46         public class HttpCompileExceptionCas : AspNetHostingMinimal {
47
48                 private HttpCompileException hce;
49
50                 [TestFixtureSetUp]
51                 public void FixtureSetUp ()
52                 {
53                         hce = new HttpCompileException ();
54                 }
55
56
57                 [Test]
58                 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
59                 public void Constructor0_Deny_Unrestricted ()
60                 {
61                         HttpCompileException e = new HttpCompileException ();
62                         Assert.IsNotNull (e.Message, "Message");
63                 }
64
65                 [Test]
66                 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
67                 public void Constructor1_Deny_Unrestricted ()
68                 {
69                         HttpCompileException e = new HttpCompileException ("message");
70                         Assert.IsNotNull (e.Message, "Message");
71                 }
72
73                 [Test]
74                 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
75                 public void Constructor2a_Deny_Unrestricted ()
76                 {
77                         HttpCompileException e = new HttpCompileException (new CompilerResults (null), "source");
78                         Assert.IsNotNull (e.Message, "Message");
79                 }
80
81                 [Test]
82                 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
83                 public void Constructor2b_Deny_Unrestricted ()
84                 {
85                         HttpCompileException e = new HttpCompileException ("message", new Exception ());
86                         Assert.IsNotNull (e.Message, "Message");
87                 }
88
89
90                 [Test]
91                 [AspNetHostingPermission (SecurityAction.Deny, Level = AspNetHostingPermissionLevel.High)]
92                 [ExpectedException (typeof (SecurityException))]
93                 public void Results_Deny_High ()
94                 {
95                         Assert.IsNull (hce.Results, "Results");
96                 }
97
98                 [Test]
99                 [AspNetHostingPermission (SecurityAction.PermitOnly, Level = AspNetHostingPermissionLevel.High)]
100                 public void Results_PermitOnly_High ()
101                 {
102                         Assert.IsNull (hce.Results, "Results");
103                 }
104
105                 [Test]
106                 [AspNetHostingPermission (SecurityAction.Deny, Level = AspNetHostingPermissionLevel.High)]
107                 [ExpectedException (typeof (SecurityException))]
108                 public void SourceCode_Deny_High ()
109                 {
110                         Assert.IsNull (hce.SourceCode, "SourceCode");
111                 }
112
113                 [Test]
114                 [AspNetHostingPermission (SecurityAction.PermitOnly, Level = AspNetHostingPermissionLevel.High)]
115                 public void SourceCode_PermitOnly_High ()
116                 {
117                         Assert.IsNull (hce.SourceCode, "SourceCode");
118                 }
119
120                 [Test]
121                 [SecurityPermission (SecurityAction.Deny, SerializationFormatter = true)]
122                 [ExpectedException (typeof (SecurityException))]
123                 public void GetObjectData_Deny_SerializationFormatter ()
124                 {
125                         hce.GetObjectData (null, new StreamingContext ());
126                 }
127
128                 [Test]
129                 [SecurityPermission (SecurityAction.PermitOnly, SerializationFormatter = true)]
130                 [ExpectedException (typeof (ArgumentNullException))]
131                 public void GetObjectData_PermitOnly_SerializationFormatter ()
132                 {
133                         hce.GetObjectData (null, new StreamingContext ());
134                 }
135
136                 // LinkDemand
137
138                 public override Type Type {
139                         get { return typeof (HttpCompileException); }
140                 }
141         }
142 }
143