You've already forked linux-packaging-mono
Imported Upstream version 5.8.0.88
Former-commit-id: 4b7216ffda08448e562271ce733688e761120fc5
This commit is contained in:
parent
7d05485754
commit
6123a772ed
@ -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 (alkpli@microsoft.com)
|
||||
//
|
||||
// (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 (alkpli@microsoft.com)
|
||||
//
|
||||
// (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 (alkpli@microsoft.com)
|
||||
//
|
||||
// (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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 (alkpli@microsoft.com)
|
||||
//
|
||||
// (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 (alkpli@microsoft.com)
|
||||
//
|
||||
// (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 (alkpli@microsoft.com)
|
||||
//
|
||||
// (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 (alkpli@microsoft.com)
|
||||
//
|
||||
// (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 (alkpli@microsoft.com)
|
||||
//
|
||||
// (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 (alkpli@microsoft.com)
|
||||
//
|
||||
// (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 (alkpli@microsoft.com)
|
||||
//
|
||||
// (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 (alkpli@microsoft.com)
|
||||
//
|
||||
// (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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1362,6 +1362,63 @@ namespace MonoTests.System.Reflection
|
||||
Assert.AreEqual ("B", fields.str);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetValueContextBoundObject ()
|
||||
{
|
||||
var instance = new CBOTest ();
|
||||
|
||||
var field1 = typeof (CBOTest).GetField ("d1");
|
||||
var d1 = field1.GetValue (instance);
|
||||
Assert.AreEqual ((double)d1, 14.0, "d1");
|
||||
|
||||
var field2 = typeof (CBOTest).GetField ("d2");
|
||||
var d2 = field2.GetValue (instance);
|
||||
Assert.AreEqual ((double)d2, -20, "d2");
|
||||
|
||||
var field3 = typeof (CBOTest).GetField ("s1");
|
||||
var s1 = field3.GetValue (instance);
|
||||
Assert.AreEqual (s1, "abcd", "s1");
|
||||
|
||||
var field4 = typeof (CBOTest).GetField ("s2");
|
||||
var s2 = field4.GetValue (instance);
|
||||
Assert.AreEqual (s2, "hijkl", "s2");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetValueContextBoundObject ()
|
||||
{
|
||||
var instance = new CBOTest ();
|
||||
|
||||
var field1 = typeof (CBOTest).GetField ("d1");
|
||||
field1.SetValue (instance, 90.3);
|
||||
var d1 = field1.GetValue (instance);
|
||||
Assert.AreEqual ((double)d1, 90.3, "d1");
|
||||
|
||||
var field2 = typeof (CBOTest).GetField ("d2");
|
||||
field2.SetValue (instance, 1);
|
||||
var d2 = field2.GetValue (instance);
|
||||
Assert.AreEqual ((double)d2, 1, "d2");
|
||||
|
||||
var field3 = typeof (CBOTest).GetField ("s1");
|
||||
field3.SetValue (instance, "//////");
|
||||
var s1 = field3.GetValue (instance);
|
||||
Assert.AreEqual (s1, "//////", "s1");
|
||||
|
||||
var field4 = typeof (CBOTest).GetField ("s2");
|
||||
field4.SetValue (instance, "This is a string");
|
||||
var s2 = field4.GetValue (instance);
|
||||
Assert.AreEqual (s2, "This is a string", "s2");
|
||||
|
||||
}
|
||||
|
||||
class CBOTest : ContextBoundObject {
|
||||
public double d1 = 14.0;
|
||||
public double d2 = -20.0;
|
||||
public string s1 = "abcd";
|
||||
public string s2 = "hijkl";
|
||||
}
|
||||
|
||||
|
||||
public IntEnum PPP;
|
||||
|
||||
public class Foo<T>
|
||||
|
Reference in New Issue
Block a user