Author: spouliot
Date: 2005-10-31 20:31:01 -0500 (Mon, 31 Oct 2005)
New Revision: 52432

Added:
   trunk/mcs/class/corlib/Test/System.Runtime.Versioning/
   trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ChangeLog
   
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceConsumptionAttributeCas.cs
   
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceConsumptionAttributeTest.cs
   
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceExposureAttributeCas.cs
   
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceExposureAttributeTest.cs
   trunk/mcs/class/corlib/Test/System.Runtime.Versioning/VersioningHelperCas.cs
   trunk/mcs/class/corlib/Test/System.Runtime.Versioning/VersioningHelperTest.cs
Log:
2005-10-31  Sebastien Pouliot  <[EMAIL PROTECTED]> 

        * ResourceConsumptionAttributeCas.cs: New. CAS unit tests.
        * ResourceConsumptionAttributeTest.cs: New. Unit tests.
        * ResourceExposureAttributeCas.cs: New. CAS unit tests.
        * ResourceExposureAttributeTest.cs
        * VersioningHelperCas.cs: New. CAS unit tests.
        * VersioningHelperTest.cs


Added: trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ChangeLog     
2005-11-01 01:06:01 UTC (rev 52431)
+++ trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ChangeLog     
2005-11-01 01:31:01 UTC (rev 52432)
@@ -0,0 +1,8 @@
+2005-10-31  Sebastien Pouliot  <[EMAIL PROTECTED]> 
+
+       * ResourceConsumptionAttributeCas.cs: New. CAS unit tests.
+       * ResourceConsumptionAttributeTest.cs: New. Unit tests.
+       * ResourceExposureAttributeCas.cs: New. CAS unit tests.
+       * ResourceExposureAttributeTest.cs
+       * VersioningHelperCas.cs: New. CAS unit tests.
+       * VersioningHelperTest.cs


Property changes on: 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ChangeLog
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceConsumptionAttributeCas.cs
===================================================================
--- 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceConsumptionAttributeCas.cs
    2005-11-01 01:06:01 UTC (rev 52431)
+++ 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceConsumptionAttributeCas.cs
    2005-11-01 01:31:01 UTC (rev 52432)
@@ -0,0 +1,77 @@
+//
+// ResourceConsumptionAttributeCas.cs - CAS unit tests for 
+//     System.Runtime.Versioning.ResourceConsumptionAttribute
+//
+// Author:
+//      Sebastien Pouliot  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Reflection;
+using System.Runtime.Versioning;
+using System.Security;
+using System.Security.Permissions;
+
+using NUnit.Framework;
+using MonoTests.System.Runtime.Versioning;
+
+namespace MonoCasTests.System.Runtime.Versioning {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class ResourceConsumptionAttributeCas {
+
+               [SetUp]
+               public virtual void SetUp ()
+               {
+                       if (!SecurityManager.SecurityEnabled)
+                               Assert.Ignore ("SecurityManager.SecurityEnabled 
is OFF");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void ReuseUnitTest ()
+               {
+                       ResourceConsumptionAttributeTest unit = new 
ResourceConsumptionAttributeTest ();
+                       unit.Constructor1 ();
+                       unit.Constructor2 ();
+                       unit.InvalidResourceScope1 ();
+                       unit.InvalidResourceScope2 ();
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void LinkDemand_Deny_Unrestricted ()
+               {
+                       Type[] types = new Type[1] { typeof (ResourceScope) };
+                       ConstructorInfo ci = typeof 
(ResourceConsumptionAttribute).GetConstructor (types);
+                       Assert.IsNotNull (ci, ".ctor(ResourceScope)");
+                       Assert.IsNotNull (ci.Invoke (new object[1] { 
ResourceScope.None }), "invoke");
+               }
+       }
+}
+
+#endif


Property changes on: 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceConsumptionAttributeCas.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceConsumptionAttributeTest.cs
===================================================================
--- 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceConsumptionAttributeTest.cs
   2005-11-01 01:06:01 UTC (rev 52431)
+++ 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceConsumptionAttributeTest.cs
   2005-11-01 01:31:01 UTC (rev 52432)
@@ -0,0 +1,90 @@
+//
+// ResourceConsumptionAttributeTest.cs - Unit tests for 
+//     System.Runtime.Versioning.ResourceConsumptionAttribute
+//
+// Author:
+//      Sebastien Pouliot  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Runtime.Versioning;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Runtime.Versioning {
+
+       [TestFixture]
+       public class ResourceConsumptionAttributeTest {
+
+               [Test]
+               public void Constructor1 ()
+               {
+                       ResourceConsumptionAttribute rca = null;
+                       Array values = Enum.GetValues (typeof (ResourceScope));
+                       foreach (ResourceScope resource in values) {
+                               rca = new ResourceConsumptionAttribute 
(resource);
+                               string id = String.Format ("[{0}]", resource);
+                               Assert.AreEqual (resource, rca.ResourceScope, 
"ResourceScope-" + id);
+                               Assert.AreEqual (resource, 
rca.ConsumptionScope, "ConsumptionScope-" + id);
+                       }
+               }
+
+               [Test]
+               public void Constructor2 ()
+               {
+                       ResourceConsumptionAttribute rca = null;
+                       Array values = Enum.GetValues (typeof (ResourceScope));
+                       foreach (ResourceScope resource in values) {
+                               foreach (ResourceScope consumption in values) {
+                                       rca = new ResourceConsumptionAttribute 
(resource, consumption);
+                                       string id = String.Format ("[{0}-{1}]", 
resource, consumption);
+                                       Assert.AreEqual (resource, 
rca.ResourceScope, "ResourceScope-" + id);
+                                       Assert.AreEqual (consumption, 
rca.ConsumptionScope, "ConsumptionScope-" + id);
+                               }
+                       }
+               }
+
+               [Test]
+               public void InvalidResourceScope1 ()
+               {
+                       ResourceScope bad = (ResourceScope) Int32.MinValue;
+                       ResourceConsumptionAttribute rca = new 
ResourceConsumptionAttribute (bad);
+                       Assert.AreEqual (bad, rca.ResourceScope, 
"ResourceScope");
+                       Assert.AreEqual (bad, rca.ConsumptionScope, 
"ConsumptionScope");
+               }
+
+               [Test]
+               public void InvalidResourceScope2 ()
+               {
+                       ResourceScope bad = (ResourceScope) Int32.MinValue;
+                       ResourceConsumptionAttribute rca = new 
ResourceConsumptionAttribute (ResourceScope.None, bad);
+                       Assert.AreEqual (ResourceScope.None, rca.ResourceScope, 
"ResourceScope");
+                       Assert.AreEqual (bad, rca.ConsumptionScope, 
"ConsumptionScope");
+               }
+       }
+}
+
+#endif


Property changes on: 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceConsumptionAttributeTest.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceExposureAttributeCas.cs
===================================================================
--- 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceExposureAttributeCas.cs
       2005-11-01 01:06:01 UTC (rev 52431)
+++ 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceExposureAttributeCas.cs
       2005-11-01 01:31:01 UTC (rev 52432)
@@ -0,0 +1,75 @@
+//
+// ResourceExposureAttributeCas.cs - CAS unit tests for 
+//     System.Runtime.Versioning.ResourceExposureAttribute
+//
+// Author:
+//      Sebastien Pouliot  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Reflection;
+using System.Runtime.Versioning;
+using System.Security;
+using System.Security.Permissions;
+
+using NUnit.Framework;
+using MonoTests.System.Runtime.Versioning;
+
+namespace MonoCasTests.System.Runtime.Versioning {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class ResourceExposureAttributeCas {
+
+               [SetUp]
+               public virtual void SetUp ()
+               {
+                       if (!SecurityManager.SecurityEnabled)
+                               Assert.Ignore ("SecurityManager.SecurityEnabled 
is OFF");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void ReuseUnitTest ()
+               {
+                       ResourceExposureAttributeTest unit = new 
ResourceExposureAttributeTest ();
+                       unit.Constructor1 ();
+                       unit.InvalidResourceScope1 ();
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void LinkDemand_Deny_Unrestricted ()
+               {
+                       Type[] types = new Type[1] { typeof (ResourceScope) };
+                       ConstructorInfo ci = typeof 
(ResourceExposureAttribute).GetConstructor (types);
+                       Assert.IsNotNull (ci, ".ctor(ResourceScope)");
+                       Assert.IsNotNull (ci.Invoke (new object[1] { 
ResourceScope.None }), "invoke");
+               }
+       }
+}
+
+#endif


Property changes on: 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceExposureAttributeCas.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceExposureAttributeTest.cs
===================================================================
--- 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceExposureAttributeTest.cs
      2005-11-01 01:06:01 UTC (rev 52431)
+++ 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceExposureAttributeTest.cs
      2005-11-01 01:31:01 UTC (rev 52432)
@@ -0,0 +1,63 @@
+//
+// ResourceExposureAttributeTest.cs - Unit tests for 
+//     System.Runtime.Versioning.ResourceExposureAttribute
+//
+// Author:
+//      Sebastien Pouliot  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Runtime.Versioning;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Runtime.Versioning {
+
+       [TestFixture]
+       public class ResourceExposureAttributeTest {
+
+               [Test]
+               public void Constructor1 ()
+               {
+                       ResourceExposureAttribute rea = null;
+                       Array values = Enum.GetValues (typeof (ResourceScope));
+                       foreach (ResourceScope resource in values) {
+                               rea = new ResourceExposureAttribute (resource);
+                               Assert.AreEqual (resource, 
rea.ResourceExposureLevel, resource.ToString ());
+                       }
+               }
+
+               [Test]
+               public void InvalidResourceScope1 ()
+               {
+                       ResourceScope bad = (ResourceScope) Int32.MinValue;
+                       ResourceExposureAttribute rea = new 
ResourceExposureAttribute (bad);
+                       Assert.AreEqual (bad, rea.ResourceExposureLevel, 
"ResourceScope");
+               }
+       }
+}
+
+#endif


Property changes on: 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/ResourceExposureAttributeTest.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/VersioningHelperCas.cs
===================================================================
--- 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/VersioningHelperCas.cs    
    2005-11-01 01:06:01 UTC (rev 52431)
+++ 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/VersioningHelperCas.cs    
    2005-11-01 01:31:01 UTC (rev 52432)
@@ -0,0 +1,79 @@
+//
+// VersioningHelperCas.cs - CAS unit tests for 
+//     System.Runtime.Versioning.VersioningHelper
+//
+// Author:
+//      Sebastien Pouliot  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Reflection;
+using System.Runtime.Versioning;
+using System.Security;
+using System.Security.Permissions;
+
+using NUnit.Framework;
+using MonoTests.System.Runtime.Versioning;
+
+namespace MonoCasTests.System.Runtime.Versioning {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class VersioningHelperCas {
+
+               [SetUp]
+               public virtual void SetUp ()
+               {
+                       if (!SecurityManager.SecurityEnabled)
+                               Assert.Ignore ("SecurityManager.SecurityEnabled 
is OFF");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void ReuseUnitTest ()
+               {
+                       VersioningHelperTest unit = new VersioningHelperTest ();
+                       unit.Name_Null ();
+                       unit.Type_Null ();
+                       unit.MakeVersionSafeName ();
+                       unit.ConvertTo_AppDomain ();
+                       unit.ConvertTo_Process ();
+                       unit.ConvertTo_AppDomain_Process ();
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void LinkDemand_Deny_Unrestricted ()
+               {
+                       Type[] types = new Type[3] { typeof (string), typeof 
(ResourceScope), typeof (ResourceScope) };
+                       MethodInfo mi = typeof (VersioningHelper).GetMethod 
("MakeVersionSafeName", types);
+                       Assert.IsNotNull (mi, 
"MakeVersionSafeName(string,ResourceScope,ResourceScope)");
+                       Assert.AreEqual (String.Empty, mi.Invoke (null, new 
object[3] { null, ResourceScope.AppDomain, ResourceScope.AppDomain }), 
"invoke");
+               }
+       }
+}
+
+#endif


Property changes on: 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/VersioningHelperCas.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/VersioningHelperTest.cs
===================================================================
--- 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/VersioningHelperTest.cs   
    2005-11-01 01:06:01 UTC (rev 52431)
+++ 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/VersioningHelperTest.cs   
    2005-11-01 01:31:01 UTC (rev 52432)
@@ -0,0 +1,162 @@
+//
+// VersioningHelperTest.cs -
+//     Unit tests for System.Runtime.Versioning.VersioningHelper
+//
+// Author:
+//      Sebastien Pouliot  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Runtime.Versioning;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Runtime.Versioning {
+
+       [TestFixture]
+       public class VersioningHelperTest {
+
+               [Test]
+               public void Name_Null ()
+               {
+                       string s = VersioningHelper.MakeVersionSafeName (null, 
ResourceScope.AppDomain, ResourceScope.AppDomain);
+                       Assert.AreEqual (String.Empty, s, "Result");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void From_Invalid ()
+               {
+                       ResourceScope bad = (ResourceScope) Int32.MinValue;
+                       string s = VersioningHelper.MakeVersionSafeName (null, 
bad, ResourceScope.None);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void To_Invalid ()
+               {
+                       ResourceScope bad = (ResourceScope) Int32.MinValue;
+                       string s = VersioningHelper.MakeVersionSafeName (null, 
ResourceScope.AppDomain, bad);
+               }
+
+               [Test]
+               public void Type_Null ()
+               {
+                       string s = VersioningHelper.MakeVersionSafeName (null, 
ResourceScope.AppDomain, ResourceScope.AppDomain, null);
+                       Assert.AreEqual (String.Empty, s, "Result");
+               }
+
+               // ResourceScope is encoded 6 bits for "from" and 6 bits for 
"to"
+               static int[] ValidValues = { 65, 66, 68, 130, 131, 132, 133, 
134, 135, 136, 137, 138, 139, 140, 141, 142, 
+                       143, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 
270, 271, 1089, 1090, 1092, 1105, 1106, 
+                       1108, 1121, 1122, 1124, 1137, 1138, 1140, 1154, 1155, 
1156, 1157, 1158, 1159, 1160, 1161, 1162,
+                       1163, 1164, 1165, 1166, 1167, 1170, 1171, 1172, 1173, 
1174, 1175, 1176, 1177, 1178, 1179, 1180,
+                       1181, 1182, 1183, 1186, 1187, 1188, 1189, 1190, 1191, 
1192, 1193, 1194, 1195, 1196, 1197, 1198,
+                       1199, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 
1210, 1211, 1212, 1213, 1214, 1215, 1284,
+                       1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 
1294, 1295, 1300, 1301, 1302, 1303, 1304,
+                       1305, 1306, 1307, 1308, 1309, 1310, 1311, 1316, 1317, 
1318, 1319, 1320, 1321, 1322, 1323, 1324, 
+                       1325, 1326, 1327, 1332, 1333, 1334, 1335, 1336, 1337, 
1338, 1339, 1340, 1341, 1342, 1343, 2113, 
+                       2114, 2116, 2145, 2146, 2148, 2178, 2179, 2180, 2181, 
2182, 2183, 2184, 2185, 2186, 2187, 2188, 
+                       2189, 2190, 2191, 2210, 2211, 2212, 2213, 2214, 2215, 
2216, 2217, 2218, 2219, 2220, 2221, 2222, 
+                       2223, 2308, 2309, 2310, 2311, 2312, 2313, 2314, 2315, 
2316, 2317, 2318, 2319, 2340, 2341, 2342,
+                       2343, 2344, 2345, 2346, 2347, 2348, 2349, 2350, 2351 };
+
+               private bool IsValid (int n)
+               {
+                       return (Array.BinarySearch (ValidValues, n) >= 0);
+               }
+
+               [Test]
+               // note: this one can be _very_ slow under a debugger due to 
the high number of exceptions
+               public void MakeVersionSafeName ()
+               {
+                       for (int i = 0; i < 64; i++) {
+                               ResourceScope from = (ResourceScope) i;
+                               for (int j = 0; j < 64; j++) {
+                                       ResourceScope to = (ResourceScope) j;
+                                       bool valid = IsValid ((i << 6) | j);
+                                       string from_to = String.Format ("From 
({2}) {0} to ({3}) {1}", from, to, (int)from, (int)to);
+                                       try {
+                                               string s = 
VersioningHelper.MakeVersionSafeName ("a", from, to);
+                                               Assert.IsTrue (valid, from_to);
+                                       }
+                                       catch (ArgumentException) {
+                                               Assert.IsFalse (valid, from_to);
+                                       }
+                               }
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void MakeVersionSafeName_SingleUnWorking ()
+               {
+                       VersioningHelper.MakeVersionSafeName ("a", 
ResourceScope.None, ResourceScope.None);
+               }
+
+               [Test]
+               public void ConvertTo_AppDomain ()
+               {
+                       // if appdomain is present in "from" then the ouput is 
unchanged
+                       Assert.AreEqual ("a", 
VersioningHelper.MakeVersionSafeName ("a", ResourceScope.AppDomain, 
ResourceScope.Library), "1a");
+                       Assert.AreEqual ("a", 
VersioningHelper.MakeVersionSafeName ("a", ResourceScope.AppDomain, 
ResourceScope.AppDomain), "1b");
+                       Assert.AreEqual ("a", 
VersioningHelper.MakeVersionSafeName ("a", ResourceScope.AppDomain, 
ResourceScope.AppDomain | ResourceScope.Machine), "1c");
+
+                       // if "from" doesn't have appdomain then the appdomain 
id is appended
+                       Assert.IsTrue (VersioningHelper.MakeVersionSafeName 
("a", ResourceScope.Machine, ResourceScope.AppDomain).StartsWith ("a_"), "2");
+               }
+
+               [Test]
+               public void ConvertTo_Process ()
+               {
+                       // if process is present in "from" then the ouput is 
unchanged
+                       Assert.AreEqual ("a", 
VersioningHelper.MakeVersionSafeName ("a", ResourceScope.Process, 
ResourceScope.Library), "1a");
+                       Assert.AreEqual ("a", 
VersioningHelper.MakeVersionSafeName ("a", ResourceScope.Process, 
ResourceScope.Process), "1b");
+                       Assert.AreEqual ("a", 
VersioningHelper.MakeVersionSafeName ("a", ResourceScope.Process, 
ResourceScope.Process | ResourceScope.Library), "1c");
+
+                       // if "from" doesn't have process then the process id 
is appended
+                       Assert.IsTrue (VersioningHelper.MakeVersionSafeName 
("a", ResourceScope.Machine, ResourceScope.Process).StartsWith ("a_"), "2");
+               }
+
+               [Test]
+               public void ConvertTo_AppDomain_Process ()
+               {
+                       // if the appdomain is present then the output is 
unchanged (process isn't appended)
+                       Assert.AreEqual ("a", 
VersioningHelper.MakeVersionSafeName ("a", ResourceScope.AppDomain, 
ResourceScope.AppDomain | ResourceScope.Process), "1a");
+                       // if the process is present then appdomain is appended 
to the output
+                       Assert.IsTrue (VersioningHelper.MakeVersionSafeName 
("a", ResourceScope.Process, ResourceScope.AppDomain | 
ResourceScope.Process).StartsWith ("a_"), "1b");
+
+                       // if "from" doesn't have process nor appdomain then 
both id are appended
+                       string s = VersioningHelper.MakeVersionSafeName ("a", 
ResourceScope.Machine, ResourceScope.AppDomain);
+                       int p1 = s.IndexOf ("_");
+                       Assert.IsTrue ((p1 > 0), "first _");
+                       int p2 = s.LastIndexOf ("_");
+                       Assert.IsTrue (((p2 > 0) && (p2 != p1)), "second _");
+               }
+       }
+}
+
+#endif


Property changes on: 
trunk/mcs/class/corlib/Test/System.Runtime.Versioning/VersioningHelperTest.cs
___________________________________________________________________
Name: svn:eol-style
   + native

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to