Ejemplo n.º 1
0
        public void RemoveSectionFromConfigurationFile()
        {
            ConfigurationFile file = new ConfigurationFile();
            file.Load(Path.GetFullPath(removeConfigTestFile));
            file.RemoveSection(ConfigurationSettings.SectionName);

            XmlDocument doc = new XmlDocument();
            doc.Load(file.FileName);

            XmlNode configSections = doc.DocumentElement.SelectSingleNode("//configuration/configSections");
            Assert.IsNotNull(configSections);
            XmlNode section = configSections.SelectSingleNode(string.Concat("//section[@name='", ConfigurationSettings.SectionName, "']"));
            Assert.IsNull(section);
            XmlNode sectionInformationNode = doc.DocumentElement.SelectSingleNode(string.Concat("//entlib:", ConfigurationSettings.SectionName), ConfigurationFile.GetNamespaceManager(doc));
            Assert.IsNull(sectionInformationNode);
        }