2005-05-30 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Mon, 30 May 2005 18:47:17 +0000 (18:47 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Mon, 30 May 2005 18:47:17 +0000 (18:47 -0000)
* PrintingPermissionTest.cs: Added tests for unification as this
assembly is signed by the "MS final" key (not the ECMA key).

svn path=/trunk/mcs/; revision=45196

mcs/class/System.Drawing/Test/System.Drawing.Printing/ChangeLog
mcs/class/System.Drawing/Test/System.Drawing.Printing/PrintingPermissionTest.cs

index 324a1ef8540be09a2f90db1d8196143025355ba7..27eeffd192c049b3a4e2b0f1e40b8b215aac4ddd 100644 (file)
@@ -1,3 +1,8 @@
+2005-05-30  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * PrintingPermissionTest.cs: Added tests for unification as this 
+       assembly is signed by the "MS final" key (not the ECMA key).
+
 2004-09-09  Sebastien Pouliot  <sebastien@ximian.com>
 
        * PrintingPermissionAttributeTest.cs: New. Unit tests for Printing
index 44a8f62b062556491d57bbe5bd5e8d28fc2df7b1..e86c35381135b2c01222c18ba33f4c089efff838 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //     Sebastien Pouliot  <sebastien@ximian.com>
 //
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-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
@@ -27,7 +27,8 @@
 //
 
 using NUnit.Framework;
-using System;
+using System;\r
+using System.IO;\r
 using System.Drawing.Printing;
 using System.Security;
 using System.Security.Permissions;
@@ -423,5 +424,55 @@ namespace MonoTests.System.Drawing.Printing {
                        w.AddAttribute ("class", se.Attribute ("class"));
                        pp.FromXml (w);
                }
+
+               // Unification tests (with the MS final key)
+               // note: corlib already test the ECMA key support for unification\r
+               private const string PermissionPattern = "<PermissionSet class=\"System.Security.PermissionSet\" version=\"1\"><IPermission class=\"System.Drawing.Printing.PrintingPermission, System.Drawing, Version={0}, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\" version=\"1\" Level=\"NoPrinting\"/></PermissionSet>";
+               private const string fx10version = "1.0.3300.0";
+               private const string fx11version = "1.0.5000.0";
+               private const string fx20version = "2.0.0.0";
+
+               private void Unification (string xml)
+               {
+                       PermissionSetAttribute psa = new PermissionSetAttribute (SecurityAction.Assert);
+                       psa.XML = xml;
+                       string pset = psa.CreatePermissionSet ().ToString ();
+                       string currentVersion = typeof (string).Assembly.GetName ().Version.ToString ();
+                       Assert.IsTrue ((pset.IndexOf (currentVersion) > 0), currentVersion);
+               }
+
+               [Test]
+               public void Unification_FromFx10 ()
+               {
+                       Unification (String.Format (PermissionPattern, fx10version));
+               }
+
+               [Test]
+               public void Unification_FromFx11 ()
+               {
+                       Unification (String.Format (PermissionPattern, fx11version));
+               }
+
+               [Test]
+               public void Unification_FromFx20 ()
+               {
+                       Unification (String.Format (PermissionPattern, fx20version));
+               }
+
+#if NET_2_0\r
+               [Test]
+               [Category ("NotWorking")]
+               [ExpectedException (typeof (FileLoadException))]
+               public void Unification_FromFx99 ()
+               {
+                       Type.GetType (String.Format (PermissionPattern, "9.99.999.9999"));
+               }
+#else
+               [Test]
+               public void Unification_FromFx99 ()
+               {
+                       Unification (String.Format (PermissionPattern, "9.99.999.9999"));
+               }
+#endif\r
        }
 }