Author: spouliot
Date: 2005-03-24 15:53:40 -0500 (Thu, 24 Mar 2005)
New Revision: 42239
Modified:
trunk/mcs/class/corlib/Test/System.IO.IsolatedStorage/ChangeLog
trunk/mcs/class/corlib/Test/System.IO.IsolatedStorage/IsolatedStorageFileStreamCas.cs
Log:
2005-03-24 Sebastien Pouliot <[EMAIL PROTECTED]>
* IsolatedStorageFileStreamCas.cs: Added reflection-based unit tests
to test LinkDemand on Handle and SafeFileHandle (2.0) properties.
Modified: trunk/mcs/class/corlib/Test/System.IO.IsolatedStorage/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System.IO.IsolatedStorage/ChangeLog
2005-03-24 20:38:55 UTC (rev 42238)
+++ trunk/mcs/class/corlib/Test/System.IO.IsolatedStorage/ChangeLog
2005-03-24 20:53:40 UTC (rev 42239)
@@ -1,3 +1,8 @@
+2005-03-24 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * IsolatedStorageFileStreamCas.cs: Added reflection-based unit tests
+ to test LinkDemand on Handle and SafeFileHandle (2.0) properties.
+
2005-03-15 Sebastien Pouliot <[EMAIL PROTECTED]>
* IsolatedStorageFileStreamCas.cs: New. CAS unit tests for
Modified:
trunk/mcs/class/corlib/Test/System.IO.IsolatedStorage/IsolatedStorageFileStreamCas.cs
===================================================================
---
trunk/mcs/class/corlib/Test/System.IO.IsolatedStorage/IsolatedStorageFileStreamCas.cs
2005-03-24 20:38:55 UTC (rev 42238)
+++
trunk/mcs/class/corlib/Test/System.IO.IsolatedStorage/IsolatedStorageFileStreamCas.cs
2005-03-24 20:53:40 UTC (rev 42239)
@@ -32,6 +32,7 @@
using System;
using System.IO;
using System.IO.IsolatedStorage;
+using System.Reflection;
using System.Security;
using System.Security.Permissions;
@@ -208,7 +209,7 @@
{
IsolatedStorageFileStream isfs = new
IsolatedStorageFileStream ("cas-Handle", FileMode.Create);
IntPtr p = isfs.Handle;
- // LAMSPEC: SecurityException with UnmanagedCode
+ // Note: The SecurityException for UnmanagedCode cannot
be tested here because it's a LinkDemand
}
#if NET_2_0
[Test]
@@ -218,7 +219,43 @@
{
IsolatedStorageFileStream isfs = new
IsolatedStorageFileStream ("cas-SafeFileHandle", FileMode.Create);
SafeFileHandle sfh = isfs.SafeFileHandle;
+ // Note: The SecurityException for UnmanagedCode cannot
be tested here because it's a LinkDemand
}
#endif
+
+ // we use reflection to call IsolatedStorageFileStream as the
Handle and SafeFileHandle
+ // properties are 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, UnmanagedCode = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void Handle_UnmanagedCode ()
+ {
+ IsolatedStorageFileStream isfs = new
IsolatedStorageFileStream ("cas-Handle-Unmanaged", FileMode.Create);
+ try {
+ MethodInfo mi = typeof
(IsolatedStorageFileStream).GetProperty ("Handle").GetGetMethod ();
+ mi.Invoke (isfs, null);
+ }
+ finally {
+ isfs.Close ();
+ }
+ }
+#if NET_2_0
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void SafeFileHandle_UnmanagedCode ()
+ {
+ IsolatedStorageFileStream isfs = new
IsolatedStorageFileStream ("cas-SafeFileHandle-Unmanaged", FileMode.Create);
+ try {
+ MethodInfo mi = typeof
(IsolatedStorageFileStream).GetProperty ("SafeFileHandle").GetGetMethod ();
+ mi.Invoke (isfs, null);
+ }
+ finally {
+ isfs.Close ();
+ }
+ }
+#endif
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches