public void RaiseAssemblyRemoved(AssemblyRemovedEventArgs args)
 {
     if (this.assemblyRemoved != null)
     {
         this.assemblyRemoved(this, args);
     }
 }
        public void OnAssemblyRemovedShouldRaisePluginLostForEachPluginInAssembly()
        {
            MockAssemblySource mockSource = new MockAssemblySource();
              PluginExtractor tested = new PluginExtractor(mockSource);

              List<PluginDescriptor> plugins = new List<PluginDescriptor>();
              tested.PluginAdded += (s, e) => plugins.Add(e.Plugin);
              tested.PluginRemoved += (s, e) => plugins.Remove(e.Plugin);

              using (AssemblyReflectionManager manager = new AssemblyReflectionManager())
              {
            string assemblyPath = GetType().Assembly.Location;
            manager.LoadAssembly(assemblyPath);
            mockSource.RaiseAssemblyAdded(new AssemblyAddedEventArgs(assemblyPath, manager));

            AssemblyRemovedEventArgs args = new AssemblyRemovedEventArgs(assemblyPath);
            mockSource.RaiseAssemblyRemoved(args);
              }

              Assert.AreEqual(0, plugins.Count);
        }
        public void OnAssemblyRemovedShouldRaisePluginLostForEachPluginInAssembly()
        {
            MockAssemblySource mockSource = new MockAssemblySource();
            PluginExtractor    tested     = new PluginExtractor(mockSource);

            List <PluginDescriptor> plugins = new List <PluginDescriptor>();

            tested.PluginAdded   += (s, e) => plugins.Add(e.Plugin);
            tested.PluginRemoved += (s, e) => plugins.Remove(e.Plugin);

            using (AssemblyReflectionManager manager = new AssemblyReflectionManager())
            {
                string assemblyPath = GetType().Assembly.Location;
                manager.LoadAssembly(assemblyPath);
                mockSource.RaiseAssemblyAdded(new AssemblyAddedEventArgs(assemblyPath, manager));

                AssemblyRemovedEventArgs args = new AssemblyRemovedEventArgs(assemblyPath);
                mockSource.RaiseAssemblyRemoved(args);
            }

            Assert.AreEqual(0, plugins.Count);
        }
 /// <summary>
 /// Called when a removed assembly is reported from the assembly source.
 /// Lost plugin events are raised for plugins known to reside inside the assembly.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="AssemblyRemovedEventArgs"/> instance containing the event data.</param>
 private void OnAssemblyRemoved(object sender, AssemblyRemovedEventArgs e)
 {
     this.RemovePlugins(e.AssemblyId);
 }
 public void RaiseAssemblyRemoved(AssemblyRemovedEventArgs args)
 {
     if (this.assemblyRemoved != null)
     this.assemblyRemoved(this, args);
 }