public void RemoveDirRequiresKnownDirectory()
        {
            AssemblyContainer tested    = new AssemblyContainer();
            IPluginDirectory  pluginDir = new MockPluginDirectory();

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

            tested.AddDir(pluginDir);
            DoAssert.Throws <ArgumentException>(() => tested.AddDir(pluginDir));
        }
        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 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 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 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);
        }