public void WatchedSectionIsUpdatedIfNotificationIsFired() { SqlConfigurationSourceImplementation implementation = new SqlConfigurationSourceImplementation(this.data, false); object section1 = implementation.GetSection(localSection); Assert.IsNotNull(section1); DummySection dummySection1 = section1 as DummySection; Assert.AreEqual(localSection, dummySection1.Name); Assert.AreEqual(10, dummySection1.Value); System.Configuration.Configuration rwConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); DummySection rwSection = rwConfiguration.GetSection(localSection) as DummySection; rwSection.Value = 15; implementation.SaveSection(localSection, rwSection); implementation.ConfigSourceChanged(externalSectionSource); section1 = implementation.GetSection(localSection); Assert.IsNotNull(section1); dummySection1 = section1 as DummySection; Assert.AreEqual(localSection, dummySection1.Name); Assert.AreEqual(15, dummySection1.Value); }
public void Setup() { string connectString = @"server=(local)\SQLExpress;database=Northwind;Integrated Security=true"; string getStoredProc = @"EntLib_GetConfig"; string setStoredProc = @"EntLib_SetConfig"; string refreshStoredProc = @"UpdateSectionDate"; string removeStoredProc = @"EntLib_RemoveSection"; this.data = new SqlConfigurationData(connectString, getStoredProc, setStoredProc, refreshStoredProc, removeStoredProc); SqlConfigurationSource.ResetImplementation(data, false); System.Configuration.Configuration rwConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); DummySection rwSection; rwConfiguration.Sections.Remove(localSection); rwConfiguration.Sections.Add(localSection, rwSection = new DummySection()); rwSection.Name = localSection; rwSection.Value = 10; SqlConfigurationSourceImplementation configSourceImpl = new SqlConfigurationSourceImplementation(this.data, false); configSourceImpl.SaveSection(rwSection.Name, rwSection); rwConfiguration.Sections.Remove(externalSection); rwConfiguration.Sections.Add(externalSection, rwSection = new DummySection()); rwSection.Name = externalSection; rwSection.Value = 20; configSourceImpl.SaveSection(rwSection.Name, rwSection); rwConfiguration.Sections.Remove(localSection2); rwConfiguration.Sections.Add(localSection2, rwSection = new DummySection()); rwSection.Name = localSection2; rwSection.Value = 30; configSourceImpl.SaveSection(rwSection.Name, rwSection); rwConfiguration.Save(); SqlConfigurationManager.RefreshSection(localSection, this.data); SqlConfigurationManager.RefreshSection(localSection2, this.data); SqlConfigurationManager.RefreshSection(externalSection, this.data); ConfigurationChangeSqlWatcher.ResetDefaultPollDelay(); updatedSectionsTally = new Dictionary <string, int>(0); }
public void RestoredSectionGetsNotificationOnRestoreAndGetsFurtherNotifications() { SqlConfigurationSourceImplementation implementation = new SqlConfigurationSourceImplementation(this.data, false); object section1 = implementation.GetSection(localSection); Assert.IsNotNull(section1); object section2 = implementation.GetSection(localSection2); Assert.IsNotNull(section2); implementation.AddSectionChangeHandler(localSection, new ConfigurationChangedEventHandler(OnConfigurationChanged)); implementation.AddSectionChangeHandler(localSection2, new ConfigurationChangedEventHandler(OnConfigurationChanged)); System.Configuration.Configuration rwConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); implementation.ConfigSourceChanged(externalSectionSource); Assert.AreEqual(1, updatedSectionsTally[localSection]); Assert.AreEqual(1, updatedSectionsTally[localSection2]); // removal of the section notifies both sections rwConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); implementation.RemoveSection(localSection2); Assert.AreEqual(2, updatedSectionsTally[localSection]); Assert.AreEqual(2, updatedSectionsTally[localSection2]); implementation.ConfigSourceChanged(externalSectionSource); Assert.AreEqual(3, updatedSectionsTally[localSection]); Assert.AreEqual(2, updatedSectionsTally[localSection2]); // restore of section gets notified DummySection rwSection = new DummySection(); rwSection.Name = localSection2; rwSection.Value = 30; rwSection.SectionInformation.ConfigSource = externalSectionSource; implementation.SaveSection(rwSection.Name, rwSection); implementation.ConfigSourceChanged(externalSectionSource); Assert.AreEqual(4, updatedSectionsTally[localSection]); Assert.AreEqual(3, updatedSectionsTally[localSection2]); }
public void Setup() { string connectString = @"server=(local)\SQLExpress;database=Northwind;Integrated Security=true"; string getStoredProc = @"EntLib_GetConfig"; string setStoredProc = @"EntLib_SetConfig"; string refreshStoredProc = @"UpdateSectionDate"; string removeStoredProc = @"EntLib_RemoveSection"; this.data = new SqlConfigurationData(connectString, getStoredProc, setStoredProc, refreshStoredProc, removeStoredProc); SqlConfigurationSource.ResetImplementation(data, false); System.Configuration.Configuration rwConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); DummySection rwSection; rwConfiguration.Sections.Remove(localSection); rwConfiguration.Sections.Add(localSection, rwSection = new DummySection()); rwSection.Name = localSection; rwSection.Value = 10; SqlConfigurationSourceImplementation configSourceImpl = new SqlConfigurationSourceImplementation(this.data, false); configSourceImpl.SaveSection(rwSection.Name,rwSection); rwConfiguration.Sections.Remove(externalSection); rwConfiguration.Sections.Add(externalSection, rwSection = new DummySection()); rwSection.Name = externalSection; rwSection.Value = 20; configSourceImpl.SaveSection(rwSection.Name, rwSection); rwConfiguration.Sections.Remove(localSection2); rwConfiguration.Sections.Add(localSection2, rwSection = new DummySection()); rwSection.Name = localSection2; rwSection.Value = 30; configSourceImpl.SaveSection(rwSection.Name, rwSection); rwConfiguration.Save(); SqlConfigurationManager.RefreshSection(localSection, this.data); SqlConfigurationManager.RefreshSection(localSection2, this.data); SqlConfigurationManager.RefreshSection(externalSection, this.data); ConfigurationChangeSqlWatcher.ResetDefaultPollDelay(); updatedSectionsTally = new Dictionary<string, int>(0); }