2 // HttpBrowserCapabilitiesCas.cs
3 // - CAS unit tests for System.Web.HttpBrowserCapabilities
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.
30 using NUnit.Framework;
33 using System.Security;
34 using System.Security.Permissions;
38 namespace MonoCasTests.System.Web {
40 // note: this[string] is throwing NullReferenceException everywhere
41 // so we "remove" it from action (only for full demands)
42 class BoolHttpBrowserCapabilities : HttpBrowserCapabilities {
44 public override string this [string key] {
45 get { return "true"; }
49 class StringHttpBrowserCapabilities : HttpBrowserCapabilities {
51 public override string this [string key] {
52 get { return String.Empty; }
56 class NumericHttpBrowserCapabilities : HttpBrowserCapabilities {
58 public override string this [string key] {
63 class VersionHttpBrowserCapabilities : HttpBrowserCapabilities {
65 public override string this [string key] {
66 get { return "1.2.3.4"; }
72 public class HttpBrowserCapabilitiesCas : AspNetHostingMinimal {
75 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
76 public void BoolProperties_Deny_Unrestricted ()
78 HttpBrowserCapabilities cap = new BoolHttpBrowserCapabilities ();
79 Assert.IsTrue (cap.ActiveXControls, "ActiveXControls");
80 Assert.IsTrue (cap.AOL, "AOL");
81 Assert.IsTrue (cap.BackgroundSounds, "BackgroundSounds");
82 Assert.IsTrue (cap.Beta, "Beta");
83 Assert.IsTrue (cap.CDF, "CDF");
84 Assert.IsTrue (cap.Cookies, "Cookies");
85 Assert.IsTrue (cap.Crawler, "Crawler");
86 Assert.IsTrue (cap.Frames, "Frames");
87 Assert.IsTrue (cap.JavaApplets, "JavaApplets");
88 Assert.IsTrue (cap.JavaScript, "JavaScript");
89 Assert.IsTrue (cap.Tables, "Tables");
90 Assert.IsTrue (cap.VBScript, "VBScript");
91 Assert.IsTrue (cap.Win16, "Win16");
92 Assert.IsTrue (cap.Win32, "Win32");
96 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
97 public void StringProperties_Deny_Unrestricted ()
99 HttpBrowserCapabilities cap = new StringHttpBrowserCapabilities ();
100 Assert.IsNotNull (cap.Browser, "Browser");
102 Assert.IsNull (cap.Browsers, "Browsers");
104 Assert.IsNotNull (cap.Platform, "Platform");
105 Assert.IsNotNull (cap.Type, "Type");
106 Assert.IsNotNull (cap.Version, "Version");
110 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
111 public void TypeProperties_Deny_Unrestricted ()
113 HttpBrowserCapabilities cap = new StringHttpBrowserCapabilities ();
114 Assert.IsNull (cap.TagWriter, "TagWriter");
118 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
119 public void NumericProperties_Deny_Unrestricted ()
121 HttpBrowserCapabilities cap = new NumericHttpBrowserCapabilities ();
123 Assert.AreEqual (1, cap.MajorVersion, "MajorVersion");
125 Assert.AreEqual (1, cap.MinorVersion, "MinorVersion");
129 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
130 public void VersionProperties_Deny_Unrestricted ()
132 HttpBrowserCapabilities cap = new VersionHttpBrowserCapabilities ();
133 Assert.IsNotNull (cap.ClrVersion, "ClrVersion");
134 Assert.IsNotNull (cap.EcmaScriptVersion, "EcmaScriptVersion");
135 Assert.IsNotNull (cap.MSDomVersion, "MSDomVersion");
136 Assert.IsNotNull (cap.W3CDomVersion, "W3CDomVersion");
140 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
141 public void GetClrVersions_Deny_Unrestricted ()
143 HttpBrowserCapabilities cap = new StringHttpBrowserCapabilities ();
145 Assert.IsNull (cap.GetClrVersions (), "GetClrVersions");
147 Version[] versions = cap.GetClrVersions ();
148 Assert.AreEqual (1, versions.Length, "GetClrVersions");
149 Assert.AreEqual ("0.0", versions [0].ToString (), "Version[0]");
155 public override Type Type {
156 get { return typeof (HttpBrowserCapabilities); }