2003-02-10 Zoltan Varga <vargaz@freemail.hu>
authorZoltan Varga <vargaz@gmail.com>
Mon, 10 Feb 2003 13:17:31 +0000 (13:17 -0000)
committerZoltan Varga <vargaz@gmail.com>
Mon, 10 Feb 2003 13:17:31 +0000 (13:17 -0000)
* ConstructorBuilderTest.cs: added SetCustomAttribute() tests.

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

mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog
mcs/class/corlib/Test/System.Reflection.Emit/ConstructorBuilderTest.cs

index d246760af1a6e54df3a0b68229dd1469d1cb45a5..9aff2e4e4f335c04267d7ae63d532e629175a976 100644 (file)
@@ -1,5 +1,7 @@
 2003-02-10  Zoltan Varga  <vargaz@freemail.hu>
 
+       * ConstructorBuilderTest.cs: added SetCustomAttribute() tests.
+
        * MethodBuilderTest.cs: updated to NUNIT2 conventions.
 
        * ConstructorBuilderTest.cs: New file.
index 73d4f52c90a3e106c04b387f876a511d81c1136d..d3bba9dd0dec90a813ef256791a25bcc8088d516 100644 (file)
@@ -264,5 +264,43 @@ public class ConstructorBuilderTest : Assertion
                } catch (NotSupportedException) {\r
                }\r
        }\r
+\r
+       public void TestSetCustomAttribute () {\r
+               TypeBuilder tb = module.DefineType ("class21", TypeAttributes.Public);\r
+               ConstructorBuilder cb = tb.DefineConstructor (\r
+                        0, 0, \r
+                       new Type [1] {typeof(int)});\r
+               cb.GetILGenerator ().Emit (OpCodes.Ret);\r
+\r
+               // Null argument\r
+               try {\r
+                       cb.SetCustomAttribute (null);\r
+                       Fail ();\r
+               } catch (ArgumentNullException) {\r
+               }\r
+\r
+               byte[] custAttrData = { 1, 0, 0, 0, 0};\r
+               Type attrType = Type.GetType\r
+                       ("System.Reflection.AssemblyKeyNameAttribute");\r
+               Type[] paramTypes = new Type[1];\r
+               paramTypes[0] = typeof(String);\r
+               ConstructorInfo ctorInfo =\r
+                       attrType.GetConstructor(paramTypes);\r
+\r
+               cb.SetCustomAttribute (ctorInfo, custAttrData);\r
+\r
+               // Null arguments again\r
+               try {\r
+                       cb.SetCustomAttribute (null, new byte[2]);\r
+                       Fail ();\r
+               } catch (ArgumentNullException) {\r
+               }\r
+\r
+               try {\r
+                       cb.SetCustomAttribute (ctorInfo, null);\r
+                       Fail ();\r
+               } catch (ArgumentNullException) {\r
+               }\r
+       }\r
 }\r
 }\r