Imported Upstream version 5.8.0.88

Former-commit-id: 4b7216ffda08448e562271ce733688e761120fc5
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-11-28 19:36:51 +00:00
parent 7d05485754
commit 6123a772ed
277 changed files with 4817 additions and 941 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -18,15 +18,20 @@ namespace MonoTests.System.IO
[TestFixture]
public class StreamReaderTest
{
static string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.System.IO.Tests");
private string _codeFileName = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
private string _tmpFolder;
private string _codeFileName;
private const string TestString = "Hello World!";
[SetUp]
public void SetUp ()
{
if (!Directory.Exists (TempFolder))
Directory.CreateDirectory (TempFolder);
_tmpFolder = Path.GetTempFileName ();
if (File.Exists (_tmpFolder))
File.Delete (_tmpFolder);
_codeFileName = _tmpFolder + Path.DirectorySeparatorChar + "AFile.txt";
if (!Directory.Exists (_tmpFolder))
Directory.CreateDirectory (_tmpFolder);
if (!File.Exists (_codeFileName))
File.Create (_codeFileName).Close ();
@@ -35,8 +40,8 @@ public class StreamReaderTest
[TearDown]
public void TearDown ()
{
if (Directory.Exists (TempFolder))
Directory.Delete (TempFolder, true);
if (Directory.Exists (_tmpFolder))
Directory.Delete (_tmpFolder, true);
}
@@ -245,7 +250,7 @@ public class StreamReaderTest
{
bool errorThrown = false;
try {
new StreamReader(TempFolder + "/nonexistentfile", false);
new StreamReader(_tmpFolder + "/nonexistentfile", false);
} catch (FileNotFoundException) {
errorThrown = true;
} catch (Exception e) {
@@ -256,7 +261,7 @@ public class StreamReaderTest
{
bool errorThrown = false;
try {
new StreamReader(TempFolder + "/nonexistentdir/file", false);
new StreamReader(_tmpFolder + "/nonexistentdir/file", false);
} catch (DirectoryNotFoundException) {
errorThrown = true;
} catch (Exception e) {
@@ -310,7 +315,7 @@ public class StreamReaderTest
{
bool errorThrown = false;
try {
new StreamReader(TempFolder + "/nonexistentfile", true);
new StreamReader(_tmpFolder + "/nonexistentfile", true);
} catch (FileNotFoundException) {
errorThrown = true;
} catch (Exception e) {
@@ -321,7 +326,7 @@ public class StreamReaderTest
{
bool errorThrown = false;
try {
new StreamReader(TempFolder + "/nonexistentdir/file", true);
new StreamReader(_tmpFolder + "/nonexistentdir/file", true);
} catch (DirectoryNotFoundException) {
errorThrown = true;
} catch (Exception e) {

View File

@@ -95,16 +95,23 @@ namespace MonoTests.System.IO
}
}
static string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.System.IO.Tests");
private string _codeFileName = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
private string _thisCodeFileName = TempFolder + Path.DirectorySeparatorChar + "StreamWriterTest.temp";
private string _tmpFolder;
private string _codeFileName;
private string _thisCodeFileName;
[SetUp]
public void SetUp ()
{
if (Directory.Exists (TempFolder))
Directory.Delete (TempFolder, true);
Directory.CreateDirectory (TempFolder);
_tmpFolder = Path.GetTempFileName ();
if (File.Exists (_tmpFolder))
File.Delete (_tmpFolder);
_codeFileName = _tmpFolder + Path.DirectorySeparatorChar + "AFile.txt";
_thisCodeFileName = _tmpFolder + Path.DirectorySeparatorChar + "StreamWriterTest.temp";
if (Directory.Exists (_tmpFolder))
Directory.Delete (_tmpFolder, true);
Directory.CreateDirectory (_tmpFolder);
if (!File.Exists (_thisCodeFileName))
File.Create (_thisCodeFileName).Close ();
@@ -113,8 +120,8 @@ namespace MonoTests.System.IO
[TearDown]
public void TearDown ()
{
if (Directory.Exists (TempFolder))
Directory.Delete (TempFolder, true);
if (Directory.Exists (_tmpFolder))
Directory.Delete (_tmpFolder, true);
}
[Test] // .ctor (Stream)
@@ -182,7 +189,7 @@ namespace MonoTests.System.IO
[Test] // .ctor (String)
public void Constructor2_Path_DirectoryNotFound ()
{
Directory.Delete (TempFolder, true);
Directory.Delete (_tmpFolder, true);
try {
new StreamWriter (_codeFileName);
@@ -192,7 +199,7 @@ namespace MonoTests.System.IO
Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsTrue (ex.Message.IndexOf (TempFolder) != -1, "#5");
Assert.IsTrue (ex.Message.IndexOf (_tmpFolder) != -1, "#5");
}
}
@@ -328,7 +335,7 @@ namespace MonoTests.System.IO
[Test] // .ctor (String, Boolean)
public void Constructor4_Path_DirectoryNotFound ()
{
Directory.Delete (TempFolder, true);
Directory.Delete (_tmpFolder, true);
try {
new StreamWriter (_codeFileName, false);
@@ -338,7 +345,7 @@ namespace MonoTests.System.IO
Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#A2");
Assert.IsNull (ex.InnerException, "#A3");
Assert.IsNotNull (ex.Message, "#A4");
Assert.IsTrue (ex.Message.IndexOf (TempFolder) != -1, "#A5");
Assert.IsTrue (ex.Message.IndexOf (_tmpFolder) != -1, "#A5");
}
try {
@@ -349,7 +356,7 @@ namespace MonoTests.System.IO
Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#B2");
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
Assert.IsTrue (ex.Message.IndexOf (TempFolder) != -1, "#B5");
Assert.IsTrue (ex.Message.IndexOf (_tmpFolder) != -1, "#B5");
}
}
@@ -579,7 +586,7 @@ namespace MonoTests.System.IO
[Test] // .ctor (String, Boolean, Encoding)
public void Constructor6_Path_DirectoryNotFound ()
{
Directory.Delete (TempFolder, true);
Directory.Delete (_tmpFolder, true);
try {
new StreamWriter (_codeFileName, false, Encoding.UTF8);
@@ -589,7 +596,7 @@ namespace MonoTests.System.IO
Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#A2");
Assert.IsNull (ex.InnerException, "#A3");
Assert.IsNotNull (ex.Message, "#A4");
Assert.IsTrue (ex.Message.IndexOf (TempFolder) != -1, "#A5");
Assert.IsTrue (ex.Message.IndexOf (_tmpFolder) != -1, "#A5");
}
try {
@@ -600,7 +607,7 @@ namespace MonoTests.System.IO
Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#B2");
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
Assert.IsTrue (ex.Message.IndexOf (TempFolder) != -1, "#B5");
Assert.IsTrue (ex.Message.IndexOf (_tmpFolder) != -1, "#B5");
}
}
@@ -759,7 +766,7 @@ namespace MonoTests.System.IO
[Test] // .ctor (String, Boolean, Encoding, Int32)
public void Constructor7_Path_DirectoryNotFound ()
{
Directory.Delete (TempFolder, true);
Directory.Delete (_tmpFolder, true);
try {
new StreamWriter (_codeFileName, false, Encoding.UTF8, 10);
@@ -769,7 +776,7 @@ namespace MonoTests.System.IO
Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#A2");
Assert.IsNull (ex.InnerException, "#A3");
Assert.IsNotNull (ex.Message, "#A4");
Assert.IsTrue (ex.Message.IndexOf (TempFolder) != -1, "#A5");
Assert.IsTrue (ex.Message.IndexOf (_tmpFolder) != -1, "#A5");
}
try {
@@ -780,7 +787,7 @@ namespace MonoTests.System.IO
Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#B2");
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
Assert.IsTrue (ex.Message.IndexOf (TempFolder) != -1, "#B5");
Assert.IsTrue (ex.Message.IndexOf (_tmpFolder) != -1, "#B5");
}
}

View File

@@ -298,6 +298,59 @@ namespace MonoTests.System.Reflection.Emit
// (they do not provide an implementation of ToString).
}
[Test]
public void GetArrayMethodMultipleCallsTest ()
{
AssemblyBuilder ab = genAssembly ();
ModuleBuilder modb = ab.DefineDynamicModule ("foo.dll", "foo.dll");
TypeBuilder tb = modb.DefineType ("TestType");
var int2D = typeof (int[,]);
var mb = tb.DefineMethod ("TestMeth", MethodAttributes.Static | MethodAttributes.Public,
typeof(int), new Type[] { int2D });
var ilg = mb.GetILGenerator ();
// static int TestMeth(int[,] a)
// {
// int x;
// x = a.Get(0,0);
// return a.Get(0,1) + x;
// }
//
var x = ilg.DeclareLocal (typeof (int));
ilg.Emit (OpCodes.Ldarg_0);
ilg.Emit (OpCodes.Ldc_I4_0);
ilg.Emit (OpCodes.Ldc_I4_0);
var arrmi = modb.GetArrayMethod (int2D, "Get",
CallingConventions.Standard | CallingConventions.HasThis,
typeof(int),
new Type[] { typeof(int), typeof(int) });
ilg.Emit (OpCodes.Call, arrmi);
ilg.Emit (OpCodes.Stloc, x);
var arrmi2 = modb.GetArrayMethod (int2D, "Get",
CallingConventions.Standard | CallingConventions.HasThis,
typeof(int),
new Type[] { typeof(int), typeof(int) });
ilg.Emit (OpCodes.Ldarg_0);
ilg.Emit (OpCodes.Ldc_I4_0);
ilg.Emit (OpCodes.Ldc_I4_1);
ilg.Emit (OpCodes.Call, arrmi2);
ilg.Emit (OpCodes.Ldloc, x);
ilg.Emit (OpCodes.Add);
ilg.Emit (OpCodes.Ret);
Assert.AreNotSame (arrmi, arrmi2); // fresh MonoArrayMethods each time
var t = tb.CreateType ();
Assert.IsNotNull (t);
var a = new int[,] { { 5, 7 }, { 11, 19 } };
var mi = t.GetMethod ("TestMeth");
Assert.IsNotNull (t);
var o = mi.Invoke (null, new object[] { a });
Assert.AreEqual (12, (int)o);
}
private static void AssertArrayEqualsSorted (Array o1, Array o2)
{
Array s1 = (Array) o1.Clone ();

View File

@@ -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

View File

@@ -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);
}
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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);
}
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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);
}
}
}

View File

@@ -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

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}

Some files were not shown because too many files have changed in this diff Show More