mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 11:21:08 -10:00
[corlib] Add more Assembly*Attribute tests (#5918)
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
(cherry picked from commit 3df4b8f7f6)
This commit is contained in:
1 parent
3334f96038
commit
5a5ab38c9e
23 files changed
+1720
-21
No files matched your search
@@ -5,8 +5,6 @@
|
||||
// (C) 2004 Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
#if !MONOTOUCH && !FULL_AOT_RUNTIME
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
@@ -22,6 +20,7 @@ namespace MonoTests.System.Reflection {
|
||||
[TestFixture]
|
||||
public class AssemblyAlgorithmIdAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyAlgorithmIdAttribute attr;
|
||||
@@ -84,7 +83,14 @@ namespace MonoTests.System.Reflection {
|
||||
attr.Match (new AssemblyAlgorithmIdAttribute (AssemblyHashAlgorithm.SHA1)),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyAlgorithmIdAttribute (AssemblyHashAlgorithm.SHA256);
|
||||
Assert.AreEqual ((uint)AssemblyHashAlgorithm.SHA256, a.AlgorithmId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// AssemblyCompanyAttributeTest.cs
|
||||
//
|
||||
// Authors:
|
||||
// Alexander Köplinger ([email protected])
|
||||
//
|
||||
// (c) 2017 Microsoft
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Reflection {
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for AssemblyCompanyAttributeTest.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class AssemblyCompanyAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyCompanyAttribute attr;
|
||||
|
||||
public AssemblyCompanyAttributeTest ()
|
||||
{
|
||||
//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 (AssemblyCompanyAttribute);
|
||||
ConstructorInfo ctrInfo = attribute.GetConstructor (
|
||||
new Type [] { typeof (string) }
|
||||
);
|
||||
CustomAttributeBuilder attrBuilder =
|
||||
new CustomAttributeBuilder (ctrInfo, new object [1] { "Xamarin" });
|
||||
dynAssembly.SetCustomAttribute (attrBuilder);
|
||||
object [] attributes = dynAssembly.GetCustomAttributes (true);
|
||||
attr = attributes [0] as AssemblyCompanyAttribute;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CompanyTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Company,
|
||||
"Xamarin", "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TypeIdTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.TypeId,
|
||||
typeof (AssemblyCompanyAttribute), "#1"
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForTrue ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (attr),
|
||||
true, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForFalse ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (new AssemblyCompanyAttribute ("Microsoft")),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyCompanyAttribute ("some text");
|
||||
Assert.AreEqual ("some text", a.Company);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
// (C) 2004 Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
#if !MOBILE
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
@@ -21,6 +19,7 @@ namespace MonoTests.System.Reflection {
|
||||
[TestFixture]
|
||||
public class AssemblyConfigurationAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyConfigurationAttribute attr;
|
||||
@@ -80,7 +79,14 @@ namespace MonoTests.System.Reflection {
|
||||
attr.Match (new AssemblyConfigurationAttribute ("abcd")),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyConfigurationAttribute ("abcd");
|
||||
Assert.AreEqual ("abcd", a.Configuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -5,7 +5,6 @@
|
||||
// (C) 2004 Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
#if !MOBILE
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
@@ -20,6 +19,7 @@ namespace MonoTests.System.Reflection {
|
||||
[TestFixture]
|
||||
public class AssemblyCopyrightAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyCopyrightAttribute attr;
|
||||
@@ -79,7 +79,14 @@ namespace MonoTests.System.Reflection {
|
||||
attr.Match (new AssemblyCopyrightAttribute ("imian")),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyCopyrightAttribute ("abcd");
|
||||
Assert.AreEqual ("abcd", a.Copyright);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -5,8 +5,6 @@
|
||||
// (C) 2004 Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
#if !MOBILE
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
@@ -21,6 +19,7 @@ namespace MonoTests.System.Reflection {
|
||||
[TestFixture]
|
||||
public class AssemblyCultureAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyCultureAttribute attr;
|
||||
@@ -80,7 +79,14 @@ namespace MonoTests.System.Reflection {
|
||||
attr.Match (new AssemblyCultureAttribute ("Spanish")),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyCultureAttribute ("en");
|
||||
Assert.AreEqual ("en", a.Culture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// AssemblyDefaultAliasAttributeTest.cs
|
||||
//
|
||||
// Authors:
|
||||
// Alexander Köplinger ([email protected])
|
||||
//
|
||||
// (c) 2017 Microsoft
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Reflection {
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for AssemblyDefaultAliasAttributeTest.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class AssemblyDefaultAliasAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyDefaultAliasAttribute attr;
|
||||
|
||||
public AssemblyDefaultAliasAttributeTest ()
|
||||
{
|
||||
//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 (AssemblyDefaultAliasAttribute);
|
||||
ConstructorInfo ctrInfo = attribute.GetConstructor (
|
||||
new Type [] { typeof (string) }
|
||||
);
|
||||
CustomAttributeBuilder attrBuilder =
|
||||
new CustomAttributeBuilder (ctrInfo, new object [1] { "corlib" });
|
||||
dynAssembly.SetCustomAttribute (attrBuilder);
|
||||
object [] attributes = dynAssembly.GetCustomAttributes (true);
|
||||
attr = attributes [0] as AssemblyDefaultAliasAttribute;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DefaultAliasTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.DefaultAlias,
|
||||
"corlib", "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TypeIdTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.TypeId,
|
||||
typeof (AssemblyDefaultAliasAttribute), "#1"
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForTrue ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (attr),
|
||||
true, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForFalse ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (new AssemblyDefaultAliasAttribute ("System")),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyDefaultAliasAttribute ("some text");
|
||||
Assert.AreEqual ("some text", a.DefaultAlias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
// (C) 2004 Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
#if !MOBILE
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
@@ -20,6 +19,7 @@ namespace MonoTests.System.Reflection {
|
||||
[TestFixture]
|
||||
public class AssemblyDelaySignAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyDelaySignAttribute attr;
|
||||
@@ -78,7 +78,14 @@ namespace MonoTests.System.Reflection {
|
||||
attr.Match (new AssemblyDelaySignAttribute (true)),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyDelaySignAttribute (true);
|
||||
Assert.AreEqual (true, a.DelaySign);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -5,7 +5,6 @@
|
||||
// (C) 2004 Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
#if !MOBILE
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
@@ -20,6 +19,7 @@ namespace MonoTests.System.Reflection {
|
||||
[TestFixture]
|
||||
public class AssemblyDescriptionAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyDescriptionAttribute attr;
|
||||
@@ -79,7 +79,13 @@ namespace MonoTests.System.Reflection {
|
||||
attr.Match (new AssemblyDescriptionAttribute ("Descrptn")),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyDescriptionAttribute ("some text");
|
||||
Assert.AreEqual ("some text", a.Description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -5,8 +5,6 @@
|
||||
// (C) 2004 Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
#if !MOBILE
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
@@ -21,6 +19,7 @@ namespace MonoTests.System.Reflection {
|
||||
[TestFixture]
|
||||
public class AssemblyFileVersionAttributeTest {
|
||||
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyFileVersionAttribute attr;
|
||||
@@ -87,7 +86,13 @@ namespace MonoTests.System.Reflection {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// AssemblyFlagsAttributeTest.cs
|
||||
//
|
||||
// Authors:
|
||||
// Alexander Köplinger ([email protected])
|
||||
//
|
||||
// (c) 2017 Microsoft
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Reflection {
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for AssemblyFlagsAttributeTest.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class AssemblyFlagsAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyFlagsAttribute attr;
|
||||
|
||||
public AssemblyFlagsAttributeTest ()
|
||||
{
|
||||
//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 (AssemblyFlagsAttribute);
|
||||
ConstructorInfo ctrInfo = attribute.GetConstructor (
|
||||
new Type [] { typeof (AssemblyNameFlags) }
|
||||
);
|
||||
CustomAttributeBuilder attrBuilder =
|
||||
new CustomAttributeBuilder (ctrInfo, new object [1] { AssemblyNameFlags.PublicKey | AssemblyNameFlags.Retargetable });
|
||||
dynAssembly.SetCustomAttribute (attrBuilder);
|
||||
object [] attributes = dynAssembly.GetCustomAttributes (true);
|
||||
attr = attributes [0] as AssemblyFlagsAttribute;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AssemblyFlagsTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.AssemblyFlags,
|
||||
(int)(AssemblyNameFlags.PublicKey | AssemblyNameFlags.Retargetable), "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TypeIdTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.TypeId,
|
||||
typeof (AssemblyFlagsAttribute), "#1"
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForTrue ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (attr),
|
||||
true, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForFalse ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (new AssemblyFlagsAttribute (AssemblyNameFlags.None)),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyFlagsAttribute (AssemblyNameFlags.PublicKey);
|
||||
Assert.AreEqual ((int)AssemblyNameFlags.PublicKey, a.AssemblyFlags);
|
||||
|
||||
a = new AssemblyFlagsAttribute ((int)AssemblyNameFlags.PublicKey);
|
||||
Assert.AreEqual ((int)AssemblyNameFlags.PublicKey, a.AssemblyFlags);
|
||||
|
||||
a = new AssemblyFlagsAttribute ((uint)AssemblyNameFlags.PublicKey);
|
||||
Assert.AreEqual ((uint)AssemblyNameFlags.PublicKey, a.Flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-3
@@ -4,7 +4,6 @@
|
||||
//
|
||||
// (C) 2004 Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
#if !MOBILE
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
@@ -20,6 +19,7 @@ namespace MonoTests.System.Reflection {
|
||||
[TestFixture]
|
||||
public class AssemblyInformationalVersionAttributeTest {
|
||||
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyInformationalVersionAttribute attr;
|
||||
@@ -79,7 +79,12 @@ namespace MonoTests.System.Reflection {
|
||||
attr.Match (new AssemblyInformationalVersionAttribute ("Descrptn")),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyInformationalVersionAttribute ("1.2.3.4");
|
||||
Assert.AreEqual ("1.2.3.4", a.InformationalVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// AssemblyKeyFileAttributeTest.cs
|
||||
//
|
||||
// Authors:
|
||||
// Alexander Köplinger ([email protected])
|
||||
//
|
||||
// (c) 2017 Microsoft
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Reflection {
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for AssemblyKeyFileAttributeTest.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class AssemblyKeyFileAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyKeyFileAttribute attr;
|
||||
|
||||
public AssemblyKeyFileAttributeTest ()
|
||||
{
|
||||
//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 (AssemblyKeyFileAttribute);
|
||||
ConstructorInfo ctrInfo = attribute.GetConstructor (
|
||||
new Type [] { typeof (string) }
|
||||
);
|
||||
CustomAttributeBuilder attrBuilder =
|
||||
new CustomAttributeBuilder (ctrInfo, new object [1] { "test.snk" });
|
||||
dynAssembly.SetCustomAttribute (attrBuilder);
|
||||
object [] attributes = dynAssembly.GetCustomAttributes (true);
|
||||
attr = attributes [0] as AssemblyKeyFileAttribute;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void KeyFileTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.KeyFile,
|
||||
"test.snk", "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TypeIdTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.TypeId,
|
||||
typeof (AssemblyKeyFileAttribute), "#1"
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForTrue ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (attr),
|
||||
true, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForFalse ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (new AssemblyKeyFileAttribute ("other.snk")),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyKeyFileAttribute ("some text");
|
||||
Assert.AreEqual ("some text", a.KeyFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// AssemblyKeyNameAttributeTest.cs
|
||||
//
|
||||
// Authors:
|
||||
// Alexander Köplinger ([email protected])
|
||||
//
|
||||
// (c) 2017 Microsoft
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Reflection {
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for AssemblyKeyNameAttributeTest.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class AssemblyKeyNameAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyKeyNameAttribute attr;
|
||||
|
||||
public AssemblyKeyNameAttributeTest ()
|
||||
{
|
||||
//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 (AssemblyKeyNameAttribute);
|
||||
ConstructorInfo ctrInfo = attribute.GetConstructor (
|
||||
new Type [] { typeof (string) }
|
||||
);
|
||||
CustomAttributeBuilder attrBuilder =
|
||||
new CustomAttributeBuilder (ctrInfo, new object [1] { "MyKey" });
|
||||
dynAssembly.SetCustomAttribute (attrBuilder);
|
||||
object [] attributes = dynAssembly.GetCustomAttributes (true);
|
||||
attr = attributes [0] as AssemblyKeyNameAttribute;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void KeyNameTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.KeyName,
|
||||
"MyKey", "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TypeIdTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.TypeId,
|
||||
typeof (AssemblyKeyNameAttribute), "#1"
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForTrue ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (attr),
|
||||
true, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForFalse ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (new AssemblyKeyNameAttribute ("OtherKey")),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyKeyNameAttribute ("some text");
|
||||
Assert.AreEqual ("some text", a.KeyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
//
|
||||
// AssemblyMetadataAttributeTest.cs
|
||||
//
|
||||
// Authors:
|
||||
// Alexander Köplinger ([email protected])
|
||||
//
|
||||
// (c) 2017 Microsoft
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Reflection {
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for AssemblyMetadataAttributeTest.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class AssemblyMetadataAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyMetadataAttribute attr;
|
||||
|
||||
public AssemblyMetadataAttributeTest ()
|
||||
{
|
||||
//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 (AssemblyMetadataAttribute);
|
||||
ConstructorInfo ctrInfo = attribute.GetConstructor (
|
||||
new Type [] { typeof (string), typeof (string) }
|
||||
);
|
||||
CustomAttributeBuilder attrBuilder =
|
||||
new CustomAttributeBuilder (ctrInfo, new object [2] { "MyKey", "MyValue" });
|
||||
dynAssembly.SetCustomAttribute (attrBuilder);
|
||||
object [] attributes = dynAssembly.GetCustomAttributes (true);
|
||||
attr = attributes [0] as AssemblyMetadataAttribute;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MetadataTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Key,
|
||||
"MyKey", "#1");
|
||||
Assert.AreEqual (
|
||||
attr.Value,
|
||||
"MyValue", "#2");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TypeIdTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.TypeId,
|
||||
typeof (AssemblyMetadataAttribute), "#1"
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForTrue ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (attr),
|
||||
true, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForFalse ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (new AssemblyMetadataAttribute ("OtherKey", "OtherValue")),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyMetadataAttribute ("some text", "some other text");
|
||||
Assert.AreEqual ("some text", a.Key);
|
||||
Assert.AreEqual ("some other text", a.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// AssemblyProductAttributeTest.cs
|
||||
//
|
||||
// Authors:
|
||||
// Alexander Köplinger ([email protected])
|
||||
//
|
||||
// (c) 2017 Microsoft
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Reflection {
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for AssemblyProductAttributeTest.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class AssemblyProductAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyProductAttribute attr;
|
||||
|
||||
public AssemblyProductAttributeTest ()
|
||||
{
|
||||
//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 (AssemblyProductAttribute);
|
||||
ConstructorInfo ctrInfo = attribute.GetConstructor (
|
||||
new Type [] { typeof (string) }
|
||||
);
|
||||
CustomAttributeBuilder attrBuilder =
|
||||
new CustomAttributeBuilder (ctrInfo, new object [1] { "Mono" });
|
||||
dynAssembly.SetCustomAttribute (attrBuilder);
|
||||
object [] attributes = dynAssembly.GetCustomAttributes (true);
|
||||
attr = attributes [0] as AssemblyProductAttribute;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ProductTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Product,
|
||||
"Mono", "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TypeIdTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.TypeId,
|
||||
typeof (AssemblyProductAttribute), "#1"
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForTrue ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (attr),
|
||||
true, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForFalse ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (new AssemblyProductAttribute ("Java")),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyProductAttribute ("some text");
|
||||
Assert.AreEqual ("some text", a.Product);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
//
|
||||
// AssemblySignatureKeyAttributeTest.cs
|
||||
//
|
||||
// Authors:
|
||||
// Alexander Köplinger ([email protected])
|
||||
//
|
||||
// (c) 2017 Microsoft
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Reflection {
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for AssemblySignatureKeyAttributeTest.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class AssemblySignatureKeyAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblySignatureKeyAttribute attr;
|
||||
|
||||
public AssemblySignatureKeyAttributeTest ()
|
||||
{
|
||||
//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 (AssemblySignatureKeyAttribute);
|
||||
ConstructorInfo ctrInfo = attribute.GetConstructor (
|
||||
new Type [] { typeof (string), typeof (string) }
|
||||
);
|
||||
CustomAttributeBuilder attrBuilder =
|
||||
new CustomAttributeBuilder (ctrInfo, new object [2] { "PublicKey", "CounterSignature" });
|
||||
dynAssembly.SetCustomAttribute (attrBuilder);
|
||||
object [] attributes = dynAssembly.GetCustomAttributes (true);
|
||||
attr = attributes [0] as AssemblySignatureKeyAttribute;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SignatureKeyTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.PublicKey,
|
||||
"PublicKey", "#1");
|
||||
Assert.AreEqual (
|
||||
attr.Countersignature,
|
||||
"CounterSignature", "#2");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TypeIdTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.TypeId,
|
||||
typeof (AssemblySignatureKeyAttribute), "#1"
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForTrue ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (attr),
|
||||
true, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForFalse ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (new AssemblySignatureKeyAttribute ("OtherPublicKey", "OtherCounterSignature")),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblySignatureKeyAttribute ("some text", "some other text");
|
||||
Assert.AreEqual ("some text", a.PublicKey);
|
||||
Assert.AreEqual ("some other text", a.Countersignature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// AssemblyTitleAttributeTest.cs
|
||||
//
|
||||
// Authors:
|
||||
// Alexander Köplinger ([email protected])
|
||||
//
|
||||
// (c) 2017 Microsoft
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Reflection {
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for AssemblyTitleAttributeTest.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class AssemblyTitleAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyTitleAttribute attr;
|
||||
|
||||
public AssemblyTitleAttributeTest ()
|
||||
{
|
||||
//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 (AssemblyTitleAttribute);
|
||||
ConstructorInfo ctrInfo = attribute.GetConstructor (
|
||||
new Type [] { typeof (string) }
|
||||
);
|
||||
CustomAttributeBuilder attrBuilder =
|
||||
new CustomAttributeBuilder (ctrInfo, new object [1] { "The Assembly" });
|
||||
dynAssembly.SetCustomAttribute (attrBuilder);
|
||||
object [] attributes = dynAssembly.GetCustomAttributes (true);
|
||||
attr = attributes [0] as AssemblyTitleAttribute;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TitleTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Title,
|
||||
"The Assembly", "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TypeIdTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.TypeId,
|
||||
typeof (AssemblyTitleAttribute), "#1"
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForTrue ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (attr),
|
||||
true, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForFalse ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (new AssemblyTitleAttribute ("Not The Assembly")),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyTitleAttribute ("some text");
|
||||
Assert.AreEqual ("some text", a.Title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// AssemblyTrademarkAttributeTest.cs
|
||||
//
|
||||
// Authors:
|
||||
// Alexander Köplinger ([email protected])
|
||||
//
|
||||
// (c) 2017 Microsoft
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Reflection {
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for AssemblyTrademarkAttributeTest.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class AssemblyTrademarkAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyTrademarkAttribute attr;
|
||||
|
||||
public AssemblyTrademarkAttributeTest ()
|
||||
{
|
||||
//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 (AssemblyTrademarkAttribute);
|
||||
ConstructorInfo ctrInfo = attribute.GetConstructor (
|
||||
new Type [] { typeof (string) }
|
||||
);
|
||||
CustomAttributeBuilder attrBuilder =
|
||||
new CustomAttributeBuilder (ctrInfo, new object [1] { "(c) Xamarin" });
|
||||
dynAssembly.SetCustomAttribute (attrBuilder);
|
||||
object [] attributes = dynAssembly.GetCustomAttributes (true);
|
||||
attr = attributes [0] as AssemblyTrademarkAttribute;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TrademarkTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Trademark,
|
||||
"(c) Xamarin", "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TypeIdTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.TypeId,
|
||||
typeof (AssemblyTrademarkAttribute), "#1"
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForTrue ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (attr),
|
||||
true, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForFalse ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (new AssemblyTrademarkAttribute ("(c) Microsoft")),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyTrademarkAttribute ("some text");
|
||||
Assert.AreEqual ("some text", a.Trademark);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// AssemblyVersionAttributeTest.cs
|
||||
//
|
||||
// Authors:
|
||||
// Alexander Köplinger ([email protected])
|
||||
//
|
||||
// (c) 2017 Microsoft
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Reflection {
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for AssemblyVersionAttributeTest.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class AssemblyVersionAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AssemblyVersionAttribute attr;
|
||||
|
||||
public AssemblyVersionAttributeTest ()
|
||||
{
|
||||
//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 (AssemblyVersionAttribute);
|
||||
ConstructorInfo ctrInfo = attribute.GetConstructor (
|
||||
new Type [] { typeof (string) }
|
||||
);
|
||||
CustomAttributeBuilder attrBuilder =
|
||||
new CustomAttributeBuilder (ctrInfo, new object [1] { "1.2.3.4" });
|
||||
dynAssembly.SetCustomAttribute (attrBuilder);
|
||||
object [] attributes = dynAssembly.GetCustomAttributes (true);
|
||||
attr = attributes [0] as AssemblyVersionAttribute;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void VersionTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Version,
|
||||
"1.2.3.4", "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TypeIdTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.TypeId,
|
||||
typeof (AssemblyVersionAttribute), "#1"
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForTrue ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (attr),
|
||||
true, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForFalse ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (new AssemblyVersionAttribute ("2.0.0.0")),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AssemblyVersionAttribute ("some text");
|
||||
Assert.AreEqual ("some text", a.Version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
//
|
||||
// DllImportAttributeTest.cs
|
||||
//
|
||||
// Authors:
|
||||
// Alexander Köplinger ([email protected])
|
||||
//
|
||||
// (c) 2017 Microsoft
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Runtime.InteropServices;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Runtime.InteropServices {
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for DllImportAttributeTest.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class DllImportAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
DllImportAttribute attr;
|
||||
|
||||
public DllImportAttributeTest ()
|
||||
{
|
||||
//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 (DllImportAttribute);
|
||||
ConstructorInfo ctrInfo = attribute.GetConstructor (
|
||||
new Type [] { typeof (string) }
|
||||
);
|
||||
CustomAttributeBuilder attrBuilder =
|
||||
new CustomAttributeBuilder (ctrInfo, new object [1] { "libc.dylib" });
|
||||
dynAssembly.SetCustomAttribute (attrBuilder);
|
||||
object [] attributes = dynAssembly.GetCustomAttributes (true);
|
||||
attr = attributes [0] as DllImportAttribute;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DllImportTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Value,
|
||||
"libc.dylib", "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TypeIdTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.TypeId,
|
||||
typeof (DllImportAttribute), "#1"
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForTrue ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (attr),
|
||||
true, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForFalse ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (new DllImportAttribute ("libcups.dylib")),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new DllImportAttribute ("some text");
|
||||
Assert.AreEqual ("some text", a.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FieldsTest ()
|
||||
{
|
||||
var a = new DllImportAttribute ("libc.dylib");
|
||||
|
||||
Assert.Null (a.EntryPoint);
|
||||
Assert.AreEqual ((CharSet)0, a.CharSet);
|
||||
Assert.False (a.SetLastError);
|
||||
Assert.False (a.ExactSpelling);
|
||||
Assert.AreEqual ((CallingConvention)0, a.CallingConvention);
|
||||
Assert.False (a.BestFitMapping);
|
||||
Assert.False (a.PreserveSig);
|
||||
Assert.False (a.ThrowOnUnmappableChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
//
|
||||
// MarshalAsAttributeTest.cs
|
||||
//
|
||||
// Authors:
|
||||
// Alexander Köplinger ([email protected])
|
||||
//
|
||||
// (c) 2017 Microsoft
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Runtime.InteropServices;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Runtime.InteropServices {
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for MarshalAsAttributeTest.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class MarshalAsAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
MarshalAsAttribute attr;
|
||||
|
||||
public MarshalAsAttributeTest ()
|
||||
{
|
||||
//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 (MarshalAsAttribute);
|
||||
ConstructorInfo ctrInfo = attribute.GetConstructor (
|
||||
new Type [] { typeof (UnmanagedType) }
|
||||
);
|
||||
CustomAttributeBuilder attrBuilder =
|
||||
new CustomAttributeBuilder (ctrInfo, new object [1] { UnmanagedType.LPWStr });
|
||||
dynAssembly.SetCustomAttribute (attrBuilder);
|
||||
object [] attributes = dynAssembly.GetCustomAttributes (true);
|
||||
attr = attributes [0] as MarshalAsAttribute;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MarshalAsTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Value,
|
||||
UnmanagedType.LPWStr, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TypeIdTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.TypeId,
|
||||
typeof (MarshalAsAttribute), "#1"
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForTrue ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (attr),
|
||||
true, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForFalse ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (new MarshalAsAttribute (UnmanagedType.Bool)),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new MarshalAsAttribute (UnmanagedType.Bool);
|
||||
Assert.AreEqual (UnmanagedType.Bool, a.Value);
|
||||
|
||||
a = new MarshalAsAttribute ((short)UnmanagedType.Bool);
|
||||
Assert.AreEqual (UnmanagedType.Bool, a.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FieldsTest ()
|
||||
{
|
||||
var a = new MarshalAsAttribute (UnmanagedType.Bool);
|
||||
|
||||
Assert.Null (a.MarshalCookie);
|
||||
Assert.Null (a.MarshalType);
|
||||
Assert.Null (a.MarshalTypeRef);
|
||||
Assert.Null (a.SafeArrayUserDefinedSubType);
|
||||
Assert.AreEqual ((UnmanagedType)0, a.ArraySubType);
|
||||
Assert.AreEqual (VarEnum.VT_EMPTY, a.SafeArraySubType);
|
||||
Assert.AreEqual (0, a.SizeConst);
|
||||
Assert.AreEqual (0, a.IidParameterIndex);
|
||||
Assert.AreEqual (0, a.SizeParamIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
//
|
||||
// AttributeUsageAttributeTest.cs
|
||||
//
|
||||
// Authors:
|
||||
// Alexander Köplinger ([email protected])
|
||||
//
|
||||
// (c) 2017 Microsoft
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System {
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for AttributeUsageAttributeTest.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class AttributeUsageAttributeTest
|
||||
{
|
||||
#if !MOBILE
|
||||
private AssemblyBuilder dynAssembly;
|
||||
AssemblyName dynAsmName = new AssemblyName ();
|
||||
AttributeUsageAttribute attr;
|
||||
|
||||
public AttributeUsageAttributeTest ()
|
||||
{
|
||||
//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 (AttributeUsageAttribute);
|
||||
ConstructorInfo ctrInfo = attribute.GetConstructor (
|
||||
new Type [] { typeof (AttributeTargets) }
|
||||
);
|
||||
CustomAttributeBuilder attrBuilder =
|
||||
new CustomAttributeBuilder (ctrInfo, new object [1] { AttributeTargets.Assembly });
|
||||
dynAssembly.SetCustomAttribute (attrBuilder);
|
||||
object [] attributes = dynAssembly.GetCustomAttributes (true);
|
||||
attr = attributes [0] as AttributeUsageAttribute;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AttributeUsageTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.ValidOn,
|
||||
AttributeTargets.Assembly, "#1");
|
||||
Assert.AreEqual (
|
||||
attr.AllowMultiple,
|
||||
false, "#2");
|
||||
Assert.AreEqual (
|
||||
attr.Inherited,
|
||||
true, "#3");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TypeIdTest ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.TypeId,
|
||||
typeof (AttributeUsageAttribute), "#1"
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForTrue ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (attr),
|
||||
true, "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchTestForFalse ()
|
||||
{
|
||||
Assert.AreEqual (
|
||||
attr.Match (new AttributeUsageAttribute (AttributeTargets.Method)),
|
||||
false, "#1");
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void CtorTest ()
|
||||
{
|
||||
var a = new AttributeUsageAttribute (AttributeTargets.Method);
|
||||
Assert.AreEqual (AttributeTargets.Method, a.ValidOn);
|
||||
Assert.False (a.AllowMultiple);
|
||||
Assert.True (a.Inherited);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyTest ()
|
||||
{
|
||||
var a = new AttributeUsageAttribute (AttributeTargets.Method | AttributeTargets.Class);
|
||||
a.AllowMultiple = true;
|
||||
a.Inherited = false;
|
||||
Assert.AreEqual (AttributeTargets.Method | AttributeTargets.Class, a.ValidOn);
|
||||
Assert.True (a.AllowMultiple);
|
||||
Assert.False (a.Inherited);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ System/ArrayTest.cs
|
||||
System/ArraySortArgChecks.cs
|
||||
System/ArraySegmentTest.cs
|
||||
System/AttributeTest.cs
|
||||
System/AttributeUsageAttributeTest.cs
|
||||
System/BadImageFormatExceptionTest.cs
|
||||
System/BitConverterTest.cs
|
||||
System/BooleanTest.cs
|
||||
@@ -131,12 +132,23 @@ System/ObjectTest.cs
|
||||
System/RandomTest.cs
|
||||
System.Reflection/AssemblyAlgorithmIdAttributeTest.cs
|
||||
System.Reflection/AssemblyConfigurationAttributeTest.cs
|
||||
System.Reflection/AssemblyCompanyAttributeTest.cs
|
||||
System.Reflection/AssemblyCopyrightAttributeTest.cs
|
||||
System.Reflection/AssemblyCultureAttributeTest.cs
|
||||
System.Reflection/AssemblyDefaultAliasAttributeTest.cs
|
||||
System.Reflection/AssemblyDelaySignAttributeTest.cs
|
||||
System.Reflection/AssemblyDescriptionAttributeTest.cs
|
||||
System.Reflection/AssemblyFileVersionAttributeTest.cs
|
||||
System.Reflection/AssemblyFlagsAttributeTest.cs
|
||||
System.Reflection/AssemblyInformationalVersionAttributeTest.cs
|
||||
System.Reflection/AssemblyKeyFileAttributeTest.cs
|
||||
System.Reflection/AssemblyKeyNameAttributeTest.cs
|
||||
System.Reflection/AssemblyMetadataAttributeTest.cs
|
||||
System.Reflection/AssemblyProductAttributeTest.cs
|
||||
System.Reflection/AssemblySignatureKeyAttributeTest.cs
|
||||
System.Reflection/AssemblyTitleAttributeTest.cs
|
||||
System.Reflection/AssemblyTrademarkAttributeTest.cs
|
||||
System.Reflection/AssemblyVersionAttributeTest.cs
|
||||
System.Reflection/AssemblyNameTest.cs
|
||||
System.Reflection/AssemblyTest.cs
|
||||
System.Reflection/BinderTests.cs
|
||||
@@ -193,8 +205,10 @@ System.Runtime.CompilerServices/TaskAwaiterTest.cs
|
||||
System.Runtime.CompilerServices/TaskAwaiterTest_T.cs
|
||||
System.Runtime.CompilerServices/YieldAwaitableTest.cs
|
||||
System.Runtime.ExceptionServices/ExceptionDispatchInfoTest.cs
|
||||
System.Runtime.InteropServices/DllImportAttributeTest.cs
|
||||
System.Runtime.InteropServices/ExternalExceptionTest.cs
|
||||
System.Runtime.InteropServices/GCHandleTest.cs
|
||||
System.Runtime.InteropServices/MarshalAsAttributeTest.cs
|
||||
System.Runtime.InteropServices/MarshalTest.cs
|
||||
System.Runtime.InteropServices/RuntimeEnvironmentTest.cs
|
||||
System.Runtime.InteropServices/SafeHandleTest.cs
|
||||
|
||||
Reference in new issue
Block a user