1 // AssemblyDescriptionAttributeTest.cs
3 // Author: Vineeth N <nvineeth@yahoo.com>
5 // (C) 2004 Ximian, Inc. http://www.ximian.com
8 using System
.Threading
;
9 using System
.Reflection
;
10 using System
.Reflection
.Emit
;
11 using NUnit
.Framework
;
13 namespace MonoTests
.System
.Reflection
{
16 /// Summary description for AssemblyDescriptionAttributeTest.
19 public class AssemblyDescriptionAttributeTest
: Assertion
21 private AssemblyBuilder dynAssembly
;
22 AssemblyName dynAsmName
= new AssemblyName ();
23 AssemblyDescriptionAttribute attr
;
25 public AssemblyDescriptionAttributeTest ()
27 //create a dynamic assembly with the required attribute
28 //and check for the validity
30 dynAsmName
.Name
= "TestAssembly";
32 dynAssembly
= Thread
.GetDomain ().DefineDynamicAssembly (
33 dynAsmName
,AssemblyBuilderAccess
.Run
36 // Set the required Attribute of the assembly.
37 Type attribute
= typeof (AssemblyDescriptionAttribute
);
38 ConstructorInfo ctrInfo
= attribute
.GetConstructor (
39 new Type
[] { typeof (string) }
41 CustomAttributeBuilder attrBuilder
=
42 new CustomAttributeBuilder (ctrInfo
, new object [1] { "Emitted Assembly" }
);
43 dynAssembly
.SetCustomAttribute (attrBuilder
);
44 object [] attributes
= dynAssembly
.GetCustomAttributes (true);
45 attr
= attributes
[0] as AssemblyDescriptionAttribute
;
49 public void DescriptionTest ()
51 AssertEquals ("#Testing Description",
57 public void TypeIdTest ()
59 AssertEquals ("#testing Typeid",
61 typeof (AssemblyDescriptionAttribute
)
66 public void MatchTestForTrue ()
68 AssertEquals ("#testing Match method-- for true",
74 public void MatchTestForFalse ()
76 AssertEquals ("#testing Match method-- for false",
77 attr
.Match (new AssemblyDescriptionAttribute ("Descrptn")),