2 // HttpCompileExceptionCas.cs
3 // - CAS unit tests for System.Web.HttpCompileException
6 // Sebastien Pouliot <sebastien@ximian.com>
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
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:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
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.
31 // Note: class exists in 1.x but has no public ctor
33 using NUnit.Framework;
36 using System.CodeDom.Compiler;
37 using System.Runtime.Serialization;
38 using System.Security;
39 using System.Security.Permissions;
42 namespace MonoCasTests.System.Web {
46 public class HttpCompileExceptionCas : AspNetHostingMinimal {
48 private HttpCompileException hce;
51 public void FixtureSetUp ()
53 hce = new HttpCompileException ();
58 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
59 public void Constructor0_Deny_Unrestricted ()
61 HttpCompileException e = new HttpCompileException ();
62 Assert.IsNotNull (e.Message, "Message");
66 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
67 public void Constructor1_Deny_Unrestricted ()
69 HttpCompileException e = new HttpCompileException ("message");
70 Assert.IsNotNull (e.Message, "Message");
74 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
75 public void Constructor2a_Deny_Unrestricted ()
77 HttpCompileException e = new HttpCompileException (new CompilerResults (null), "source");
78 Assert.IsNotNull (e.Message, "Message");
82 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
83 public void Constructor2b_Deny_Unrestricted ()
85 HttpCompileException e = new HttpCompileException ("message", new Exception ());
86 Assert.IsNotNull (e.Message, "Message");
91 [AspNetHostingPermission (SecurityAction.Deny, Level = AspNetHostingPermissionLevel.High)]
92 [ExpectedException (typeof (SecurityException))]
93 public void Results_Deny_High ()
95 Assert.IsNull (hce.Results, "Results");
99 [AspNetHostingPermission (SecurityAction.PermitOnly, Level = AspNetHostingPermissionLevel.High)]
100 public void Results_PermitOnly_High ()
102 Assert.IsNull (hce.Results, "Results");
106 [AspNetHostingPermission (SecurityAction.Deny, Level = AspNetHostingPermissionLevel.High)]
107 [ExpectedException (typeof (SecurityException))]
108 public void SourceCode_Deny_High ()
110 Assert.IsNull (hce.SourceCode, "SourceCode");
114 [AspNetHostingPermission (SecurityAction.PermitOnly, Level = AspNetHostingPermissionLevel.High)]
115 public void SourceCode_PermitOnly_High ()
117 Assert.IsNull (hce.SourceCode, "SourceCode");
121 [SecurityPermission (SecurityAction.Deny, SerializationFormatter = true)]
122 [ExpectedException (typeof (SecurityException))]
123 public void GetObjectData_Deny_SerializationFormatter ()
125 hce.GetObjectData (null, new StreamingContext ());
129 [SecurityPermission (SecurityAction.PermitOnly, SerializationFormatter = true)]
130 [ExpectedException (typeof (ArgumentNullException))]
131 public void GetObjectData_PermitOnly_SerializationFormatter ()
133 hce.GetObjectData (null, new StreamingContext ());
138 public override Type Type {
139 get { return typeof (HttpCompileException); }