1 // AssemblyAlgorithmIdAttributeTest.cs
3 // Author: Vineeth N <nvineeth@yahoo.com>
5 // (C) 2004 Ximian, Inc. http://www.ximian.com
8 using System.Threading;
9 using System.Reflection;
10 using System.Reflection.Emit;
11 using System.Configuration.Assemblies;
12 using NUnit.Framework;
14 namespace MonoTests.System.Reflection {
17 /// Test Fixture for AssemblyAlgorithmIdAttribute class
20 public class AssemblyAlgorithmIdAttributeTest : Assertion
22 private AssemblyBuilder dynAssembly;
23 AssemblyName dynAsmName = new AssemblyName ();
24 AssemblyAlgorithmIdAttribute attr;
26 public AssemblyAlgorithmIdAttributeTest ()
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 (AssemblyAlgorithmIdAttribute);
39 ConstructorInfo ctrInfo = attribute.GetConstructor (
40 new Type [] { typeof (AssemblyHashAlgorithm) }
42 CustomAttributeBuilder attrBuilder =
43 new CustomAttributeBuilder (
45 new object [1] { AssemblyHashAlgorithm.MD5 }
47 dynAssembly.SetCustomAttribute (attrBuilder);
48 object [] attributes = dynAssembly.GetCustomAttributes (true);
49 attr = attributes [0] as AssemblyAlgorithmIdAttribute;
53 public void AlgorithmIdTest()
55 AssertEquals ("#Testing AlgorithmId",
57 (uint) AssemblyHashAlgorithm.MD5);
61 public void TypeIdTest ()
63 AssertEquals ("#testing Typeid",
65 typeof (AssemblyAlgorithmIdAttribute)
71 public void MatchTestForTrue ()
73 AssertEquals ("#testing Match method-- for true",
78 public void MatchTestForFalse ()
80 AssertEquals ("#testing Match method-- for false",
81 attr.Match (new AssemblyAlgorithmIdAttribute (AssemblyHashAlgorithm.SHA1)),