public void RemoveWatcherForConfigSource(String configSource)
        {
            ConfigurationChangeFileWatcher watcher = null;

            configSourceWatcherMapping.TryGetValue(configSource, out watcher);

            if (watcher != null)
            {
                configSourceWatcherMapping.Remove(configSource);
                watcher.Dispose();
            }
        }
        public void WillStopNotifyingAfterObjectIsDisposed()
        {
            ConfigurationChangeFileWatcher watcher = new ConfigurationChangeFileWatcher("MyFile.Test", "MySection");

            watcher.SetPollDelayInMilliseconds(100);
            watcher.ConfigurationChanged += new ConfigurationChangedEventHandler(FileChanged);
            watcher.StartWatching();
            Thread.Sleep(100);
            watcher.Dispose();

            File.SetLastWriteTime("MyFile.Test", DateTime.Now + TimeSpan.FromHours(1.0));
            Thread.Sleep(250);

            Assert.AreEqual(0, configurationChangeCounter);
        }
        public void WillStopNotifyingAfterObjectIsDisposed()
        {
            ConfigurationChangeFileWatcher watcher = new ConfigurationChangeFileWatcher("MyFile.Test", "MySection");
            watcher.SetPollDelayInMilliseconds(100);
            watcher.ConfigurationChanged += new ConfigurationChangedEventHandler(FileChanged);
            watcher.StartWatching();
            Thread.Sleep(100);
            watcher.Dispose();

            File.SetLastWriteTime("MyFile.Test", DateTime.Now + TimeSpan.FromHours(1.0));
            Thread.Sleep(250);

            Assert.AreEqual(0, configurationChangeCounter);
        }