Ejemplo n.º 1
0
        public Boolean insert_test(String name)
        {
            String _name = "Trip_" + (Module.getIndex(name) + 1);
            //create a kml folder by tripname
            IKmlFolder temp  = t_pool.getByName(name);
            IKmlFolder temp2 = 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();
            int init_size_a = t_pool.getAttrs().Count;

            // //get the attribute data by trip name
            // String[] att = t_pool.getAttByName(name);

            // MessageBox.Show((Module.getIndex(name) + 1).ToString());
            core.insert(name, _name);


            //get index + 1 of the current trip


            Boolean gflag = true;

            // Boolean fflag = true;
            try
            {
                int final_size_t = t_pool.getSize();

                //CASE 1: compare the initial size of the t pool against the final t pool.
                Assert.AreEqual(init_size_t, final_size_t - 1);
                //Case 2: Trip is inserted between the two selected trips
                Assert.AreEqual(temp, t_pool.getByName(name));
                Assert.AreEqual(temp2, t_pool.getByName("Trip_" + (Module.getIndex(name) + 2)));

                Console.WriteLine("#Passed the test for insert the trip on GUI level ");
            }
            catch
            {
                Console.WriteLine("#Failed  the test for insert the trip on GUI level ");
                gflag = false;
            }


            try
            {
                // Test start point of newly inserted trip start pt= end pt of previous trip, finish pt = start pt of next trip


                String tp1_flon = Module.getCoordinates(t_pool.getFinish(t_pool.getByName(name)))["lon"].ToString();
                String tp1_flat = Module.getCoordinates(t_pool.getFinish(t_pool.getByName(name)))["lat"].ToString();
                String tp2_slon = Module.getCoordinates(t_pool.getStart(t_pool.getByName(_name)))["lon"].ToString();
                String tp2_slat = Module.getCoordinates(t_pool.getStart(t_pool.getByName(_name)))["lat"].ToString();

                String tp2_flon = Module.getCoordinates(t_pool.getFinish(t_pool.getByName(_name)))["lon"].ToString();
                String tp2_flat = Module.getCoordinates(t_pool.getFinish(t_pool.getByName(_name)))["lat"].ToString();
                String tp3_slon = Module.getCoordinates(t_pool.getStart(t_pool.getByName("Trip_" + (Module.getIndex(name) + 2))))["lon"].ToString();
                String tp3_slat = Module.getCoordinates(t_pool.getStart(t_pool.getByName("Trip_" + (Module.getIndex(name) + 2))))["lat"].ToString();


                Assert.AreEqual(tp2_slon, tp1_flon); Assert.AreEqual(tp2_slat, tp1_flat); //Start trip 2(lon,lat) = End trip 1(lon,lat)
                Assert.AreEqual(tp2_flon, tp3_slon); Assert.AreEqual(tp2_flat, tp3_slat); // End trip 2(lon,lat) = Start trip 3(lon,lat)


                Console.WriteLine("#Passed to compute the correct start and finish coordinates");
            }
            catch
            {
                Console.WriteLine("#Failed to compute the correct start and finish coordinates");
                gflag = false;
            }

            try
            {
                Console.WriteLine("#Passed the test for Insert the trip on file level");
            }
            catch
            {
                Console.WriteLine("#Failed the test for Insert the trip on file level");
                gflag = false;
            }


            return(gflag);
        }