Example #1
0
        public void RunningWatcherKeepsOnlyOnePollingThread()
        {
            ConfigurationChangeWatcher.SetDefaultPollDelayInMilliseconds(50);
            TestConfigurationChangeWatcher watcher = new TestConfigurationChangeWatcher();

            try
            {
                watcher.ConfigurationChanged += new ConfigurationChangedEventHandler(OnConfigurationChanged);

                for (int i = 0; i < 20; i++)
                {
                    watcher.StopWatching();
                    watcher.StartWatching();
                }

                // ramp up
                Thread.Sleep(50);

                watcher.DoNotification();

                // wait for notification
                Thread.Sleep(150);

                Assert.AreEqual(1, notifications);
            }
            finally
            {
                watcher.StopWatching();
                ConfigurationChangeWatcher.ResetDefaultPollDelay();
            }
        }
Example #2
0
        protected override void Teardown()
        {
            ConfigurationChangeWatcher.ResetDefaultPollDelay();

            File.WriteAllText(@"ExternalFileSource.config", originalConfigurationFileContents);
            waitForChangedEvents.Dispose();
        }
Example #3
0
        public void TearDown()
        {
            System.Configuration.Configuration rwConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            LoggingSettings rwSettings = rwConfiguration.GetSection(LoggingSettings.SectionName) as LoggingSettings;

            ((CategoryFilterData)rwSettings.LogFilters.Get("Category")).CategoryFilters.Remove("MockCategoryOne");
            rwConfiguration.Save();
            ConfigurationManager.RefreshSection(LoggingSettings.SectionName);
            ConfigurationChangeWatcher.ResetDefaultPollDelay();
        }
Example #4
0
        public void ChangeInExternalConfigSourceIsDetected()
        {
            ConfigurationChangeWatcher.SetDefaultPollDelayInMilliseconds(50);
            string otherConfigurationFile        = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Other.config");
            FileConfigurationParameter parameter = new FileConfigurationParameter(otherConfigurationFile);

            FileConfigurationSource.ResetImplementation(otherConfigurationFile, true);
            try
            {
                File.Copy(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, otherConfigurationFile);
                FileConfigurationSource otherSource = new FileConfigurationSource(otherConfigurationFile);

                DummySection rwSection;
                System.Configuration.Configuration rwConfiguration = ConfigurationManager.OpenExeConfiguration(otherConfigurationFile);
                rwConfiguration.Sections.Remove(externalSection);
                rwConfiguration.Sections.Add(externalSection, rwSection = new DummySection());
                rwSection.Name  = externalSection;
                rwSection.Value = 12;
                rwSection.SectionInformation.ConfigSource = externalSectionSource;
                rwConfiguration.Save(ConfigurationSaveMode.Full);

                DummySection otherSection = otherSource.GetSection(externalSection) as DummySection;
                Assert.AreEqual(12, otherSection.Value);

                rwSection.Value = 13;
                rwConfiguration.Save(ConfigurationSaveMode.Modified);

                Thread.Sleep(150);

                otherSection = otherSource.GetSection(externalSection) as DummySection;
                Assert.AreEqual(13, otherSection.Value);
            }
            finally
            {
                ConfigurationChangeWatcher.ResetDefaultPollDelay();
                FileConfigurationSource.ResetImplementation(otherConfigurationFile, true);
                if (File.Exists(otherConfigurationFile))
                {
                    File.Delete(otherConfigurationFile);
                }
            }
        }
 public void TearDown()
 {
     ConfigurationChangeWatcher.ResetDefaultPollDelay();
 }
Example #6
0
 public void TestInitialize()
 {
     ClearConfig();
     ConfigurationChangeWatcher.ResetDefaultPollDelay();
 }