Merge pull request #5714 from alexischr/update_bockbuild
[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
8 #if !MOBILE
9 using System;
10 using System.Threading;
11 using System.Reflection;
12 using System.Reflection.Emit;
13 using NUnit.Framework;
14
15 namespace MonoTests.System.Reflection {
16
17         /// <summary>
18         /// Summary description for AssemblyDelaySignAttributeTest.
19         /// </summary>
20         [TestFixture]
21         public class AssemblyDelaySignAttributeTest
22         {
23                 private AssemblyBuilder dynAssembly;
24                 AssemblyName dynAsmName = new AssemblyName ();
25                 AssemblyDelaySignAttribute attr;
26                 
27                 public AssemblyDelaySignAttributeTest ()
28                 {
29                         //create a dynamic assembly with the required attribute
30                         //and check for the validity
31
32                         dynAsmName.Name = "TestAssembly";
33
34                         dynAssembly = Thread.GetDomain ().DefineDynamicAssembly (
35                                 dynAsmName,AssemblyBuilderAccess.Run
36                                 );
37
38                         // Set the required Attribute of the assembly.
39                         Type attribute = typeof (AssemblyDelaySignAttribute);
40                         ConstructorInfo ctrInfo = attribute.GetConstructor (
41                                 new Type [] { typeof (bool) }
42                                 );
43                         CustomAttributeBuilder attrBuilder =
44                                 new CustomAttributeBuilder (ctrInfo, new object [1] { false });
45                         dynAssembly.SetCustomAttribute (attrBuilder);
46                         object [] attributes = dynAssembly.GetCustomAttributes (true);
47                         attr = attributes [0] as AssemblyDelaySignAttribute;
48                 }
49                 
50                 [Test]
51                 public void DelaySignTest ()
52                 {
53                         Assert.AreEqual (
54                                 attr.DelaySign,
55                                 false, "#1");
56                 }
57
58                 [Test]
59                 public void TypeIdTest ()
60                 {
61                         Assert.AreEqual (
62                                 attr.TypeId,
63                                 typeof (AssemblyDelaySignAttribute)
64                                 , "#1");
65                 }
66
67                 [Test]
68                 public void MatchTestForTrue ()
69                 {
70                         Assert.AreEqual (
71                                 attr.Match (attr),
72                                 true, "#1");
73                 }
74                 [Test]
75                 public void MatchTestForFalse ()
76                 {
77                         Assert.AreEqual (
78                                 attr.Match (new AssemblyDelaySignAttribute (true)),
79                                 false, "#1");
80                 }
81         }
82 }
83
84 #endif