mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
This should allow us to remove most of the linker exclusions in [1] since they'd be used and thus not linked away in the tests. Some of the attributes had existing tests but those were under !MOBILE since they're using RefEmit. Added additional tests to those as well. [1] https://github.com/xamarin/xamarin-android/blob/c43c5e671aa57a56f7ba5abc3423e9906af51a83/tests/Xamarin.Android.Bcl-Tests/Resources/LinkerDescription.xml
99 lines
2.2 KiB
C#
99 lines
2.2 KiB
C#
// AssemblyFileVersionAttributeTest.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>
|
|
/// Summary description for AssemblyFileVersionAttributeTest.
|
|
/// </summary>
|
|
[TestFixture]
|
|
public class AssemblyFileVersionAttributeTest {
|
|
|
|
#if !MOBILE
|
|
private AssemblyBuilder dynAssembly;
|
|
AssemblyName dynAsmName = new AssemblyName ();
|
|
AssemblyFileVersionAttribute attr;
|
|
|
|
public AssemblyFileVersionAttributeTest ()
|
|
{
|
|
//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 (AssemblyFileVersionAttribute);
|
|
ConstructorInfo ctrInfo = attribute.GetConstructor (
|
|
new Type [] { typeof(string) }
|
|
);
|
|
CustomAttributeBuilder attrBuilder =
|
|
new CustomAttributeBuilder(ctrInfo, new object [1] { "1.0.0.0" });
|
|
dynAssembly.SetCustomAttribute (attrBuilder);
|
|
object [] attributes = dynAssembly.GetCustomAttributes (true);
|
|
attr = attributes [0] as AssemblyFileVersionAttribute;
|
|
}
|
|
|
|
[Test]
|
|
[ExpectedException (typeof (ArgumentNullException))]
|
|
public void ArgumentNullExceptionTest()
|
|
{
|
|
string version = null;
|
|
new AssemblyFileVersionAttribute (version);
|
|
}
|
|
|
|
[Test]
|
|
public void FileVersionTest ()
|
|
{
|
|
Assert.AreEqual (attr.Version,
|
|
"1.0.0.0", "#1");
|
|
}
|
|
|
|
[Test]
|
|
public void TypeIdTest ()
|
|
{
|
|
Assert.AreEqual (
|
|
attr.TypeId,
|
|
typeof (AssemblyFileVersionAttribute), "#1"
|
|
);
|
|
}
|
|
|
|
[Test]
|
|
public void MatchTestForTrue ()
|
|
{
|
|
Assert.AreEqual (
|
|
attr.Match (attr),
|
|
true, "#1");
|
|
}
|
|
|
|
[Test]
|
|
public void MatchTestForFalse ()
|
|
{
|
|
Assert.AreEqual (
|
|
attr.Match (new AssemblyFileVersionAttribute ("Descrptn")),
|
|
false, "#1");
|
|
}
|
|
#endif
|
|
[Test]
|
|
public void CtorTest ()
|
|
{
|
|
var a = new AssemblyFileVersionAttribute ("1.2.3.4");
|
|
Assert.AreEqual ("1.2.3.4", a.Version);
|
|
}
|
|
}
|
|
}
|
|
|