**** Merged from MCS ****
[mono-project.git] / mcs / class / corlib / Test / System.Reflection / AssemblyFileVersionAttributeTest.cs
blob7e66d1cd36bc657cff2653e781a45179d7a9c713
1 // AssemblyFileVersionAttributeTest.cs
2 //
3 // Author: Vineeth N <nvineeth@yahoo.com>
4 //
5 // (C) 2004 Ximian, Inc. http://www.ximian.com
6 //
7 using System;
8 using System.Threading;
9 using System.Reflection;
10 using System.Reflection.Emit;
11 using NUnit.Framework;
13 namespace MonoTests.System.Reflection {
15 /// <summary>
16 /// Summary description for AssemblyFileVersionAttributeTest.
17 /// </summary>
18 [TestFixture]
19 public class AssemblyFileVersionAttributeTest : Assertion {
21 private AssemblyBuilder dynAssembly;
22 AssemblyName dynAsmName = new AssemblyName ();
23 AssemblyFileVersionAttribute attr;
25 public AssemblyFileVersionAttributeTest ()
27 //create a dynamic assembly with the required attribute
28 //and check for the validity
30 dynAsmName.Name = "TestAssembly";
32 dynAssembly = Thread.GetDomain ().DefineDynamicAssembly (
33 dynAsmName,AssemblyBuilderAccess.Run
36 // Set the required Attribute of the assembly.
37 Type attribute = typeof (AssemblyFileVersionAttribute);
38 ConstructorInfo ctrInfo = attribute.GetConstructor (
39 new Type [] { typeof(string) }
41 CustomAttributeBuilder attrBuilder =
42 new CustomAttributeBuilder(ctrInfo, new object [1] { "1.0.0.0" });
43 dynAssembly.SetCustomAttribute (attrBuilder);
44 object [] attributes = dynAssembly.GetCustomAttributes (true);
45 attr = attributes [0] as AssemblyFileVersionAttribute;
48 [Test]
49 [ExpectedException (typeof (ArgumentNullException))]
50 public void ArgumentNullExceptionTest()
52 string version = null;
53 new AssemblyFileVersionAttribute (version);
56 [Test]
57 public void FileVersionTest ()
59 AssertEquals ("#Testing FileVersion",
60 attr.Version,
61 "1.0.0.0");
64 [Test]
65 public void TypeIdTest ()
67 AssertEquals ("#testing Typeid",
68 attr.TypeId,
69 typeof (AssemblyFileVersionAttribute)
73 [Test]
74 public void MatchTestForTrue ()
76 AssertEquals ("#testing Match method-- for true",
77 attr.Match (attr),
78 true);
81 [Test]
82 public void MatchTestForFalse ()
84 AssertEquals ("#testing Match method-- for false",
85 attr.Match (new AssemblyFileVersionAttribute ("Descrptn")),
86 false);