public void InitialiseOrdersPluginNamesAndSucceeds() { // Arrange var configuration = new PluginLoaderConfiguration(); var extensionsFolder = "C:\\arbitrary-folder\\"; var pluginNames = "BBB-FirstListedPlugin,AAA-SecondListedPlugin,CCC-ThirdListedPlugin"; Mock.SetupStatic(typeof(ConfigurationManager)); Mock.Arrange(() => ConfigurationManager.AppSettings[SchedulerAppSettings.Keys.EXTENSIONS_FOLDER]) .Returns(extensionsFolder) .MustBeCalled(); Mock.Arrange(() => ConfigurationManager.AppSettings[SchedulerAppSettings.Keys.PLUGIN_TYPES]) .Returns(pluginNames) .MustBeCalled(); Mock.SetupStatic(typeof(Directory)); Mock.Arrange(() => Directory.Exists(Arg.Is<string>(extensionsFolder))) .Returns(true) .MustBeCalled(); // Act var sut = new PluginLoaderConfigurationFromAppSettingsLoader(); sut.Initialise(configuration, null); // Assert Mock.Assert(() => ConfigurationManager.AppSettings[SchedulerAppSettings.Keys.EXTENSIONS_FOLDER]); Mock.Assert(() => ConfigurationManager.AppSettings[SchedulerAppSettings.Keys.PLUGIN_TYPES]); Mock.Assert(() => Directory.Exists(Arg.Is<string>(extensionsFolder))); Assert.AreEqual(extensionsFolder, configuration.ExtensionsFolder); Assert.AreEqual(3, configuration.PluginTypes.Count); Assert.AreEqual("AAA-SecondListedPlugin".ToLower(), configuration.PluginTypes[0]); Assert.AreEqual("BBB-FirstListedPlugin".ToLower(), configuration.PluginTypes[1]); Assert.AreEqual("CCC-ThirdListedPlugin".ToLower(), configuration.PluginTypes[2]); }
public void InitialiseWithPluginNamesAndStarReturnsStarPlugin() { // Arrange var configuration = new PluginLoaderConfiguration(); var extensionsFolder = "C:\\arbitrary-folder\\"; var pluginNames = "*,Plugin1,Plugin2,Plugin3,*"; Mock.SetupStatic(typeof(ConfigurationManager)); Mock.Arrange(() => ConfigurationManager.AppSettings[SchedulerAppSettings.Keys.EXTENSIONS_FOLDER]) .Returns(extensionsFolder) .MustBeCalled(); Mock.Arrange(() => ConfigurationManager.AppSettings[SchedulerAppSettings.Keys.PLUGIN_TYPES]) .Returns(pluginNames) .MustBeCalled(); Mock.SetupStatic(typeof(Directory)); Mock.Arrange(() => Directory.Exists(Arg.Is<string>(extensionsFolder))) .Returns(true) .MustBeCalled(); // Act var sut = new PluginLoaderConfigurationFromAppSettingsLoader(); sut.Initialise(configuration, null); // Assert Mock.Assert(() => ConfigurationManager.AppSettings[SchedulerAppSettings.Keys.EXTENSIONS_FOLDER]); Mock.Assert(() => ConfigurationManager.AppSettings[SchedulerAppSettings.Keys.PLUGIN_TYPES]); Mock.Assert(() => Directory.Exists(Arg.Is<string>(extensionsFolder))); Assert.AreEqual(extensionsFolder, configuration.ExtensionsFolder); Assert.AreEqual(1, configuration.PluginTypes.Count); Assert.AreEqual("*".ToLower(), configuration.PluginTypes[0]); }
public void InitialiseWithEmptyPluginNamesLoadsDefaultPlugin() { // Arrange var configuration = new PluginLoaderConfiguration(); var extensionsFolder = "C:\\arbitrary-folder\\"; var pluginNames = ""; Mock.SetupStatic(typeof(ConfigurationManager)); Mock.Arrange(() => ConfigurationManager.AppSettings[SchedulerAppSettings.Keys.EXTENSIONS_FOLDER]) .Returns(extensionsFolder) .MustBeCalled(); Mock.Arrange(() => ConfigurationManager.AppSettings[SchedulerAppSettings.Keys.PLUGIN_TYPES]) .Returns(pluginNames) .MustBeCalled(); Mock.SetupStatic(typeof(Directory)); Mock.Arrange(() => Directory.Exists(Arg.Is<string>(extensionsFolder))) .Returns(true) .MustBeCalled(); // Act var sut = new PluginLoaderConfigurationFromAppSettingsLoader(); sut.Initialise(configuration, null); // Assert Mock.Assert(() => ConfigurationManager.AppSettings[SchedulerAppSettings.Keys.EXTENSIONS_FOLDER]); Mock.Assert(() => ConfigurationManager.AppSettings[SchedulerAppSettings.Keys.PLUGIN_TYPES]); Mock.Assert(() => Directory.Exists(Arg.Is<string>(extensionsFolder))); Assert.AreEqual(extensionsFolder, configuration.ExtensionsFolder); Assert.AreEqual(1, configuration.PluginTypes.Count); Assert.IsTrue(configuration.PluginTypes .Contains(biz.dfch.CS.Appclusive.Scheduler.Public.Constants.PLUGIN_TYPE_DEFAULT.ToLower())); }