public void CanRetrieveModule() { var assemblyResolver = new MockAssemblyResolver(); var retriever = new FileModuleTypeLoader(assemblyResolver); string assembly = CompilerHelper.GenerateDynamicModule("FileModuleA", null); string assemblyRef = "file://" + assembly; var fileModuleInfo = CreateModuleInfo(assemblyRef, "TestModules.FileModuleAClass", "ModuleA", true, null); bool loadCompleted = false; retriever.LoadModuleCompleted += delegate(object sender, LoadModuleCompletedEventArgs e) { loadCompleted = true; }; retriever.LoadModuleType(fileModuleInfo); Assert.IsTrue(loadCompleted); Assert.AreEqual(assemblyRef, assemblyResolver.LoadAssemblyFromArgument); }
public void ShouldReturnErrorToCallback() { var assemblyResolver = new MockAssemblyResolver(); var retriever = new FileModuleTypeLoader(assemblyResolver); var fileModuleInfo = CreateModuleInfo("NonExistentFile.dll", "NonExistentModule", "NonExistent", true, null); assemblyResolver.ThrowOnLoadAssemblyFrom = true; Exception resultException = null; bool loadCompleted = false; retriever.LoadModuleCompleted += delegate(object sender, LoadModuleCompletedEventArgs e) { loadCompleted = true; resultException = e.Error; }; retriever.LoadModuleType(fileModuleInfo); Assert.IsTrue(loadCompleted); Assert.IsNotNull(resultException); }