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