public void ForgetLostPlugins()
        {
            PluginRepository tested = new PluginRepository();
              MockPluginSource pluginSource = new MockPluginSource();
              tested.AddPluginSource(pluginSource);

              PluginDescriptor thePlugin = new PluginDescriptor()
              {
            QualifiedName = typeof(UnitTest_PluginRepository)
              };

              pluginSource.RaisePluginAdded(thePlugin);

              var pluginsBefore = tested.Plugins(null).ToArray();
              pluginSource.RaisePluginRemoved(thePlugin);
              var pluginsAfter = tested.Plugins(null).ToArray();

              Assert.IsTrue(pluginsAfter.Length - pluginsBefore.Length == -1);
              Assert.IsFalse(pluginsAfter.Contains(thePlugin));
        }
        public void RememberFoundPlugins()
        {
            PluginRepository tested = new PluginRepository();
              MockPluginSource pluginSource = new MockPluginSource();
              tested.AddPluginSource(pluginSource);

              var pluginsBefore = tested.Plugins(null).ToArray();
              PluginDescriptor thePlugin = new PluginDescriptor()
              {
            QualifiedName = typeof(UnitTest_PluginRepository)
              };

              pluginSource.RaisePluginAdded(thePlugin);

              var pluginsAfter = tested.Plugins(null).ToArray();

              Assert.IsTrue(pluginsAfter.Length - pluginsBefore.Length == 1);
              Assert.AreSame(thePlugin, pluginsAfter.Except(pluginsBefore).First());
        }
        public void ShouldOnlyReportPluginsThatMatchesFilter()
        {
            PluginRepository tested = new PluginRepository();
              MockPluginSource pluginSource = new MockPluginSource();
              tested.AddPluginSource(pluginSource);

              PluginDescriptor plugin1 = new PluginDescriptor()
              {
            QualifiedName = typeof(MockPlugin1),
            Name = "plugin1"
              };

              PluginDescriptor plugin2 = new PluginDescriptor()
              {
            QualifiedName = typeof(MockPlugin2),
            Name = "plugin2"
              };

              pluginSource.RaisePluginAdded(plugin1);
              pluginSource.RaisePluginAdded(plugin2);

              PluginFilter filter = PluginFilter.Create.IsNamed("plugin1");
              var foundPlugins = tested.Plugins(filter);

              Assert.AreEqual(1, foundPlugins.Count());
              Assert.AreSame(plugin1, foundPlugins.First());
        }