| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- // AssemblyCultureAttributeTest.cs
- //
- // Author: Vineeth N <[email protected]>
- //
- // (C) 2004 Ximian, Inc. http://www.ximian.com
- //
- #if !MOBILE
- using System;
- using System.Threading;
- using System.Reflection;
- using System.Reflection.Emit;
- using NUnit.Framework;
- namespace MonoTests.System.Reflection {
- /// <summary>
- /// Test Fixture for AssemblyCultureAttribute
- /// </summary>
- [TestFixture]
- public class AssemblyCultureAttributeTest
- {
- private AssemblyBuilder dynAssembly;
- AssemblyName dynAsmName = new AssemblyName ();
- AssemblyCultureAttribute attr;
- public AssemblyCultureAttributeTest ()
- {
- //create a dynamic assembly with the required attribute
- //and check for the validity
- dynAsmName.Name = "TestAssembly";
- dynAssembly = Thread.GetDomain ().DefineDynamicAssembly (
- dynAsmName,AssemblyBuilderAccess.Run
- );
- // Set the required Attribute of the assembly.
- Type attribute = typeof (AssemblyCultureAttribute);
- ConstructorInfo ctrInfo = attribute.GetConstructor (
- new Type [] { typeof (string) }
- );
- CustomAttributeBuilder attrBuilder =
- new CustomAttributeBuilder (ctrInfo, new object [1] { "India" });
- dynAssembly.SetCustomAttribute (attrBuilder);
- object [] attributes = dynAssembly.GetCustomAttributes(true);
- attr = attributes [0] as AssemblyCultureAttribute;
- }
-
- [Test]
- public void CultureTest ()
- {
- Assert.AreEqual (
- attr.Culture,
- "India", "#1");
- }
- [Test]
- public void TypeIdTest ()
- {
- Assert.AreEqual (
- attr.TypeId,
- typeof (AssemblyCultureAttribute), "#1"
- );
- }
- [Test]
- public void MatchTestForTrue ()
- {
- Assert.AreEqual (
- attr.Match (attr),
- true, "#1");
- }
- [Test]
- public void MatchTestForFalse ()
- {
- Assert.AreEqual (
- attr.Match (new AssemblyCultureAttribute ("Spanish")),
- false, "#1");
- }
- }
- }
- #endif
|