[bcl] Remove more NET_2_0 checks from class libs
[mono.git] / mcs / class / System / Test / System / UriCas.cs
1 //
2 // UriCas.cs - CAS unit tests for System.Uri
3 //
4 // Author:
5 //      Sebastien Pouliot  <sebastien@ximian.com>
6 //
7 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28
29 using NUnit.Framework;
30
31 using System;
32 using System.Reflection;
33 using System.Security;
34 using System.Security.Permissions;
35
36 using MonoTests.System;
37
38 namespace MonoCasTests.System {
39
40         [TestFixture]
41         [Category ("CAS")]
42         public class UriCas {
43
44                 [SetUp]
45                 public virtual void SetUp ()
46                 {
47                         if (!SecurityManager.SecurityEnabled)
48                                 Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
49                 }
50
51                 [Test]
52                 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
53                 public void UnitTestReuse ()
54                 {
55                         UriTest unit = new UriTest ();
56                         unit.GetReady ();
57
58                         unit.Constructors ();
59                         unit.Constructor_DualHostPort ();
60                         unit.RelativeCtor ();
61                         unit.LeadingSlashes ();
62                         unit.ConstructorsRejectRelativePath ();
63                         unit.LocalPath ();
64                         unit.LocalPath_FileHost ();
65                         unit.LocalPath_Escape ();
66                         unit.UnixPath ();
67                         unit.Unc ();
68                         unit.FromHex ();
69                         unit.Unescape ();
70                         unit.HexEscape ();
71                         unit.HexUnescape ();
72                         unit.IsHexDigit ();
73                         unit.IsHexEncoding ();
74                         unit.GetLeftPart ();
75                         unit.NewsDefaultPort ();
76                         unit.FragmentEscape ();
77                         unit.CheckHostName2 ();
78                         unit.IsLoopback ();
79                         unit.Equals1 ();
80                         unit.TestEquals2 ();
81                         unit.CaseSensitivity ();
82                         unit.GetHashCodeTest ();
83                         unit.MakeRelative ();
84                         unit.RelativeUri ();
85                         unit.ToStringTest ();
86                         unit.CheckSchemeName ();
87                         unit.CheckSchemeName_FirstChar ();
88                         unit.CheckSchemeName_AnyOtherChar ();
89                         unit.Segments1 ();
90                         unit.Segments2 ();
91                         unit.Segments3 ();
92                         unit.Segments5 ();
93                         unit.UnixLocalPath ();
94                         unit.PortMax ();
95                 }
96
97                 [Test]
98                 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
99                 [Category ("NotDotNet")] // tests needs to be updated for 2.0
100                 public void UnitTest2Reuse ()
101                 {
102                         UriTest2 unit = new UriTest2 ();
103                         unit.AbsoluteUriFromFile ();
104                         unit.RelativeUriFromFile ();
105                         unit.MoreUnescape ();
106                         unit.UriScheme ();
107                 }
108                 [Test]
109                 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
110                 [Category ("NotWorking")]
111                 public void UnitTest3Reuse ()
112                 {
113                         UriTest3 unit = new UriTest3 ();
114                         unit.Absolute_UriKind_Absolute ();
115                         unit.Relative_UriKind_Relative ();
116                         unit.TryCreate_String_UriKind_Uri ();
117                         unit.TryCreate_Uri_String_Uri ();
118                         unit.TryCreate_Uri_Uri_Uri ();
119                 }
120                 [Test]
121                 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
122                 public void LinkDemand_Deny_Unrestricted ()
123                 {
124                         Type[] types = new Type[1] { typeof (string) };
125                         ConstructorInfo ci = typeof (Uri).GetConstructor (types);
126                         Assert.IsNotNull (ci, ".ctor(string)");
127                         Assert.IsNotNull (ci.Invoke (new object[1] { "http://www.mono-project.com/" }), "invoke");
128                 }
129         }
130 }