Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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"));
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 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));
 }
Esempio n. 5
0
 public async Task Load_No_Context_Throws_ArgumentNullException()
 {
     var loader = new DefaultAssemblyLoader(() => null);
     await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => loader.Load(null));
 }