Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        public void ShouldLogToDebugOnPluginQuery()
        {
            PluginRepository tested = new PluginRepository();
            MockLog          log    = new MockLog(tested);
            PluginFilter     filter = PluginFilter.Create.IsNamed("plugin name").Implements(typeof(IMockPluginInterface1));

            tested.Plugins(filter);
            Assert.IsTrue(log.Any(x => x.Level == MockLog.Level.Debug && x.Message.Contains("Returning plugins for") && x.Message.Contains(filter.ToString())));
        }
Ejemplo n.º 3
0
        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 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));
        }
Ejemplo n.º 5
0
        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());
        }
 public void ShouldLogToDebugOnPluginQuery()
 {
     PluginRepository tested = new PluginRepository();
       MockLog log = new MockLog(tested);
       PluginFilter filter = PluginFilter.Create.IsNamed("plugin name").Implements(typeof(IMockPluginInterface1));
       tested.Plugins(filter);
       Assert.IsTrue(log.Any(x => x.Level == MockLog.Level.Debug && x.Message.Contains("Returning plugins for") && x.Message.Contains(filter.ToString())));
 }