// 1. Get list of testbed titles // 2. Get list of computers for each testbed // 3. Add each list and its contents to the tree // 4. Add all of the computers in the DB to the master tree private void WindowListBrowserWindow_Loaded(object sender, RoutedEventArgs e) { DataTable allTestbeds = new Testbeds().SelectAll(); foreach (DataRow row_testbed in allTestbeds.Rows) { // Loop through each testbed Testbed testbed = new Testbed((int)row_testbed["ID"], (string)row_testbed["Title"]); // Find all of the relations for this testbed ID DataTable testbedRelations = new TestbedRelations().FindByTestbedID((int)row_testbed["ID"]); foreach (DataRow row_relation in testbedRelations.Rows) { // Get the computer information for this ID DataTable table_computer = new Computers().Find((int)row_relation["ComputerID"]); foreach (DataRow row_computer in table_computer.Rows) { testbed.Add(new RemoteComputer(row_computer)); } } listTree.AddList((string)row_testbed["Title"], testbed); } DisplayAllInMasterList(); }
public void SaveLoadTest() { // init database connection ConnectionManager.Connect(); Computers computersInterface = new Computers(); // add localhost/127.0.0.1 to db int computerID = computersInterface.Insert("dummy", "127.0.0.1", "", ""); // check the db to see if it's there bool found = false; DataTable all = computersInterface.SelectAll(); Assert.AreNotEqual(0, all.Rows.Count); foreach (DataRow row in all.Rows) { if (row["Hostname"].ToString().Equals("dummy")) { found = true; } } Assert.IsTrue(found); // save it to a new testbed int testbedID = new Testbeds().Insert("SaveLoadTest01"); new TestbedRelations().Insert(computerID, testbedID); bool foundInTestbed = false; DataTable testbedsResults = new TestbedRelations().FindByTestbedID(testbedID); foreach (DataRow row in testbedsResults.Rows) { if (int.Parse(row["ComputerID"].ToString()) == computerID && int.Parse(row["TestbedID"].ToString()) == testbedID) { foundInTestbed = true; } } Assert.IsTrue(foundInTestbed); new TestbedRelations().DeleteTestbed(testbedID); new Testbeds().Delete(testbedID); }