Author: gert
Date: 2007-05-01 12:56:28 -0400 (Tue, 01 May 2007)
New Revision: 76533

Added:
   trunk/mcs/class/corlib/Test/System.Reflection/ConstructorInfoTest.cs
Modified:
   trunk/mcs/class/corlib/ChangeLog
   trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog
   trunk/mcs/class/corlib/corlib_test.dll.sources
Log:
* corlib_test.dll.sources: Added ConstructorInfoTest.cs.
* ConstructorInfoTest.cs: Added tests for Invoke.


Modified: trunk/mcs/class/corlib/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/ChangeLog    2007-05-01 16:38:12 UTC (rev 76532)
+++ trunk/mcs/class/corlib/ChangeLog    2007-05-01 16:56:28 UTC (rev 76533)
@@ -1,3 +1,7 @@
+2007-05-01  Gert Driesen  <[EMAIL PROTECTED]>
+
+       * corlib_test.dll.sources: Added ConstructorInfoTest.cs.
+
 2007-04-30  Dick Porter  <[EMAIL PROTECTED]>
 
        * corlib.dll.sources: Added

Modified: trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog     2007-05-01 
16:38:12 UTC (rev 76532)
+++ trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog     2007-05-01 
16:56:28 UTC (rev 76533)
@@ -1,3 +1,7 @@
+2007-05-01  Gert Driesen  <[EMAIL PROTECTED]>
+
+       * ConstructorInfoTest.cs: Added tests for Invoke.
+
 2007-05-01  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * MethodInfoTest.cs: Reenable a NotWorking test which is working now.

Added: trunk/mcs/class/corlib/Test/System.Reflection/ConstructorInfoTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.Reflection/ConstructorInfoTest.cs        
2007-05-01 16:38:12 UTC (rev 76532)
+++ trunk/mcs/class/corlib/Test/System.Reflection/ConstructorInfoTest.cs        
2007-05-01 16:56:28 UTC (rev 76533)
@@ -0,0 +1,91 @@
+//
+// System.Reflection.ConstructorInfo Test Cases
+//
+// Authors:
+//  Gert Driesen ([EMAIL PROTECTED])
+//
+// (c) 2007 Gert Driesen
+//
+// 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 System;
+using System.Reflection;
+using System.Runtime.Serialization;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Reflection
+{
+       [TestFixture]
+       public class ConstructorInfoTest
+       {
+               [Test]
+               public void Invoke ()
+               {
+                       ConstructorInfo ctor = typeof (Foo).GetConstructor (
+                               BindingFlags.Public | BindingFlags.Instance, 
null,
+                               Type.EmptyTypes, null);
+                       Foo foo = ctor.Invoke (new object [0]) as Foo;
+                       Assert.IsNotNull (foo, "#1");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void InvokeAbstract ()
+               {
+                       object obj = FormatterServices.GetUninitializedObject 
(typeof (Foo));
+                       ConstructorInfo ctor = typeof 
(AbstractFoo).GetConstructor (
+                               BindingFlags.Instance | BindingFlags.NonPublic, 
null, 
+                               Type.EmptyTypes, null);
+                       Assert.IsNotNull (ctor, "#A1");
+                       object ret = ctor.Invoke (obj, new object [0]);
+                       Assert.IsNull (ret, "#A2");
+
+                       try {
+                               ctor.Invoke (null, new object [0]);
+                               Assert.Fail ("#B1");
+                       } catch (TargetException ex) {
+                               // Non-static method requires a target
+                               Assert.AreEqual (typeof (TargetException), 
ex.GetType (), "#B2");
+                               Assert.IsNull (ex.InnerException, "#B3");
+                               Assert.IsNotNull (ex.Message, "#B4");
+                       }
+
+                       try {
+                               ctor.Invoke (new object [0]);
+                               Assert.Fail ("#C1");
+                       } catch (MemberAccessException ex) {
+                               // Cannot create an abstract class
+                               Assert.AreEqual (typeof 
(MemberAccessException), ex.GetType (), "#C2");
+                               Assert.IsNull (ex.InnerException, "#C3");
+                               Assert.IsNotNull (ex.Message, "#C4");
+                       }
+               }
+
+               abstract class AbstractFoo
+               {
+               }
+
+               class Foo : AbstractFoo
+               {
+               }
+       }
+}

Modified: trunk/mcs/class/corlib/corlib_test.dll.sources
===================================================================
--- trunk/mcs/class/corlib/corlib_test.dll.sources      2007-05-01 16:38:12 UTC 
(rev 76532)
+++ trunk/mcs/class/corlib/corlib_test.dll.sources      2007-05-01 16:56:28 UTC 
(rev 76533)
@@ -102,6 +102,7 @@
 System.Reflection/AssemblyNameTest.cs
 System.Reflection/AssemblyTest.cs
 System.Reflection/BinderTests.cs
+System.Reflection/ConstructorInfoTest.cs
 System.Reflection/EventInfoTest.cs
 System.Reflection/FieldInfoTest.cs
 System.Reflection/MethodInfoTest.cs

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

Reply via email to