public void TestConfigurationManagerSaveConfigurationNodeAddition() { String newFilePath = "MockConfigurationTestConfigurationManagerSaveConfigurationNodeAddition.xml"; File.Copy("MockConfiguration.xml", newFilePath); ConfigurationManager manager = new ConfigurationManager(newFilePath); MockApp app = manager.FindAllComponentsOfType <MockApp>().Single(a => a.TestProp.Equals("Test2")); MockSupport support = new MockSupport(); support.TestProp = "AddedNode"; app.AddChild(support); manager.SaveConfiguration(); String inputFile = File.ReadAllText("MockConfigurationSavedNodeAddition.xml").Replace(" ", "").Replace("\t", ""); String outputFile = File.ReadAllText(newFilePath).Replace(" ", "").Replace("\t", ""); Assert.AreEqual(inputFile, outputFile); manager.Dispose(); }
public void TestConfigurationManagerConstructorIOInterfaceNestedComponentsTag() { ConfigurationManager manager = new ConfigurationManager(@"MockConfigurationNestedComponentsTag.xml"); IEnumerable <IParseable> foundComponents = manager.Components; Assert.AreEqual(5, foundComponents.Count()); Assert.AreEqual(2, foundComponents.OfType <IIOInterface>().Count()); Assert.AreEqual(1, foundComponents.OfType <IIOInterface>().Count(c => c.Children.Any())); IIOInterface ioInterface = foundComponents.OfType <IIOInterface>().Single(c => c.Children.Any()); Assert.AreEqual(1, ioInterface.Children.Count()); MockSupport support = ioInterface.Children.First() as MockSupport; Assert.IsNotNull(support); Assert.AreEqual(1, support.Children.Count()); Assert.AreEqual(1, support.Children.OfType <MockSupport>().Count()); manager.Dispose(); }