public Boolean test_undo_insert() { bool gflag = true; bool fflag = true; //Store all the actions into a hashtable Hashtable temp = record.undo(); //Checking for the option insert if (temp["opt"] == "ins") { //Declarations for the data structures and variables ArrayList data = (ArrayList)temp["data"]; String name = (String)data[0]; String[] att = (String[])data[2]; int ts_init = t_pool.getSize(); int l_t1 = t_pool.getByName(name).getFeatures().getChildNodes().getLength(); int l_t2 = t_pool.getByName("Trip_" + (Module.getIndex(name) + 1)).getFeatures().getChildNodes().getLength(); String[] att1 = t_pool.getAttByName(name); String[] att2 = t_pool.getAttByName("Trip_" + (Module.getIndex(name) + 1)); // MessageBox.Show(l_t1 + " " + l_t2 + " " + t_pool.getByName(name).getFeatures().getChildNodes().getLength()); core.undo(record.undo()); try { Assert.AreEqual(ts_init, t_pool.getSize() + 1); // MessageBox.Show(l_t1 + " " + l_t2 + " " + t_pool.getByName(name).getFeatures().getChildNodes().getLength()); // Assert.AreEqual(t_pool.getByName(name).getFeatures().getChildNodes().getLength(), l_t1 + l_t2); Console.WriteLine("#Passed undo the previous insert on GUI level <<<<<<<<<<<<"); } catch { Console.WriteLine("#Failed Failed to undo the previous insert on GUI level <-----------"); gflag = false; } try { try { Assert.AreEqual(att[4], att1[4]); Assert.AreEqual(att[5], att2[5]); Console.WriteLine("#Passed to compute the correct start and finish time for inserted trip <<<<<<<<<<<<"); } catch { Console.WriteLine("#Failed to compute the correct start and finish time for inserted trip<-----------"); fflag = false; } try { Assert.AreEqual(Module.durationConverter(att[9]), att1[9]); Assert.AreEqual(Module.durationConverter(att[10]), att1[10]); Assert.AreEqual(Module.durationConverter(att[11]), att2[11]); Assert.AreEqual(Module.durationConverter(att[12]), att2[12]); Console.WriteLine("#Passed to compute the correct start and finish coordinates inserted trip"); } catch { Console.WriteLine(" -----------> Failed to compute the correct start and finish coordinates inserted trip"); fflag = false; } Assert.AreEqual(fflag, true); Console.WriteLine("#Passed the test for undo the previous inserted trip on file level <<<<<<<<<<<<"); } catch { Console.WriteLine("#Failed Failed the test for undo the previous inserted trip on file level <-----------"); } } return(gflag && fflag); }
public Boolean split_test(String name, int index) { //create a kml folder by tripname IKmlFolder temp = t_pool.getByName(name); // get the current placemark and the pre placemark at a given index IKmlPlacemark sst = (IKmlPlacemark)temp.getFeatures().getChildNodes().item(index - 1); IKmlPlacemark st = (IKmlPlacemark)temp.getFeatures().getChildNodes().item(index); // get trip size, number of trips and number of columns(lat,long ,elapse time etc) int pt_size = temp.getFeatures().getChildNodes().getLength(); int init_size_t = t_pool.getSize(); core.split(st); //get index + 1 of the current trip String _name = "Trip_" + (Module.getIndex(name) + 1); Boolean gflag = true; Boolean fflag = true; try { int final_size_t = t_pool.getSize(); //compare the initial size of the t pool against the final t pool. Assert.AreEqual(init_size_t, final_size_t - 1); //compare the split index with the size of the first half of the splitted trip Assert.AreEqual(index, t_pool.getByName(name).getFeatures().getChildNodes().getLength()); // compare the split index with the size of the second half of the splitted trip Assert.AreEqual(pt_size - index, t_pool.getByName(_name).getFeatures().getChildNodes().getLength()); Console.WriteLine(" >>>>>>>>>>>> Passed the test for split the trip on GUI level <<<<<<<<<<<<"); } catch { Console.WriteLine(" -----------> Failed the test for split the trip on GUI level <-----------"); gflag = false; } try { IKmlObjectList days = ge.getFeatures().getChildNodes(); IKmlDocument day = (IKmlDocument)days.item(0); String r_start = txtedit.getViewer().Rows[0]["Start"].ToString(); String r_finsih = txtedit.getViewer().Rows[0]["Finish"].ToString(); String r_duration = txtedit.getViewer().Rows[0]["Time"].ToString(); String r_slon = txtedit.getViewer().Rows[0]["sLongitude"].ToString(); String r_flon = txtedit.getViewer().Rows[0]["fLongitude"].ToString(); String r_slat = txtedit.getViewer().Rows[0]["sLatitude"].ToString(); String r_flat = txtedit.getViewer().Rows[0]["fLatitude"].ToString(); txtedit.splitTrip(day.getName(), Module.getIndex(name).ToString(), t_pool.getStart(t_pool.getByName("Trip_" + (Module.getIndex(name) + 1))), t_pool.getFinish(t_pool.getByName(name)), t_pool); try { Assert.AreEqual(txtedit.getViewer().Rows[0]["Finish"].ToString(), t_pool.getFinish(t_pool.getByName(name)).getName().ToString()); Assert.AreEqual(txtedit.getViewer().Rows[1]["Start"].ToString(), t_pool.getStart(t_pool.getByName("Trip_" + (Module.getIndex(name) + 1))).getName().ToString()); Console.WriteLine(" >>>>>>>>>>>> Succeed to compute the correct start and finish time <<<<<<<<<<<<"); } catch { Console.WriteLine(" -----------> Failed to compute the correct start and finish time <-----------"); fflag = false; } try { double tp1 = Module.durationConverter(txtedit.getViewer().Rows[0]["Time"].ToString()); double gap = ((Convert.ToDateTime(txtedit.getViewer().Rows[1]["Start"].ToString()) - Convert.ToDateTime(txtedit.getViewer().Rows[0]["Finish"].ToString()))).TotalSeconds; double tp2 = Module.durationConverter(txtedit.getViewer().Rows[1]["Time"].ToString()); // MessageBox.Show(Module.durationConverter(txtedit.getViewer().Rows[0]["Time"].ToString()) + " " + t.ToString() + " " + Module.durationConverter(txtedit.getViewer().Rows[1]["Time"].ToString()) + " " + Module.durationConverter(r_duration)); Assert.AreEqual(Module.durationConverter(r_duration), tp1 + gap + tp2); Console.WriteLine(" >>>>>>>>>>>> Succeed to compute the correct trip duration <<<<<<<<<<<<"); } catch { Console.WriteLine(" -----------> Failed to compute the correct the trip duration <-----------"); fflag = false; } try { String n_slon = txtedit.getViewer().Rows[1]["sLongitude"].ToString(); String n_slat = txtedit.getViewer().Rows[1]["sLatitude"].ToString(); String n_flon = txtedit.getViewer().Rows[0]["sLongitude"].ToString(); String n_flat = txtedit.getViewer().Rows[0]["sLatitude"].ToString(); String a_slon = Module.getCoordinates(t_pool.getStart(t_pool.getByName("Trip_" + (Module.getIndex(name) + 1))))["lon"].ToString(); String a_slat = Module.getCoordinates(t_pool.getStart(t_pool.getByName("Trip_" + (Module.getIndex(name) + 1))))["lat"].ToString(); String a_flon = Module.getCoordinates(t_pool.getStart(t_pool.getByName(name)))["lon"].ToString(); String a_flat = Module.getCoordinates(t_pool.getStart(t_pool.getByName(name)))["lat"].ToString(); /* * MessageBox.Show(n_slon+" "+a_slon); * MessageBox.Show(n_slat + " " + a_slat); * * MessageBox.Show(n_flon + " " + a_flon); * MessageBox.Show(n_flat + " " + a_flat); * * Assert.AreEqual(n_slat.Trim(), a_slat.Trim()); * Assert.AreEqual(n_slon.Trim(), a_slon.Trim()); * * Assert.AreEqual(n_flat.Trim(), a_flat.Trim()); * Assert.AreEqual(n_flon.Trim(), a_flon.Trim()); */ Console.WriteLine(" >>>>>>>>>>>> Succeed to compute the correct start and finish coordinates <<<<<<<<<<<<<"); } catch { Console.WriteLine(" -----------> Failed to compute the correct start and finish coordinates <----------"); fflag = false; } Assert.AreEqual(true, fflag); Console.WriteLine(" >>>>>>>>>>>> Passed the test for split the trip on file level <<<<<<<<<<<<<"); } catch { Console.WriteLine(" -----------> Failed the test for split the trip on file level <----------"); } return(gflag && fflag); }