Exemplo n.º 1
0
        public Boolean test_undo()
        {
            bool      gflag = true;
            bool      fflag = true;
            Hashtable temp  = record.undo();

            if (temp["opt"] == "spl")
            {
                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 t_f = t_pool.getFinish(t_pool.getByName(name)).getName().ToString();
                String t_s = t_pool.getStart(t_pool.getByName("Trip_" + (Module.getIndex(name) + 1))).getName().ToString();

                core.undo(temp);
                MessageBox.Show(l_t1 + "   " + l_t2 + "  " + t_pool.getByName(name).getFeatures().getChildNodes().getLength());

                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 split on GUI level");
                }
                catch
                {
                    Console.WriteLine("#Failed to undo the previous split 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[1]["Finish"].ToString();
                    String         r_duration1 = txtedit.getViewer().Rows[0]["Time"].ToString();
                    String         r_duration2 = txtedit.getViewer().Rows[1]["Time"].ToString();

                    double gap = ((Convert.ToDateTime(txtedit.getViewer().Rows[1]["Start"].ToString()) - Convert.ToDateTime(txtedit.getViewer().Rows[0]["Finish"].ToString()))).TotalSeconds;

                    String r_slon = txtedit.getViewer().Rows[0]["sLongitude"].ToString();
                    String r_flon = txtedit.getViewer().Rows[1]["fLongitude"].ToString();
                    String r_slat = txtedit.getViewer().Rows[0]["sLatitude"].ToString();
                    String r_flat = txtedit.getViewer().Rows[1]["fLatitude"].ToString();

                    txtedit.joinTrips(day.getName(), name, "Trip_" + (Module.getIndex(name) + 1), t_pool);
                    try
                    {
                        Assert.AreEqual(txtedit.getViewer().Rows[0]["Finish"].ToString(), t_f);
                        Assert.AreEqual(txtedit.getViewer().Rows[0]["Start"].ToString(), t_s);

                        Console.WriteLine("#Passed to compute the correct start and finish time");
                    }
                    catch
                    {
                        Console.WriteLine("#Failed to compute the correct start and finish time ");
                        fflag = false;
                    }
                    String flon = txtedit.getViewer().Rows[0]["fLongitude"].ToString();
                    String slat = txtedit.getViewer().Rows[0]["sLatitude"].ToString();


                    try
                    {
                        //                                Assert.AreEqual(flon, r_slon);
                        //                               Assert.AreEqual(slat, r_flon);
                        Console.WriteLine("#Passed to compute the correct start and finish coordinates");
                    }
                    catch
                    {
                        Console.WriteLine("#Failed to compute the correct start and finish coordinates");
                        fflag = false;
                    }
                    Assert.AreEqual(fflag, true);
                    Console.WriteLine("#Passed the test for undo the previous split on file level ");
                }
                catch
                {
                    Console.WriteLine("#Failed the test for undo the previous split on file level -");
                }
            }
            else if (temp["opt"] == "ins")
            {
                String name    = (String)temp["data"];
                int    ts_init = t_pool.getSize();

                MessageBox.Show(name);
                core.undo(temp);

                MessageBox.Show(ts_init + "   " + t_pool.getSize());
                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 to undo the previous insert on GUI level ");
                    gflag = false;
                }
            }


            return(gflag && fflag);
        }