public void TestConfigurationManagerSaveConfigurationNodeRemoval() { String newFilePath = "MockConfigurationTestConfigurationManagerSaveConfigurationNodeRemoval.xml"; File.Copy("MockConfiguration.xml", newFilePath); ConfigurationManager manager = new ConfigurationManager(newFilePath); MockApp app = manager.FindAllComponentsOfType <MockApp>().Single(a => a.TestProp.Equals("Test2")); app.RemoveChild("Test4"); manager.SaveConfiguration(); String inputFile = File.ReadAllText("MockConfigurationSavedNodeRemoval.xml").Replace(" ", "").Replace("\t", ""); String outputFile = File.ReadAllText(newFilePath).Replace(" ", "").Replace("\t", ""); Assert.AreEqual(inputFile, outputFile); manager.Dispose(); }
public void TestConfigurationManagerConstructorAppNestedComponentsTag() { ConfigurationManager manager = new ConfigurationManager(@"MockConfigurationNestedComponentsTag.xml"); IEnumerable <IParseable> foundComponents = manager.Components; Assert.AreEqual(5, foundComponents.Count()); Assert.AreEqual(3, foundComponents.OfType <MockApp>().Count()); Assert.AreEqual(1, foundComponents.OfType <MockApp>().Count(c => c.Children.Any())); MockApp app = foundComponents.OfType <MockApp>().Single(c => c.Children.Any()); Assert.AreEqual(2, app.Children.Count()); Assert.AreEqual(1, app.Children.Count(c => c.Children.Any())); MockSupport support = app.Children.First(c => c.Children.Any()) as MockSupport; Assert.IsNotNull(support); Assert.AreEqual(1, support.Children.Count()); Assert.AreEqual(1, support.Children.OfType <MockSupport>().Count()); manager.Dispose(); }