コード例 #1
0
        public void ShouldActivatePlugin()
        {
            const long   pluginId           = 234;
            const string pluginAssemblyName = "plugin_accembly_name";
            const string pluginTypeFullName = "plugin_type_full_name";

            _pluginRepository
            .Setup(_ => _.GetById(pluginId))
            .Returns(new Plugins
            {
                AssemblyName = pluginAssemblyName,
                Id           = pluginId,
                TypeFullName = pluginTypeFullName
            });

            var plugin = new Mock <ICorePlugin>();

            _pluginContainerProvider
            .Setup(_ => _.Resolve(pluginTypeFullName))
            .Returns(plugin.Object);

            var result = _target.Activate(pluginId);

            result.Should().NotBeNull();
            result.ShouldBeEquivalentTo(plugin.Object);
        }
コード例 #2
0
        public ICorePlugin Prepare(long pluginId, long projectId, long?userId = null)
        {
            var plugin = _pluginActivator.Activate(pluginId);

            var settings = _pluginSettingProvider.GetSettingsForPlugin(pluginId, projectId, userId);

            if ((settings == null) ||
                (settings.Count == 0))
            {
                return(plugin);
            }

            plugin.LoadSettingValues(settings);

            _log.Trace(
                Resources.Resources.PluginFactory_Prepare_PluginPrepared.FormatWith(
                    pluginId,
                    projectId,
                    userId));

            return(plugin);
        }