public async Task Load_No_PathToAssembly_Throws_ArgumentNullException() { var loader = new DefaultAssemblyLoader(() => null); var loadContext = new PluginLoadContext("Path To Plugin", this.GetType(), "netcoreapp3.1"); loadContext.FullPathToPluginAssembly = null; await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => loader.Load(loadContext)); }
public void ShouldLoad_Assembly_FileByAssemblyName() { var loader = new DefaultAssemblyLoader(); var assemblyName = AssemblyName.GetAssemblyName("BetterModules.Sample.Module.dll"); var assembly = loader.Load(assemblyName); Assert.IsNotNull(assembly); Assert.IsTrue(assembly.FullName.StartsWith("BetterModules.Sample.Module")); }
public async Task Load_Works() { var mockLoadContext = this.mockRepository.Create <IAssemblyLoadContext>(); var assemblyShim = this.mockRepository.Create <IAssemblyShim>(); var loader = new DefaultAssemblyLoader(() => mockLoadContext.Object); var loadContext = new PluginLoadContext("/home/maarten/assembly.dll", this.GetType(), "netcoreapp3.1"); mockLoadContext.Setup(c => c.LoadPluginAssembly(loadContext)).ReturnsAsync(assemblyShim.Object); var assembly = await loader.Load(loadContext); Assert.AreEqual(assemblyShim.Object, assembly); }
public async Task Load_UnRooted_PathToAssembly_Throws_ArgumentNullException() { var loader = new DefaultAssemblyLoader(() => null); var loadContext = new PluginLoadContext("../testpath", this.GetType(), "netcoreapp3.1"); await Assert.ThrowsExceptionAsync <AssemblyLoadingException>(() => loader.Load(loadContext)); }
public async Task Load_No_Context_Throws_ArgumentNullException() { var loader = new DefaultAssemblyLoader(() => null); await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => loader.Load(null)); }