コード例 #1
0
        public void Should_register_plugins_with_registry()
        {
            var instance = new Plugin1();
            var registry = new Registry(new TypeCache());
            var plugin1  = Plugin <IPluginType> .Create(instance, true);

            var plugin2 = Plugin <IPluginType> .Create <Plugin2>(true);

            var plugins = new Plugins <IPluginType>(true);

            plugins.Append(plugin1).Append(plugin2);

            registry.RegisterPlugins(plugins);

            registry.Count().ShouldEqual(2);

            Should_be_plugin_instance(registry.First(), instance);
            Should_be_plugin_type <Plugin2>(registry.Second());
        }
コード例 #2
0
        public void Should_register_plugins_in_container()
        {
            var instance  = new Plugin1();
            var container = new Container();
            var plugin1   = Plugin <IPluginType> .Create(instance, true);

            var plugin2 = Plugin <IPluginType> .Create <Plugin2>(true);

            var plugins = new Plugins <IPluginType>(true);

            plugins.Append(plugin1).Append(plugin2);

            container.RegisterPlugins(plugins);

            var instances = container.GetInstances <IPluginType>();

            instances.Count().ShouldEqual(2);
            instances.ShouldContain(instance);
        }
コード例 #3
0
        public void Should_return_index_of_first_plugin_instance_if_instance_exists()
        {
            var instance = new Plugin1();

            _plugins.Append(Plugin <IPluginType> .Create <Plugin1>());
            _plugins.Append(Plugin <IPluginType> .Create(new Plugin1()));
            _plugins.Append(Plugin <IPluginType> .Create(instance));
            _plugins.Append(Plugin <IPluginType> .Create(instance));

            _plugins.IndexOf(instance).ShouldEqual(2);
        }
コード例 #4
0
        public void Should_clear_plugins()
        {
            _plugins.Append(Plugin <IPluginType> .Create());

            _plugins.Count().ShouldEqual(1);

            _pluginsDsl.Clear();

            _plugins.ShouldBeEmpty();
        }