2009-06-12 Bill Holmes <billholmes54@gmail.com>
[mono.git] / mcs / class / corlib / Test / System.Reflection / AssemblyDelaySignAttributeTest.cs
1 // AssemblyDelaySignAttributeTest.cs
2 //
3 // Author: Vineeth N <nvineeth@yahoo.com>
4 //
5 // (C) 2004 Ximian, Inc. http://www.ximian.com
6 //
7 using System;
8 using System.Threading;
9 using System.Reflection;
10 using System.Reflection.Emit;
11 using NUnit.Framework;
12
13 namespace MonoTests.System.Reflection {
14
15         /// <summary>
16         /// Summary description for AssemblyDelaySignAttributeTest.
17         /// </summary>
18         [TestFixture]
19         public class AssemblyDelaySignAttributeTest:Assertion
20         {
21                 private AssemblyBuilder dynAssembly;
22                 AssemblyName dynAsmName = new AssemblyName ();
23                 AssemblyDelaySignAttribute attr;
24                 
25                 public AssemblyDelaySignAttributeTest ()
26                 {
27                         //create a dynamic assembly with the required attribute
28                         //and check for the validity
29
30                         dynAsmName.Name = "TestAssembly";
31
32                         dynAssembly = Thread.GetDomain ().DefineDynamicAssembly (
33                                 dynAsmName,AssemblyBuilderAccess.Run
34                                 );
35
36                         // Set the required Attribute of the assembly.
37                         Type attribute = typeof (AssemblyDelaySignAttribute);
38                         ConstructorInfo ctrInfo = attribute.GetConstructor (
39                                 new Type [] { typeof (bool) }
40                                 );
41                         CustomAttributeBuilder attrBuilder =
42                                 new CustomAttributeBuilder (ctrInfo, new object [1] { false });
43                         dynAssembly.SetCustomAttribute (attrBuilder);
44                         object [] attributes = dynAssembly.GetCustomAttributes (true);
45                         attr = attributes [0] as AssemblyDelaySignAttribute;
46                 }
47                 
48                 [Test]
49                 public void DelaySignTest ()
50                 {
51                         AssertEquals ("#Testing DelaySign",
52                                 attr.DelaySign,
53                                 false);
54                 }
55
56                 [Test]
57                 public void TypeIdTest ()
58                 {
59                         AssertEquals ("#testing Typeid",
60                                 attr.TypeId,
61                                 typeof (AssemblyDelaySignAttribute)
62                                 );
63                 }
64
65                 [Test]
66                 public void MatchTestForTrue ()
67                 {
68                         AssertEquals ("#testing Match method-- for true",
69                                 attr.Match (attr),
70                                 true);
71                 }
72                 [Test]
73                 public void MatchTestForFalse ()
74                 {
75                         AssertEquals ("#testing Match method-- for false",
76                                 attr.Match (new AssemblyDelaySignAttribute (true)),
77                                 false);
78                 }
79         }
80 }
81