Author: spouliot
Date: 2005-03-31 08:44:03 -0500 (Thu, 31 Mar 2005)
New Revision: 42423

Added:
   trunk/mcs/class/corlib/Test/System.Resources/ResourceReaderCas.cs
   trunk/mcs/class/corlib/Test/System.Resources/ResourceSetCas.cs
Modified:
   trunk/mcs/class/corlib/Test/System.Resources/ChangeLog
   trunk/mcs/class/corlib/Test/System.Resources/ResourceReaderTest.cs
Log:
2005-03-31  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * ResourceReaderCas.cs: New. CAS unit tests for ResourceReader.
        * ResourceReaderTest.cs: Changed filename to internal so the "normal" 
        tests case can be reused, with partial trust, by the CAS tests. 
        * ResourceSetCas.cs: : New. CAS unit tests for ResourceSet.



Modified: trunk/mcs/class/corlib/Test/System.Resources/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System.Resources/ChangeLog      2005-03-31 
13:40:08 UTC (rev 42422)
+++ trunk/mcs/class/corlib/Test/System.Resources/ChangeLog      2005-03-31 
13:44:03 UTC (rev 42423)
@@ -1,3 +1,10 @@
+2005-03-31  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * ResourceReaderCas.cs: New. CAS unit tests for ResourceReader.
+       * ResourceReaderTest.cs: Changed filename to internal so the "normal" 
+       tests case can be reused, with partial trust, by the CAS tests. 
+       * ResourceSetCas.cs: : New. CAS unit tests for ResourceSet.
+
 2005-01-28  Nick Drochak <[EMAIL PROTECTED]>
 
        * ResourceReaderTest.cs: Not sure about a zero-byte length file.

Added: trunk/mcs/class/corlib/Test/System.Resources/ResourceReaderCas.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.Resources/ResourceReaderCas.cs   
2005-03-31 13:40:08 UTC (rev 42422)
+++ trunk/mcs/class/corlib/Test/System.Resources/ResourceReaderCas.cs   
2005-03-31 13:44:03 UTC (rev 42423)
@@ -0,0 +1,94 @@
+//
+// ResourceReaderCas.cs - CAS unit tests for System.Resources.ResourceReader
+//
+// 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.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.IO;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Security.Permissions;
+
+namespace MonoCasTests.System.Resources {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class ResourceReaderCas {
+
+               private MonoTests.System.Resources.ResourceReaderTest rrt;
+
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+                       rrt = new MonoTests.System.Resources.ResourceReaderTest 
();
+                       rrt.FixtureSetUp ();
+               }
+
+               [SetUp]
+               public void SetUp ()
+               {
+                       if (!SecurityManager.SecurityEnabled)
+                               Assert.Ignore ("SecurityManager.SecurityEnabled 
is OFF");
+               }
+
+               // Partial Trust Tests - i.e. call "normal" unit with reduced 
privileges
+
+               [Test]
+               [FileIOPermission (SecurityAction.PermitOnly, Unrestricted = 
true)]
+               public void PartialTrust_PermitOnly_FileIOPermission ()
+               {
+                       rrt.ConstructorString ();
+                       rrt.Stream ();
+                       rrt.Close ();
+                       rrt.Enumerator ();
+               }
+
+               // we use reflection to call ResourceReader as the Stream 
constructor is 
+               // protected by LinkDemand (which will be converted into full 
demand, i.e. 
+               // a stack walk) when reflection is used (i.e. it gets 
testable).
+
+               [Test]
+               [SecurityPermission (SecurityAction.Deny, 
SerializationFormatter = true)]
+               [ExpectedException (typeof (SecurityException))]
+               public void Constructor_Stream ()
+               {
+                       ConstructorInfo ci = typeof 
(ResourceReader).GetConstructor (new Type [1] { typeof (Stream) });
+                       ci.Invoke (new object [1] { Stream.Null });
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.Deny, 
SerializationFormatter = true)]
+               public void Constructor_String ()
+               {
+                       ConstructorInfo ci = typeof 
(ResourceReader).GetConstructor (new Type [1] { typeof (string) });
+                       ci.Invoke (new object [1] { 
MonoTests.System.Resources.ResourceReaderTest.m_ResourceFile });
+                       // works - i.e. no LinkDemand
+               }
+       }
+}

Modified: trunk/mcs/class/corlib/Test/System.Resources/ResourceReaderTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.Resources/ResourceReaderTest.cs  
2005-03-31 13:40:08 UTC (rev 42422)
+++ trunk/mcs/class/corlib/Test/System.Resources/ResourceReaderTest.cs  
2005-03-31 13:44:03 UTC (rev 42423)
@@ -19,7 +19,7 @@
 
        [TestFixture]
        public class ResourceReaderTest : Assertion {
-               private static string m_ResourceFile;
+               internal static string m_ResourceFile;
                private static string m_BadResourceFile;
 
                [TestFixtureSetUp]
@@ -132,7 +132,6 @@
                                DictionaryEntry de = 
(DictionaryEntry)en.Current;
                                Assert("Current.Key should not be 
empty",String.Empty != (string)de.Key);
                                Assert("Current.Value should not be 
empty",String.Empty != (string)de.Value);
-                               Assert("Current.Value should not be 
empty",String.Empty != (string)de.Value);
                                Assert("Entry.Key should not be 
empty",String.Empty != (string)en.Key);
                                Assert("Entry.Value should not be 
empty",String.Empty != (string)en.Value);
                        }

Added: trunk/mcs/class/corlib/Test/System.Resources/ResourceSetCas.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.Resources/ResourceSetCas.cs      
2005-03-31 13:40:08 UTC (rev 42422)
+++ trunk/mcs/class/corlib/Test/System.Resources/ResourceSetCas.cs      
2005-03-31 13:44:03 UTC (rev 42423)
@@ -0,0 +1,83 @@
+//
+// ResourceSetCas.cs - CAS unit tests for System.Resources.ResourceSet
+//
+// 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.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.IO;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Security.Permissions;
+
+namespace MonoCasTests.System.Resources {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class ResourceSetCas {
+
+               [SetUp]
+               public void SetUp ()
+               {
+                       if (!SecurityManager.SecurityEnabled)
+                               Assert.Ignore ("SecurityManager.SecurityEnabled 
is OFF");
+               }
+
+               // we use reflection to call ResourceSet as the Stream 
constructor is 
+               // protected by LinkDemand (which will be converted into full 
demand, i.e. 
+               // a stack walk) when reflection is used (i.e. it gets 
testable).
+
+               [Test]
+               [SecurityPermission (SecurityAction.Deny, 
SerializationFormatter = true)]
+               [ExpectedException (typeof (SecurityException))]
+               public void Constructor_Stream ()
+               {
+                       ConstructorInfo ci = typeof 
(ResourceSet).GetConstructor (new Type [1] { typeof (Stream) });
+                       ci.Invoke (new object [1] { Stream.Null });
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.Deny, 
SerializationFormatter = true)]
+               public void Constructor_String ()
+               {
+                       ConstructorInfo ci = typeof 
(ResourceSet).GetConstructor (new Type [1] { typeof (string) });
+                       ci.Invoke (new object [1] { 
MonoTests.System.Resources.ResourceReaderTest.m_ResourceFile });
+                       // works - i.e. no LinkDemand
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.Deny, 
SerializationFormatter = true)]
+               public void Constructor_IResourceReader ()
+               {
+                       ResourceReader r = new ResourceReader 
(MonoTests.System.Resources.ResourceReaderTest.m_ResourceFile);
+                       ConstructorInfo ci = typeof 
(ResourceSet).GetConstructor (new Type [1] { typeof (IResourceReader) });
+                       ci.Invoke (new object [1] { r });
+                       // works - i.e. no LinkDemand
+               }
+       }
+}

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

Reply via email to