public void AddDirOnlyAcceptDirectoryOnce() { AssemblyContainer tested = new AssemblyContainer(); IPluginDirectory pluginDir = new MockPluginDirectory(); tested.AddDir(pluginDir); DoAssert.Throws<ArgumentException>(() => tested.AddDir(pluginDir)); }
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 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 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 RemoveDirRequiresKnownDirectory() { AssemblyContainer tested = new AssemblyContainer(); IPluginDirectory pluginDir = new MockPluginDirectory(); DoAssert.Throws<ArgumentException>(() => tested.RemoveDir(pluginDir)); }
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); }