public void SingletonPluginTest() { var host = new PluginHostBuilder() .UsePluginTypes(typeof(ITestPlugin)) .Build(); host.GetPlugins <ITestPlugin>().Count().Should().Be(2); host.GetPlugins <ITestSingletonPlugin>().Count().Should().Be(1); }
public void PluginFilterTest() { var host = new PluginHostBuilder() .UsePluginFilter(typeof(ITestPlugin)) .Build(); host.GetPlugins <ITestPlugin>().Count().Should().Be(2); host = new PluginHostBuilder() .UsePluginFilter(typeof(ITestPlugin)) .UsePluginFilter(p => p.Type != typeof(TestPlugin2)) .Build(); host.GetPlugins <ITestPlugin>().Count().Should().Be(1); }
private void RunCombinedTest(ILoggerFactory loggerFactory, bool mustClearCache = false) { var logger = loggerFactory.CreateLogger <PluginFinder>(); var pluginFinder = new PluginFinder(logger); if (mustClearCache) { var fsc = (FileSystemCache <string, string>)pluginFinder.Cache; fsc.Clear(); } var plugins = pluginFinder.FindPlugins(); plugins.InfoByType.Count.Should().BeGreaterOrEqualTo(2); // Capabilities extraction var testPlugin1Caps = plugins.InfoByType[typeof(TestPlugin1)].Capabilities; testPlugin1Caps.Count.Should().Be(0); var testPlugin2Caps = plugins.InfoByType[typeof(TestPlugin2)].Capabilities; testPlugin2Caps.Count.Should().Be(2); testPlugin2Caps.GetValueOrDefault("Client").Should().Be(true); testPlugin2Caps.GetValueOrDefault("Server").Should().Be(false); // Dependencies extraction var testPlugin1Deps = plugins.InfoByType[typeof(TestPlugin1)].Dependencies; testPlugin1Deps.Should().BeEquivalentTo((TypeRef)typeof(TestPlugin2)); var testPlugin1AllDeps = plugins.InfoByType[typeof(TestPlugin1)].AllDependencies; testPlugin1AllDeps.Should().Contain((TypeRef)typeof(TestPlugin2)); var testPlugin2Deps = plugins.InfoByType[typeof(TestPlugin2)].Dependencies; testPlugin2Deps.Count.Should().Be(0); var host = new PluginHostBuilder() .UsePlugins(plugins) .UsePluginTypes(typeof(ITestPlugin)) .Build(); RunPluginHostTests(host); }