public void RemovingAndAddingSection() { SystemConfigurationSource.ResetImplementation(true); SystemConfigurationSource sysSource = new SystemConfigurationSource(); DummySection dummySection = sysSource.GetSection(localSection) as DummySection; Assert.IsTrue(dummySection != null); Thread.Sleep(300); System.Configuration.Configuration rwConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); string fileName = rwConfiguration.FilePath; int numSections = rwConfiguration.Sections.Count; FileConfigurationParameter parameter = new FileConfigurationParameter(fileName); sysSource.Remove(parameter, localSection); Thread.Sleep(300); rwConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); Assert.AreEqual(rwConfiguration.Sections.Count, numSections - 1); sysSource.Add(parameter, localSection, new DummySection()); Thread.Sleep(300); rwConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); Assert.AreEqual(rwConfiguration.Sections.Count, numSections); }
public void TryToSaveWithAFileConfigurationSaveParameter() { SystemConfigurationSource source = new SystemConfigurationSource(); source.Add(new FileConfigurationParameter(file), InstrumentationConfigurationSection.SectionName, CreateInstrumentationSection()); ValidateConfiguration(file); }
public void AddingASectionIsReflectedInMemoryAndOnDisk_Bug2931() { SystemConfigurationSource sysSource = new SystemConfigurationSource(false); var originalSection = (DummySection)(sysSource.GetSection(addedSectionName)); Assert.IsNull(originalSection); var newSection = new DummySection(); sysSource.Add(addedSectionName, newSection); var returnedSection = (DummySection)(sysSource.GetSection(addedSectionName)); Assert.IsNotNull(returnedSection); sysSource.Remove(addedSectionName); }
public void RemovingAndAddingSection() { SystemConfigurationSource sysSource = new SystemConfigurationSource(false); DummySection dummySection = sysSource.GetSection(localSection) as DummySection; Assert.IsTrue(dummySection != null); System.Configuration.Configuration rwConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); string fileName = rwConfiguration.FilePath; int numSections = rwConfiguration.Sections.Count; sysSource.Remove(localSection); rwConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); Assert.AreEqual(rwConfiguration.Sections.Count, numSections - 1); sysSource.Add(localSection, new DummySection()); // can't be the same instance rwConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); Assert.AreEqual(rwConfiguration.Sections.Count, numSections); }
public void TryToSaveWithTheWrongConfigurationSaveParameterTypeThrows() { SystemConfigurationSource source = new SystemConfigurationSource(); source.Add(new WrongConfigurationSaveParameter(), InstrumentationConfigurationSection.SectionName, CreateInstrumentationSection()); }