public void WatchedSectionInExternalFileValuesAreUpdatedIfExternalFileChangesAndNotificationIsFired() { SystemConfigurationSourceImplementation implementation = new SystemConfigurationSourceImplementation(false); object section1 = implementation.GetSection(externalSection); Assert.IsNotNull(section1); DummySection dummySection1 = section1 as DummySection; Assert.AreEqual(externalSection, dummySection1.Name); Assert.AreEqual(20, dummySection1.Value); System.Configuration.Configuration rwConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); DummySection rwSection = rwConfiguration.GetSection(externalSection) as DummySection; rwSection.Value = 25; rwConfiguration.Save(); implementation.ExternalConfigSourceChanged(externalSectionSource); section1 = implementation.GetSection(externalSection); Assert.IsNotNull(section1); dummySection1 = section1 as DummySection; Assert.AreEqual(externalSection, dummySection1.Name); Assert.AreEqual(25, dummySection1.Value); }
public void CanAddAndRemoveHandlers() { SystemConfigurationSourceImplementation implementation = new SystemConfigurationSourceImplementation(false); object section = implementation.GetSection(externalSection); Assert.IsNotNull(section); implementation.AddSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged)); implementation.AddSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged)); implementation.ExternalConfigSourceChanged(externalSectionSource); Assert.AreEqual(2, updatedSectionsTally[externalSection]); implementation.RemoveSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged)); implementation.ExternalConfigSourceChanged(externalSectionSource); Assert.AreEqual(3, updatedSectionsTally[externalSection]); implementation.RemoveSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged)); implementation.ExternalConfigSourceChanged(externalSectionSource); Assert.AreEqual(3, updatedSectionsTally[externalSection]); }
public void RegisteredObjectIsNotifiedOfSectionChangesForExternalFile() { SystemConfigurationSourceImplementation implementation = new SystemConfigurationSourceImplementation(false); implementation.GetSection(externalSection); implementation.AddSectionChangeHandler(externalSection, new ConfigurationChangedEventHandler(OnConfigurationChanged)); implementation.ExternalConfigSourceChanged(externalSectionSource); Assert.AreEqual(1, updatedSectionsTally[externalSection]); }