public async Task LoadAssembly_Returns_Null_From_AppDomain_When_NOT_IsHostAssembly_And_RemoteAssembly() { var sut = new DefaultAssemblyLoadStrategy(); var pluginDependencyContext = this.mockRepository.Create <IPluginDependencyContext>(); var initialPluginLoadDirectory = GetPathToAssemblies(); var someAssembly = Assembly.LoadFile(Path.Combine(initialPluginLoadDirectory, "Newtonsoft.Json.dll")); var someAssemblyName = someAssembly.GetName(); var loadFromDependencyContext = CreateLookupFunction((c, a) => ValueOrProceed <AssemblyFromStrategy> .Proceed()); var loadFromRemote = CreateLookupFunction((c, a) => ValueOrProceed <AssemblyFromStrategy> .Proceed()); var loadFromAppDomain = CreateLookupFunction((c, a) => ValueOrProceed <RuntimeAssemblyShim> .Proceed()); // Mock the fact that it was setup as a host assembly that should be loaded from the host. pluginDependencyContext .Setup(p => p.HostDependencies).Returns(new List <HostDependency> { new HostDependency { DependencyName = someAssemblyName } }); // Mock the fact that it was ALSO setup as a remote assembly that should be loaded from the plugin. pluginDependencyContext .Setup(p => p.RemoteDependencies).Returns(new List <RemoteDependency> { new RemoteDependency { DependencyName = someAssemblyName } }); Assert.IsNull(sut.LoadAssembly(initialPluginLoadDirectory, someAssemblyName, pluginDependencyContext.Object, loadFromDependencyContext, loadFromRemote, loadFromAppDomain)?.Assembly); }
public async Task LoadAssembly_Returns_Null_For_Empty_AssemblyName() { var sut = new DefaultAssemblyLoadStrategy(); var emptyAssemblyname = new AssemblyName(); var initialPluginLoadDirectory = GetPathToAssemblies(); Assert.IsNull(sut.LoadAssembly(initialPluginLoadDirectory, emptyAssemblyname, null, null, null, null)?.Assembly); }
public async Task LoadAssembly_Returns_Null_When_AssemblyName_NotFound() { var sut = new DefaultAssemblyLoadStrategy(); var assemblyname = new AssemblyName("Newtonsoft.Json.dll"); var pluginDependencyContext = this.mockRepository.Create <IPluginDependencyContext>(); var loadFromDependencyContext = CreateLookupFunction((c, a) => ValueOrProceed <AssemblyFromStrategy> .Proceed()); var loadFromRemote = CreateLookupFunction((c, a) => ValueOrProceed <AssemblyFromStrategy> .Proceed()); var loadFromAppDomain = CreateLookupFunction((c, a) => ValueOrProceed <RuntimeAssemblyShim> .Proceed()); var initialPluginLoadDirectory = GetPathToAssemblies(); pluginDependencyContext .Setup(p => p.HostDependencies).Returns(Enumerable.Empty <HostDependency>()); pluginDependencyContext .Setup(p => p.RemoteDependencies).Returns(Enumerable.Empty <RemoteDependency>()); Assert.IsNull(sut.LoadAssembly(initialPluginLoadDirectory, assemblyname, pluginDependencyContext.Object, loadFromDependencyContext, loadFromRemote, loadFromAppDomain)?.Assembly); }
public async Task LoadAssembly_Returns_Assembly_From_Remote() { var sut = new DefaultAssemblyLoadStrategy(); var pluginDependencyContext = this.mockRepository.Create <IPluginDependencyContext>(); var initialPluginLoadDirectory = GetPathToAssemblies(); var someAssembly = Assembly.LoadFile(Path.Combine(initialPluginLoadDirectory, "Newtonsoft.Json.dll")); var someAssemblyName = someAssembly.GetName(); var loadFromDependencyContext = CreateLookupFunction((c, a) => ValueOrProceed <AssemblyFromStrategy> .Proceed()); var loadFromRemote = CreateLookupFunction((c, a) => ValueOrProceed <AssemblyFromStrategy> .FromValue(AssemblyFromStrategy.Releasable(someAssembly), false)); var loadFromAppDomain = CreateLookupFunction((c, a) => ValueOrProceed <RuntimeAssemblyShim> .Proceed()); pluginDependencyContext .Setup(p => p.HostDependencies).Returns(Enumerable.Empty <HostDependency>()); pluginDependencyContext .Setup(p => p.RemoteDependencies).Returns(Enumerable.Empty <RemoteDependency>()); Assert.AreEqual(someAssembly, sut.LoadAssembly(initialPluginLoadDirectory, someAssemblyName, pluginDependencyContext.Object, loadFromDependencyContext, loadFromRemote, loadFromAppDomain)?.Assembly); }