Exemple #1
0
        public void GetSettingComponentsTest()
        {
            //Arrange
            PluginResolver pluginResolver = new PluginResolver();

            pluginResolver.AddPlugin(typeof(TestPlugin.TestPlugin), "TestKey");
            pluginResolver.LoadPluginSettingsComponent(typeof(TestSettingsComponent), null);

            //Act
            var settingsComponents = pluginResolver.GetSettingComponents().ToList();

            //Assert
            Assert.NotNull(settingsComponents);
            Assert.Single(settingsComponents);
        }
Exemple #2
0
        public void LoadPluginSettingsComponentTest()
        {
            //Arrange
            PluginResolver pluginResolver = new PluginResolver();

            pluginResolver.AddPlugin(typeof(TestPlugin.TestPlugin), "TestKey");

            //Act
            pluginResolver.LoadPluginSettingsComponent(typeof(TestSettingsComponent), null);

            //Assert
            var plugin = pluginResolver.GetPlugin(typeof(TestPlugin.TestPlugin));

            Assert.NotNull(plugin.PluginSettingsComponent);
            Assert.Equal(typeof(TestSettingsComponent), plugin.PluginSettingsComponent.GetType());
        }
Exemple #3
0
        public IEnumerable <PluginSettingsComponent> LoadSettings(Assembly assembly)
        {
            var settingsTypes = assembly.GetTypes().Where(type => type.BaseType == typeof(PluginSettingsComponent)).ToList();

            foreach (Type settingsType in settingsTypes)
            {
                Console.WriteLine("LoadSettings " + settingsType);

                var settings = _pluginResolver.LoadPluginSettingsComponent(settingsType, _httpClient);

                if (settings != null)
                {
                    yield return(settings);
                }
            }
        }
Exemple #4
0
        public void SetPluginSettingsComponentTest()
        {
            //Arrange
            PluginResolver pluginResolver = new PluginResolver();

            pluginResolver.AddPlugin(typeof(TestPlugin.TestPlugin), "TestKey");
            pluginResolver.LoadPluginSettingsComponent(typeof(TestSettingsComponent), null);

            var oldComponent = pluginResolver.GetSettingComponent("TestKey");

            var newComponent = new TestSettingsComponent();

            //Act
            pluginResolver.SetPluginSettingsComponent(newComponent);

            //Assert
            Assert.NotEqual(oldComponent, pluginResolver.GetSettingComponent("TestKey"));
            Assert.Equal("TestKey", newComponent.PluginKey);
        }