Add Assembly.LoadWithPartialName cases (dotnet/corefx#36803)
authorSteve MacLean <stmaclea@microsoft.com>
Sun, 14 Apr 2019 01:57:06 +0000 (21:57 -0400)
committerGitHub <noreply@github.com>
Sun, 14 Apr 2019 01:57:06 +0000 (21:57 -0400)
* Add Assembly.LoadWithPartialName cases

Cover hole reported in dotnet/coreclrdotnet/corefx#19817

* Verify argument parameter name

* Disable new test on .NetFramework

Commit migrated from https://github.com/dotnet/corefx/commit/5ae3c5655cd84bf3c7f9568477153642fdd7c95e

src/libraries/System.Reflection/tests/AssemblyTests.cs

index f394ca5..f06eea9 100644 (file)
@@ -465,6 +465,16 @@ namespace System.Reflection.Tests
             string simpleName = typeof(AssemblyTests).Assembly.GetName().Name;
             var assembly = Assembly.LoadWithPartialName(simpleName);
             Assert.Equal(typeof(AssemblyTests).Assembly, assembly);
+        }
+
+        [Fact]
+        [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.LoadFromWithPartialName() not supported on UapAot")]
+        [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
+        public void LoadWithPartialName_Neg()
+        {
+            AssertExtensions.Throws<ArgumentNullException>("partialName", () => Assembly.LoadWithPartialName(null));
+            AssertExtensions.Throws<ArgumentException>("partialName", () => Assembly.LoadWithPartialName(""));
+            Assert.Null(Assembly.LoadWithPartialName("no such assembly"));
         }        
 #pragma warning restore 618
 
@@ -680,6 +690,8 @@ namespace System.Reflection.Tests
         
             string emptyCName = new string('\0', 1);
             AssertExtensions.Throws<ArgumentException>(null, () => Assembly.Load(emptyCName));
+
+            Assert.Throws<FileNotFoundException>(() => Assembly.Load("no such assembly")); // No such assembly
         }
 
         [Fact]