linux-packaging-mono/mcs/class/corlib/Test/System.Reflection/AssemblyConfigurationAttributeTest.cs
Xamarin Public Jenkins (auto-signing) 6123a772ed Imported Upstream version 5.8.0.88
Former-commit-id: 4b7216ffda08448e562271ce733688e761120fc5
2017-11-28 19:36:51 +00:00

93 lines
2.0 KiB
C#

// AssemblyConfigurationAttributeTest.cs
//
// Author: Vineeth N <nvineeth@yahoo.com>
//
// (C) 2004 Ximian, Inc. http://www.ximian.com
//
using System;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;
using NUnit.Framework;
namespace MonoTests.System.Reflection {
/// <summary>
/// Test Fixture for AssemblyConfigurationAttribute class
/// </summary>
[TestFixture]
public class AssemblyConfigurationAttributeTest
{
#if !MOBILE
private AssemblyBuilder dynAssembly;
AssemblyName dynAsmName = new AssemblyName ();
AssemblyConfigurationAttribute attr;
public AssemblyConfigurationAttributeTest ()
{
//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 (AssemblyConfigurationAttribute);
ConstructorInfo ctrInfo = attribute.GetConstructor (
new Type [] { typeof (string) }
);
CustomAttributeBuilder attrBuilder =
new CustomAttributeBuilder (ctrInfo, new object [1] { "Config" } );
dynAssembly.SetCustomAttribute (attrBuilder);
object [] attributes = dynAssembly.GetCustomAttributes (true);
attr = attributes [0] as AssemblyConfigurationAttribute;
}
[Test]
public void ConfigurationTest ()
{
Assert.AreEqual (
attr.Configuration,
"Config", "#1");
}
[Test]
public void TypeIdTest ()
{
Assert.AreEqual (
attr.TypeId,
typeof (AssemblyConfigurationAttribute)
, "#1");
}
[Test]
public void MatchTestForTrue ()
{
Assert.AreEqual (
attr.Match (attr),
true, "#1");
}
[Test]
public void MatchTestForFalse ()
{
Assert.AreEqual (
attr.Match (new AssemblyConfigurationAttribute ("abcd")),
false, "#1");
}
#endif
[Test]
public void CtorTest ()
{
var a = new AssemblyConfigurationAttribute ("abcd");
Assert.AreEqual ("abcd", a.Configuration);
}
}
}