Author: spouliot
Date: 2005-04-04 08:26:53 -0400 (Mon, 04 Apr 2005)
New Revision: 42513

Modified:
   trunk/mcs/class/corlib/Test/System.Reflection/AssemblyNameTest.cs
   trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog
   trunk/mcs/class/corlib/Test/System.Reflection/ModuleCas.cs
   trunk/mcs/class/corlib/Test/System.Reflection/ModuleTest.cs
Log:
2005-04-04  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * AssemblyNameTest.cs: Add test for ArgumentNullException on 
        GetObjectData. Made existing tests more nunit2.2 like.
        * ModuleCas.cs: Added new tests for FullyQualifiedName and Name 
        properties.
        * ModuleTest.cs: Add test for ArgumentNullException on GetObjectData.



Modified: trunk/mcs/class/corlib/Test/System.Reflection/AssemblyNameTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.Reflection/AssemblyNameTest.cs   
2005-04-04 12:23:01 UTC (rev 42512)
+++ trunk/mcs/class/corlib/Test/System.Reflection/AssemblyNameTest.cs   
2005-04-04 12:26:53 UTC (rev 42513)
@@ -2,9 +2,10 @@
 // AssemblyNameTest.cs - NUnit Test Cases for AssemblyName
 //
 // Author:
-//     Sebastien Pouliot ([EMAIL PROTECTED])
+//     Sebastien Pouliot  <[EMAIL PROTECTED]>
 //
 // (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
 //
 
 using NUnit.Framework;
@@ -13,6 +14,7 @@
 using System.IO;
 using System.Reflection;
 using System.Reflection.Emit;
+using System.Runtime.Serialization;
 using System.Threading;
 using System.Globalization;
 using System.Runtime.Serialization.Formatters.Binary;
@@ -59,7 +61,8 @@
        static byte[] token = { 0xFF, 0xEF, 0x94, 0x53, 0x67, 0x69, 0xDA, 0x06 
};
 
        [SetUp]
-       protected void SetUp () {
+       public void SetUp () 
+       {
                try {
                        if (Directory.Exists (tempDir))
                                Directory.Delete (tempDir, true);
@@ -73,7 +76,8 @@
        }
 
        [TearDown]
-       protected void TearDown () {
+       public void TearDown () 
+       {
                try {
                        if (Directory.Exists (tempDir))
                        Directory.Delete (tempDir, true);
@@ -84,7 +88,8 @@
                }
        }
 
-       public void TestEmptyAssembly () 
+       [Test]
+       public void EmptyAssembly () 
        {
                an = new AssemblyName ();
                Assert.IsNull (an.CodeBase, "CodeBase");
@@ -100,7 +105,8 @@
                        an.VersionCompatibility, "VersionCompatibility");
        }
 
-       public void TestPublicKey () 
+       [Test]
+       public void PublicKey () 
        {
                an = new AssemblyName ();
                Assert.IsNull (an.GetPublicKey (), "PublicKey(empty)");
@@ -113,7 +119,8 @@
                AssertEqualsByteArrays ("PublicKeyToken", token, 
an.GetPublicKeyToken ());
        }
 
-       public void TestPublicKeyToken () 
+       [Test]
+       public void PublicKeyToken () 
        {
                an = new AssemblyName ();
                an.SetPublicKeyToken (token);
@@ -124,7 +131,8 @@
                AssertEqualsByteArrays ("PublicKeyToken", token, 
an.GetPublicKeyToken ());
        }
 
-       public void TestKeyPair () 
+       [Test]
+       public void KeyPair () 
        {
                an = new AssemblyName ();
                an.KeyPair = new StrongNameKeyPair (publicKey);
@@ -136,7 +144,8 @@
        }
 
        // !!! this assembly MUST NOT use a StrongName !!!
-       public void TestSelf () 
+       [Test]
+       public void Self () 
        {
                Assembly a = Assembly.GetExecutingAssembly ();
                AssemblyName an = a.GetName ();
@@ -146,7 +155,7 @@
        }
 
        [Test]
-       public void TestFullName1 ()
+       public void FullName1 ()
        {
                // !!! we assume the mscorlib has a strong name !!!
                AssemblyName an = typeof(int).Assembly.GetName ();
@@ -157,7 +166,7 @@
        }
 
        [Test]
-       public void TestFullName2 ()
+       public void FullName2 ()
        {
                const string assemblyName = "TestAssembly";
 
@@ -171,7 +180,7 @@
        }
 
        [Test]
-       public void TestFullName3 ()
+       public void FullName3 ()
        {
                const string assemblyName = "TestAssembly";
                const string assemblyVersion = "1.2";
@@ -184,7 +193,7 @@
        }
 
        [Test]
-       public void TestFullName4 ()
+       public void FullName4 ()
        {
                const string assemblyName = "TestAssembly";
 
@@ -196,7 +205,7 @@
        }
 
        [Test]
-       public void TestFullName5 ()
+       public void FullName5 ()
        {
                const string assemblyName = "TestAssembly";
 
@@ -208,7 +217,7 @@
        }
 
        [Test]
-       public void TestFullName6 ()
+       public void FullName6 ()
        {
                const string assemblyName = "TestAssembly";
                const string assemblyVersion = "1.2";
@@ -223,7 +232,7 @@
        }
 
        [Test]
-       public void TestFullName7 ()
+       public void FullName7 ()
        {
                const string assemblyName = "TestAssembly";
                const string assemblyVersion = "1.2";
@@ -239,7 +248,7 @@
        }
 
        [Test]
-       public void TestFullName8 ()
+       public void FullName8 ()
        {
                const string assemblyName = "TestAssembly";
 
@@ -255,13 +264,15 @@
 
        static int nameIndex = 0;
 
-       private AssemblyName GenAssemblyName () {
+       private AssemblyName GenAssemblyName () 
+       {
                AssemblyName assemblyName = new AssemblyName();
                assemblyName.Name = 
"MonoTests.System.Reflection.AssemblyNameTest" + (nameIndex ++);
                return assemblyName;
        }
 
-       private Assembly GenerateAssembly (AssemblyName name) {
+       private Assembly GenerateAssembly (AssemblyName name) 
+       {
                AssemblyBuilder ab = domain.DefineDynamicAssembly (
                        name,
                        AssemblyBuilderAccess.RunAndSave,
@@ -272,6 +283,7 @@
                return Assembly.LoadFrom (Path.Combine (tempDir, name.Name + 
".dll"));
        }
 
+       [Test]
        public void TestCultureInfo ()
        {
                AssemblyName name = GenAssemblyName ();
@@ -281,7 +293,8 @@
                Assert.AreEqual (a.GetName ().CultureInfo.Name, "ar-DZ");
        }
 
-       public void TestVersion ()
+       [Test]
+       public void Version ()
        {
                AssemblyName name = GenAssemblyName ();
                name.Version = new Version (1, 2, 3, 4);
@@ -302,13 +315,15 @@
                Assert.AreEqual ("1.2.0.0", a.GetName ().Version.ToString ());
        }
 
-       public void TestHashAlgorithm ()
+       [Test]
+       public void HashAlgorithm ()
        {
                Assert.AreEqual (AssemblyHashAlgorithm.SHA1, 
                        typeof (int).Assembly.GetName ().HashAlgorithm);
        }
 
-       public void TestSerialization ()
+       [Test]
+       public void Serialization ()
        {
                AssemblyName an = new AssemblyName ();
                an.CodeBase = "http://www.test.com/test.dll";;
@@ -348,13 +363,16 @@
                AssertEqualsByteArrays ("PublicToken", an.GetPublicKeyToken (), 
dsAssemblyName.GetPublicKeyToken ());
        }
 
-
-       private AssemblyName GetAssemblyName (string assemblyFile) 
+       [Test]
+       [ExpectedException (typeof (ArgumentNullException))]
+       public void GetObjectData_Null ()
        {
-               Assembly a = Assembly.LoadFrom (assemblyFile);
-               return a.GetName ();
-       }
+               AssemblyName an = new AssemblyName ();
+               an.GetObjectData (null, new StreamingContext 
(StreamingContextStates.All));
+       }
 
+       // helpers
+
        private string GetTokenString (byte[] value)
        {
                string tokenString = "";
@@ -363,11 +381,6 @@
                }
                return tokenString;
        }
-
-       public void TestStatic () 
-       {
-               /*an = GetAssemblyName ("System.Reflection.dll");*/
-       }
 }
 
 }

Modified: trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog     2005-04-04 
12:23:01 UTC (rev 42512)
+++ trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog     2005-04-04 
12:26:53 UTC (rev 42513)
@@ -1,3 +1,11 @@
+2005-04-04  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * AssemblyNameTest.cs: Add test for ArgumentNullException on 
+       GetObjectData. Made existing tests more nunit2.2 like.
+       * ModuleCas.cs: Added new tests for FullyQualifiedName and Name 
+       properties.
+       * ModuleTest.cs: Add test for ArgumentNullException on GetObjectData.
+
 2005-03-24  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * ModuleCas.cs: New. CAS unit tests for Module.

Modified: trunk/mcs/class/corlib/Test/System.Reflection/ModuleCas.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.Reflection/ModuleCas.cs  2005-04-04 
12:23:01 UTC (rev 42512)
+++ trunk/mcs/class/corlib/Test/System.Reflection/ModuleCas.cs  2005-04-04 
12:26:53 UTC (rev 42513)
@@ -41,11 +41,13 @@
        public class ModuleCas {
 
                private MonoTests.System.Reflection.ModuleTest mt;
+               private Module main;
 
                [TestFixtureSetUp]
                public void FixtureSetUp ()
                {
                        mt = new MonoTests.System.Reflection.ModuleTest ();
+                       main = typeof (int).Module;
                }
 
                [SetUp]
@@ -62,12 +64,13 @@
                        mt.TearDown ();
                }
 
-               // Partial Trust Tests - i.e. call "normal" unit with reduced 
privileges
+               // Partial Trust Tests
 
                [Test]
                [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
                public void PartialTrust_DenyUnrestricted ()
                {
+                       // call "normal" unit with reduced privileges
                        mt.FindTypes ();
 #if NET_2_0
                        mt.ResolveType ();
@@ -75,8 +78,47 @@
                        mt.ResolveField ();
                        mt.ResolveMember ();
 #endif
+                       // properties
+                       Assert.IsNotNull (main.Assembly, "Assembly");
+                       Assert.IsNotNull (main.ScopeName, "ScopeName");
+
+                       // methods (incomplete)
+                       Assert.IsNotNull (main.ToString (), "ToString");
                }
 
+               [Test]
+               [FileIOPermission (SecurityAction.Deny, Unrestricted = true)]
+               [ExpectedException (typeof (SecurityException))]
+               public void FullyQualifiedName_Deny_FileIOPermission ()
+               {
+                       Assert.IsNotNull (main.FullyQualifiedName, 
"FullyQualifiedName");
+               }
+
+               [Test]
+               [FileIOPermission (SecurityAction.PermitOnly, Unrestricted = 
true)]
+               public void FullyQualifiedName_PermitOnly_FileIOPermission ()
+               {
+                       Assert.IsNotNull (main.FullyQualifiedName, 
"FullyQualifiedName");
+               }
+
+               // Note: we do not ask for PathDiscovery because no path is 
returned here.
+               // However MS Fx requires it (see FDBK23572 for details).
+               [Category ("NotWorking")] // on purpose ;-)
+               [Test]
+               [FileIOPermission (SecurityAction.Deny, Unrestricted = true)]
+               [ExpectedException (typeof (SecurityException))]
+               public void Name_Deny_FileIOPermission ()
+               {
+                       Assert.IsNotNull (main.Name, "Name");
+               }
+
+               [Test]
+               [FileIOPermission (SecurityAction.PermitOnly, Unrestricted = 
true)]
+               public void Name_PermitOnly_FileIOPermission ()
+               {
+                       Assert.IsNotNull (main.Name, "Name");
+               }
+
                // we use reflection to call Module as the GetObjectData method 
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).

Modified: trunk/mcs/class/corlib/Test/System.Reflection/ModuleTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.Reflection/ModuleTest.cs 2005-04-04 
12:23:01 UTC (rev 42512)
+++ trunk/mcs/class/corlib/Test/System.Reflection/ModuleTest.cs 2005-04-04 
12:26:53 UTC (rev 42513)
@@ -4,14 +4,14 @@
 // Zoltan Varga ([EMAIL PROTECTED])
 //
 // (C) Ximian, Inc.  http://www.ximian.com
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
 //
-//
 
-
 using System;
 using System.Threading;
 using System.Reflection;
 using System.Reflection.Emit;
+using System.Runtime.Serialization;
 using System.IO;
 using System.Collections;
 
@@ -280,6 +280,14 @@
                AssertEquals ("FindTypesTestFirstClass", t [0].Name);
                AssertEquals ("FindTypesTestSecondClass", t [1].Name);
        }
+
+       [Test]
+       [ExpectedException (typeof (ArgumentNullException))]
+       public void GetObjectData_Null ()
+       {
+               Module m = typeof (ModuleTest).Module;
+               m.GetObjectData (null, new StreamingContext 
(StreamingContextStates.All));
+       }
 
        class FindTypesTestFirstClass { 
        }

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

Reply via email to