2 // HttpParseExceptionCas.cs
3 // - CAS unit tests for System.Web.HttpParseException
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.
32 // Note: class exists in 1.x but has no public ctor
34 using NUnit.Framework;
37 using System.CodeDom.Compiler;
38 using System.Runtime.Serialization;
39 using System.Security;
40 using System.Security.Permissions;
43 namespace MonoCasTests.System.Web {
47 public class HttpParseExceptionCas : AspNetHostingMinimal {
49 private HttpParseException hpe;
52 public void FixtureSetUp ()
54 hpe = new HttpParseException ();
59 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
60 public void Constructor0_Deny_Unrestricted ()
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");
70 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
71 public void Constructor1_Deny_Unrestricted ()
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");
81 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
82 public void Constructor2_Deny_Unrestricted ()
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");
92 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
93 public void Constructor5_Deny_Unrestricted ()
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");
103 [SecurityPermission (SecurityAction.Deny, SerializationFormatter = true)]
104 [ExpectedException (typeof (SecurityException))]
105 public void GetObjectData_Deny_SerializationFormatter ()
107 hpe.GetObjectData (null, new StreamingContext ());
111 [SecurityPermission (SecurityAction.PermitOnly, SerializationFormatter = true)]
112 [ExpectedException (typeof (ArgumentNullException))]
113 public void GetObjectData_PermitOnly_SerializationFormatter ()
115 hpe.GetObjectData (null, new StreamingContext ());
120 public override Type Type {
121 get { return typeof (HttpParseException); }