public void SetUp() { _pluginDirectory = @"C:\Temp\Plugins"; _assemblyLocation = Path.Combine(_pluginDirectory, "TestPlugin.dll"); _filesystem = new Mock<IFileSystem>(); _filesystem.Setup(x => x.GetFiles(_pluginDirectory, "*.dll")).Returns(new[] { _assemblyLocation }); _filesystem.Setup(s => s.GetSubDirectories(_pluginDirectory)).Returns(new List<string>()); _pluginMetadata = BuildMetadata("1.0.0.0", "TestPlugin"); _pluginLoader = new Mock<IPluginLoader>(); _mockPlugin = new Mock<IPlugin>(); _pluginLoader.Setup(x => x.CreateInstance(_pluginMetadata)).Returns(_mockPlugin.Object); _pluginLoader.Setup(x => x.InspectAssembly(_assemblyLocation)).Returns(_pluginMetadata); _pluginFactory = new PluginFactory(_filesystem.Object, _pluginDirectory, _pluginLoader.Object); }
private void _buttonLoadPlugins_Click(object sender, EventArgs e) { var textBox = _textBoxPluginPath; if (IsValid(textBox, "Plugin")) { _pluginFactory = new PluginFactory(textBox.Text); if (_pluginFactory.AvailablePlugins != null) { object[] availablePlugins = _pluginFactory.AvailablePlugins.ToArray(); _comboBoxPlugins.Items.Clear(); _comboBoxPlugins.Items.Add("(Select)"); _comboBoxPlugins.SelectedIndex = 0; _comboBoxPlugins.Items.AddRange(availablePlugins); } } }
public void PluginFactoryGivenEmptyDirectoryShouldHaveNoAvailablePlugins() { var pluginLocation = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); var pluginLoader = new PluginFactory(pluginLocation); var result = pluginLoader.AvailablePlugins; Assert.IsEmpty(result); }
public void Initialize(string pluginsPath) { _pluginFactory = new PluginFactory(pluginsPath); }