| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- // AssemblyInformationalVersionAttributeTest.cs
- //
- // Author: Vineeth N <[email protected]>
- //
- // (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 AssemblyInformationalVersionAttribute.
- /// </summary>
- [TestFixture]
- public class AssemblyInformationalVersionAttributeTest {
- #if !MOBILE
- private AssemblyBuilder dynAssembly;
- AssemblyName dynAsmName = new AssemblyName ();
- AssemblyInformationalVersionAttribute attr;
-
- public AssemblyInformationalVersionAttributeTest ()
- {
- //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 (AssemblyInformationalVersionAttribute);
- ConstructorInfo ctrInfo = attribute.GetConstructor (
- new Type [] { typeof (string) }
- );
- CustomAttributeBuilder attrBuilder =
- new CustomAttributeBuilder (ctrInfo, new object [1] { "2.0.0.0" });
- dynAssembly.SetCustomAttribute (attrBuilder);
- object [] attributes = dynAssembly.GetCustomAttributes (true);
- attr = attributes [0] as AssemblyInformationalVersionAttribute;
- }
- [Test]
- public void InformationalVersionTest ()
- {
- Assert.AreEqual (attr.InformationalVersion,
- "2.0.0.0", "#1");
- }
- [Test]
- public void TypeIdTest ()
- {
- Assert.AreEqual (
- attr.TypeId,
- typeof (AssemblyInformationalVersionAttribute), "#1"
- );
- }
- [Test]
- public void MatchTestForTrue ()
- {
- Assert.AreEqual (
- attr.Match (attr),
- true, "#1");
- }
- [Test]
- public void MatchTestForFalse ()
- {
-
- Assert.AreEqual (
- attr.Match (new AssemblyInformationalVersionAttribute ("Descrptn")),
- false, "#1");
- }
- #endif
- [Test]
- public void CtorTest ()
- {
- var a = new AssemblyInformationalVersionAttribute ("1.2.3.4");
- Assert.AreEqual ("1.2.3.4", a.InformationalVersion);
- }
- }
- }
|