[LoongArch64] Part-5:add loongarch support in some files for LoongArch64. (#21769)
[mono-project.git] / mcs / class / corlib / Test / System.Reflection / AssemblyAlgorithmIdAttributeTest.cs
blob5250a24648e32651a5deb325da63f993388745e0
1 // AssemblyAlgorithmIdAttributeTest.cs
2 //
3 // Author: Vineeth N <nvineeth@yahoo.com>
4 //
5 // (C) 2004 Ximian, Inc. http://www.ximian.com
6 //
8 using System;
9 using System.Threading;
10 using System.Reflection;
11 using System.Reflection.Emit;
12 using System.Configuration.Assemblies;
13 using NUnit.Framework;
15 namespace MonoTests.System.Reflection {
17 /// <summary>
18 /// Test Fixture for AssemblyAlgorithmIdAttribute class
19 /// </summary>
20 [TestFixture]
21 public class AssemblyAlgorithmIdAttributeTest
23 #if !MOBILE
24 private AssemblyBuilder dynAssembly;
25 AssemblyName dynAsmName = new AssemblyName ();
26 AssemblyAlgorithmIdAttribute attr;
28 public AssemblyAlgorithmIdAttributeTest ()
30 //create a dynamic assembly with the required attribute
31 //and check for the validity
33 dynAsmName.Name = "TestAssembly";
35 dynAssembly = Thread.GetDomain ().DefineDynamicAssembly (
36 dynAsmName,AssemblyBuilderAccess.Run
39 // Set the required Attribute of the assembly.
40 Type attribute = typeof (AssemblyAlgorithmIdAttribute);
41 ConstructorInfo ctrInfo = attribute.GetConstructor (
42 new Type [] { typeof (AssemblyHashAlgorithm) }
44 CustomAttributeBuilder attrBuilder =
45 new CustomAttributeBuilder (
46 ctrInfo,
47 new object [1] { AssemblyHashAlgorithm.MD5 }
49 dynAssembly.SetCustomAttribute (attrBuilder);
50 object [] attributes = dynAssembly.GetCustomAttributes (true);
51 attr = attributes [0] as AssemblyAlgorithmIdAttribute;
54 [Test]
55 public void AlgorithmIdTest()
57 Assert.AreEqual (
58 attr.AlgorithmId,
59 (uint) AssemblyHashAlgorithm.MD5, "#1");
62 [Test]
63 public void TypeIdTest ()
65 Assert.AreEqual (
66 attr.TypeId,
67 typeof (AssemblyAlgorithmIdAttribute), "#1"
72 [Test]
73 public void MatchTestForTrue ()
75 Assert.AreEqual (
76 attr.Match (attr),
77 true, "#1");
79 [Test]
80 public void MatchTestForFalse ()
82 Assert.AreEqual (
83 attr.Match (new AssemblyAlgorithmIdAttribute (AssemblyHashAlgorithm.SHA1)),
84 false, "#1");
86 #endif
88 [Test]
89 public void CtorTest ()
91 var a = new AssemblyAlgorithmIdAttribute (AssemblyHashAlgorithm.SHA256);
92 Assert.AreEqual ((uint)AssemblyHashAlgorithm.SHA256, a.AlgorithmId);