public void AddDirOnlyAcceptDirectoryOnce() { AssemblyContainer tested = new AssemblyContainer(); IPluginDirectory pluginDir = new MockPluginDirectory(); tested.AddDir(pluginDir); DoAssert.Throws<ArgumentException>(() => tested.AddDir(pluginDir)); }
public void AddDirOnlyAcceptDirectoryOnce() { AssemblyContainer tested = new AssemblyContainer(); IPluginDirectory pluginDir = new MockPluginDirectory(); tested.AddDir(pluginDir); DoAssert.Throws <ArgumentException>(() => tested.AddDir(pluginDir)); }
public void AddDirAcceptsValidArgument() { AssemblyContainer tested = new AssemblyContainer(); IPluginDirectory pluginDir = new MockPluginDirectory(); tested.AddDir(pluginDir); }
public void RemoveDirShouldHandleRemovalOfKnownDirectory() { AssemblyContainer tested = new AssemblyContainer(); IPluginDirectory pluginDir = new MockPluginDirectory(); tested.AddDir(pluginDir); tested.RemoveDir(pluginDir); }
public void ShouldLogToInfoWhenAddingDirectory() { var path = "mockDir"; var mockPluginDir = new Mock <IPluginDirectory>(); mockPluginDir.Setup(x => x.Path).Returns(path); AssemblyContainer tested = new AssemblyContainer(); MockLog log = new MockLog(tested); tested.AddDir(mockPluginDir.Object); Assert.IsTrue(log.Any(x => x.Level == MockLog.Level.Info && x.Message.Contains("Added plugin directory ") && x.Message.Contains(path))); }
public void ShouldRaiseAssemblyAddedOnFileFound() { AssemblyContainer tested = new AssemblyContainer(); MockPluginDirectory pluginDir = new MockPluginDirectory(); tested.AddDir(pluginDir); bool assemblyAddedRaised = false; tested.AssemblyAdded += (s, e) => assemblyAddedRaised = true; pluginDir.RaiseFileFound(GetType().Assembly.Location); Assert.IsTrue(assemblyAddedRaised); }
public void ShouldNotRaiseAssemblyRemovedOnUnknownFileLost() { AssemblyContainer tested = new AssemblyContainer(); MockPluginDirectory pluginDir = new MockPluginDirectory(); tested.AddDir(pluginDir); bool assemblyRemovedRaised = false; tested.AssemblyRemoved += (s, e) => assemblyRemovedRaised = true; pluginDir.RaiseFileLost(GetType().Assembly.Location); Assert.IsFalse(assemblyRemovedRaised); }
public void ShouldForgetLostFile() { AssemblyContainer tested = new AssemblyContainer(); MockPluginDirectory pluginDir = new MockPluginDirectory(); tested.AddDir(pluginDir); int assemblyRemovedRaised = 0; tested.AssemblyRemoved += (s, e) => assemblyRemovedRaised++; pluginDir.RaiseFileFound(GetType().Assembly.Location); pluginDir.RaiseFileLost(GetType().Assembly.Location); pluginDir.RaiseFileLost(GetType().Assembly.Location); Assert.AreEqual(1, assemblyRemovedRaised); }
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store) { AssemblyContainer assemblyContainer = new AssemblyContainer(); PluginRepository pluginRepository = new PluginRepository(); pluginRepository.AddPluginSource(new PluginExtractor(assemblyContainer)); System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader(); string pluginDir = settingsReader.GetValue("PluginPath", typeof(string)) as string; PluginDirectory pluginDirectory = new PluginDirectory(pluginDir, true); assemblyContainer.AddDir(pluginDirectory); container.Register( Component.For<IPluginRepository>().LifestyleSingleton().Instance(pluginRepository), Component.For<IAssemblyRepository>().LifestyleSingleton().Instance(assemblyContainer) .OnDestroy(kernel => { assemblyContainer.RemoveDir(pluginDirectory); pluginDirectory.Dispose(); }) ); }
public void RemovedDirDoesNotRaiseEvents() { AssemblyContainer tested = new AssemblyContainer(); MockPluginDirectory pluginDir = new MockPluginDirectory(); tested.AddDir(pluginDir); int assemblyAddedRaised = 0; int assemblyRemovedRaised = 0; tested.AssemblyAdded += (s, e) => assemblyAddedRaised++; tested.AssemblyRemoved += (s, e) => assemblyRemovedRaised++; tested.RemoveDir(pluginDir); pluginDir.RaiseFileFound(GetType().Assembly.Location); pluginDir.RaiseFileLost(GetType().Assembly.Location); Assert.AreEqual(0, assemblyAddedRaised); Assert.AreEqual(0, assemblyRemovedRaised); }
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store) { AssemblyContainer assemblyContainer = new AssemblyContainer(); PluginRepository pluginRepository = new PluginRepository(); pluginRepository.AddPluginSource(new PluginExtractor(assemblyContainer)); System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader(); string pluginDir = settingsReader.GetValue("PluginPath", typeof(string)) as string; PluginDirectory pluginDirectory = new PluginDirectory(pluginDir, true); assemblyContainer.AddDir(pluginDirectory); container.Register( Component.For <IPluginRepository>().LifestyleSingleton().Instance(pluginRepository), Component.For <IAssemblyRepository>().LifestyleSingleton().Instance(assemblyContainer) .OnDestroy(kernel => { assemblyContainer.RemoveDir(pluginDirectory); pluginDirectory.Dispose(); }) ); }
public void ShouldRaiseAssemblyRemovedOnKnownFileLost() { AssemblyContainer tested = new AssemblyContainer(); MockPluginDirectory pluginDir = new MockPluginDirectory(); tested.AddDir(pluginDir); bool assemblyRemovedRaised = false; tested.AssemblyRemoved += (s, e) => assemblyRemovedRaised = true; pluginDir.RaiseFileFound(GetType().Assembly.Location); pluginDir.RaiseFileLost(GetType().Assembly.Location); Assert.IsTrue(assemblyRemovedRaised); }
public void ShouldLogToInfoWhenRemovingDirectory() { var path = "mockDir"; var mockPluginDir = new Mock<IPluginDirectory>(); mockPluginDir.Setup(x => x.Path).Returns(path); AssemblyContainer tested = new AssemblyContainer(); MockLog log = new MockLog(tested); tested.AddDir(mockPluginDir.Object); tested.RemoveDir(mockPluginDir.Object); Assert.IsTrue(log.Any(x => x.Level == MockLog.Level.Info && x.Message.Contains("Removed plugin directory ") && x.Message.Contains(path))); }
public void AddDirRequiresArgument() { AssemblyContainer tested = new AssemblyContainer(); DoAssert.Throws<ArgumentNullException>(() => tested.AddDir(null)); }
public void AddDirRequiresArgument() { AssemblyContainer tested = new AssemblyContainer(); DoAssert.Throws <ArgumentNullException>(() => tested.AddDir(null)); }