summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@gmail.com>2022-06-16 23:32:53 +0700
committerPeter Dettman <peter.dettman@gmail.com>2022-06-16 23:32:53 +0700
commit995255e51334878901fca7bfd2069393abd32339 (patch)
treeba38a638250f89e8360963c808e2ed2ac6ed63e2 /crypto
parentImprove MiscTest (diff)
downloadBouncyCastle.NET-ed25519-995255e51334878901fca7bfd2069393abd32339.tar.xz
Alternative for GetExecutingAssembly
Diffstat (limited to 'crypto')
-rw-r--r--crypto/test/src/util/test/SimpleTest.cs22
1 files changed, 15 insertions, 7 deletions
diff --git a/crypto/test/src/util/test/SimpleTest.cs b/crypto/test/src/util/test/SimpleTest.cs
index a40ff2961..b2eb670ff 100644
--- a/crypto/test/src/util/test/SimpleTest.cs
+++ b/crypto/test/src/util/test/SimpleTest.cs
@@ -2,9 +2,6 @@ using System;
 using System.Collections;
 using System.IO;
 using System.Reflection;
-using System.Text;
-
-using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Utilities.Test
 {
@@ -143,7 +140,7 @@ namespace Org.BouncyCastle.Utilities.Test
 		{
 			string fullName = GetFullName(name);
 
-			return Assembly.GetExecutingAssembly().GetManifestResourceStream(fullName);
+			return GetAssembly().GetManifestResourceStream(fullName);
 		}
 
 		internal static string[] GetTestDataEntries(
@@ -152,7 +149,7 @@ namespace Org.BouncyCastle.Utilities.Test
 			string fullPrefix = GetFullName(prefix);
 
 			ArrayList result = new ArrayList();
-			string[] fullNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
+			string[] fullNames = GetAssembly().GetManifestResourceNames();
 			foreach (string fullName in fullNames)
 			{
 				if (fullName.StartsWith(fullPrefix))
@@ -161,10 +158,21 @@ namespace Org.BouncyCastle.Utilities.Test
 					result.Add(name);
 				}
 			}
-			return (string[])result.ToArray(typeof(String));
+			return (string[])result.ToArray(typeof(string));
 		}
 
-		private static string GetFullName(
+        private static Assembly GetAssembly()
+        {
+#if !PORTABLE
+            return Assembly.GetExecutingAssembly();
+#elif NEW_REFLECTION
+            return typeof(SimpleTest).GetTypeInfo().Assembly;
+#else
+            return typeof(SimpleTest).Assembly;
+#endif
+        }
+
+        private static string GetFullName(
 			string name)
 		{
 #if SEPARATE_UNIT_TESTS