public void XmlDBManager() { sm = new SettingsManager(configXml, "xmldbmanager"); Assert.IsNotEmpty(sm.SelectElementValue("baseFolderPath")); Assert.IsNotEmpty(sm.SelectElementValue("dBFileName")); string DBPath = Path.Combine(sm.SelectElementValue("baseFolderPath"), sm.SelectElementValue("dBFileName")); string DBPath_Test = Path.Combine(sm.SelectElementValue("baseFolderPath"), "DB_Test.xml"); var dm = new XmlDBManager(configXml); // Load DFD dm.DFDPath = DBPath; dm.LoadDFD(); // Delete Test DFD dm.DFDPath = DBPath_Test; dm.DeleteDFD(); Assert.IsFalse(File.Exists(DBPath_Test)); // Create Test DFD dm.DFDPath = DBPath_Test; dm.SaveDFD(); Assert.IsTrue(File.Exists(DBPath_Test)); // Create a table in Test DFD dm.DFDPath = DBPath_Test; XElement newTable1 = new XElement("table", new XAttribute("name", "coordinates"), new XElement("Name", new XAttribute("type", "string")), new XElement("Latitude", new XAttribute("type", "int")), new XElement("Longitude", new XAttribute("type", "int"))); dm.CreateDFDTable(newTable1); Assert.IsNotNull(dm.GetTableRef("coordinates")); // Delete the table in Test DFD dm.DeleteDFDTable("coordinates"); Assert.IsNull(dm.GetTableRef("coordinates")); // Create table "coordinates" again (now from existing DFD) newTable1 = new XElement("table", new XAttribute("name", "coordinates"), new XElement("Name", new XAttribute("type", "string")), new XElement("Latitude", new XAttribute("type", "int")), new XElement("Longitude", new XAttribute("type", "int"))); dm.CreateDFDTable(newTable1); // Create a second table "people" XElement newTable2 = new XElement("table", new XAttribute("name", "people"), new XElement("Firstname", new XAttribute("type", "string")), new XElement("Lastname", new XAttribute("type", "string")), new XElement("Initials", new XAttribute("type", "string"))); dm.CreateDFDTable(newTable2); // Delete 2nd table dm.DeleteDFDTable("people"); Assert.IsNull(dm.GetTableRef("people")); Assert.IsNotNull(dm.GetTableRef("coordinates")); // Add 2nd table again newTable2 = new XElement("table", new XAttribute("name", "people"), new XElement("Firstname", new XAttribute("type", "string")), new XElement("Lastname", new XAttribute("type", "string")), new XElement("Initials", new XAttribute("type", "string"))); dm.CreateDFDTable(newTable2); // Save to disk, load and verify that the 2 tables must exist. dm.SaveDFD(); dm.LoadDFD(); Assert.IsNotNull(dm.GetTableRef("coordinates")); Assert.IsNotNull(dm.GetTableRef("people")); // Delete 1st table dm.DeleteDFDTable("coordinates"); Assert.IsNull(dm.GetTableRef("coordinates")); Assert.IsNotNull(dm.GetTableRef("people")); // Delete 2nd table dm.DeleteDFDTable("people"); Assert.IsNull(dm.GetTableRef("people")); // Save to disk, load and verify that the 2 tables do not exist. dm.SaveDFD(); dm.LoadDFD(); Assert.IsNull(dm.GetTableRef("coordinates")); Assert.IsNull(dm.GetTableRef("people")); }