1 // AssemblyAlgorithmIdAttributeTest.cs
\r
3 // Author: Vineeth N <nvineeth@yahoo.com>
\r
5 // (C) 2004 Ximian, Inc. http://www.ximian.com
\r
8 using System.Threading;
\r
9 using System.Reflection;
\r
10 using System.Reflection.Emit;
\r
11 using System.Configuration.Assemblies;
\r
12 using NUnit.Framework;
\r
14 namespace MonoTests.System.Reflection {
\r
17 /// Test Fixture for AssemblyAlgorithmIdAttribute class
\r
20 public class AssemblyAlgorithmIdAttributeTest : Assertion
\r
22 private AssemblyBuilder dynAssembly;
\r
23 AssemblyName dynAsmName = new AssemblyName ();
\r
24 AssemblyAlgorithmIdAttribute attr;
\r
26 public AssemblyAlgorithmIdAttributeTest ()
\r
28 //create a dynamic assembly with the required attribute
\r
29 //and check for the validity
\r
31 dynAsmName.Name = "TestAssembly";
\r
33 dynAssembly = Thread.GetDomain ().DefineDynamicAssembly (
\r
34 dynAsmName,AssemblyBuilderAccess.Run
\r
37 // Set the required Attribute of the assembly.
\r
38 Type attribute = typeof (AssemblyAlgorithmIdAttribute);
\r
39 ConstructorInfo ctrInfo = attribute.GetConstructor (
\r
40 new Type [] { typeof (AssemblyHashAlgorithm) }
\r
42 CustomAttributeBuilder attrBuilder =
\r
43 new CustomAttributeBuilder (
\r
45 new object [1] { AssemblyHashAlgorithm.MD5 }
\r
47 dynAssembly.SetCustomAttribute (attrBuilder);
\r
48 object [] attributes = dynAssembly.GetCustomAttributes (true);
\r
49 attr = attributes [0] as AssemblyAlgorithmIdAttribute;
\r
53 public void AlgorithmIdTest()
\r
55 AssertEquals ("#Testing AlgorithmId",
\r
57 (uint) AssemblyHashAlgorithm.MD5);
\r
61 public void TypeIdTest ()
\r
63 AssertEquals ("#testing Typeid",
\r
65 typeof (AssemblyAlgorithmIdAttribute)
\r
71 public void MatchTestForTrue ()
\r
73 AssertEquals ("#testing Match method-- for true",
\r
78 public void MatchTestForFalse ()
\r
80 AssertEquals ("#testing Match method-- for false",
\r
81 attr.Match (new AssemblyAlgorithmIdAttribute (AssemblyHashAlgorithm.SHA1)),
\r