public void CanRetrieveModule()
        {
            var    assemblyResolver = new MockAssemblyResolver();
            var    retriever        = new FileModuleTypeLoader(assemblyResolver);
            string assembly         = CompilerHelper.GenerateDynamicModule("FileModuleA", null);
            var    fileModuleInfo   = CreateModuleInfo(assembly, "TestModules.FileModuleAClass", "ModuleA", true, null);

            ManualResetEvent callbackEvent = new ManualResetEvent(false);

            retriever.BeginLoadModuleType(fileModuleInfo, delegate
            {
                callbackEvent.Set();
            });

            callbackEvent.WaitOne(500);

            Assert.AreEqual(assembly, assemblyResolver.LoadAssemblyFromArgument);
        }
        public void ShouldReturnErrorToCallback()
        {
            var assemblyResolver = new MockAssemblyResolver();
            var retriever        = new FileModuleTypeLoader(assemblyResolver);
            var fileModuleInfo   = CreateModuleInfo("NonExistentFile.dll", "NonExistentModule", "NonExistent", true, null);

            ManualResetEvent callbackEvent = new ManualResetEvent(false);

            assemblyResolver.ThrowOnLoadAssemblyFrom = true;
            Exception resultException = null;

            retriever.BeginLoadModuleType(fileModuleInfo, delegate(ModuleInfo moduleInfo, Exception error)
            {
                resultException = error;
                callbackEvent.Set();
            });

            callbackEvent.WaitOne(500);

            Assert.IsNotNull(resultException);
        }