**** Merged from MCS ****
[mono-project.git] / mcs / class / corlib / Test / System.Reflection / AssemblyConfigurationAttributeTest.cs
blobcd8e320b0d2b5be09c4029406bc44a45bbce0df3
1 // AssemblyConfigurationAttributeTest.cs
2 //
3 // Author: Vineeth N <nvineeth@yahoo.com>
4 //
5 // (C) 2004 Ximian, Inc. http://www.ximian.com
6 //
8 using System;
9 using System.Threading;
10 using System.Reflection;
11 using System.Reflection.Emit;
12 using NUnit.Framework;
14 namespace MonoTests.System.Reflection {
16 /// <summary>
17 /// Test Fixture for AssemblyConfigurationAttribute class
18 /// </summary>
19 [TestFixture]
20 public class AssemblyConfigurationAttributeTest : Assertion
22 private AssemblyBuilder dynAssembly;
23 AssemblyName dynAsmName = new AssemblyName ();
24 AssemblyConfigurationAttribute attr;
26 public AssemblyConfigurationAttributeTest ()
28 //create a dynamic assembly with the required attribute
29 //and check for the validity
31 dynAsmName.Name = "TestAssembly";
33 dynAssembly = Thread.GetDomain ().DefineDynamicAssembly (
34 dynAsmName,AssemblyBuilderAccess.Run
37 // Set the required Attribute of the assembly.
38 Type attribute = typeof (AssemblyConfigurationAttribute);
39 ConstructorInfo ctrInfo = attribute.GetConstructor (
40 new Type [] { typeof (string) }
42 CustomAttributeBuilder attrBuilder =
43 new CustomAttributeBuilder (ctrInfo, new object [1] { "Config" } );
44 dynAssembly.SetCustomAttribute (attrBuilder);
45 object [] attributes = dynAssembly.GetCustomAttributes (true);
46 attr = attributes [0] as AssemblyConfigurationAttribute;
49 [Test]
50 public void ConfigurationTest ()
52 AssertEquals ("#Testing Configuration",
53 attr.Configuration,
54 "Config");
57 [Test]
58 public void TypeIdTest ()
60 AssertEquals ("#testing Typeid",
61 attr.TypeId,
62 typeof (AssemblyConfigurationAttribute)
66 [Test]
67 public void MatchTestForTrue ()
69 AssertEquals ("#testing Match method-- for true",
70 attr.Match (attr),
71 true);
74 [Test]
75 public void MatchTestForFalse ()
77 AssertEquals ("#testing Match method-- for false",
78 attr.Match (new AssemblyConfigurationAttribute ("abcd")),
79 false);