Beispiel #1
0
        // function to delete from database
        public XElement Delete(XElement dbe, DBEngine <int, DBElement <int, string> > db)
        {
            DBElement <int, string> elem = new DBElement <int, string>();

            Console.WriteLine("\n----------Delete Operation----------");
            Console.Write("\n Now deleting the element with key=3");
            bool result = db.remove(Int32.Parse((dbe.Element("key").Value)));

            db.showDB();
            if (result == true)
            {
                XElement s = new XElement("result", "\n Element deleted successfully ");
                return(s);
            }
            else
            {
                XElement f = new XElement("result", "Failure");
                return(f);
            }
        }
        void TestR3()
        {
            "Demonstrating Requirement #3".title();
            //demonstrating addition and removal of key/value pairs pairs
            WriteLine("\n Database contents before addition");
            db.showDB();
            WriteLine();
            WriteLine(" \n Database contents after addition-----");
            DBElement <int, string> insert1 = new DBElement <int, string>();

            insert1.name      = "first inserted element";
            insert1.descr     = "int and string values database";
            insert1.timeStamp = DateTime.Now;
            insert1.children.AddRange(new List <int> {
                7, 7, 8, 3, 8, 8, 5, 5, 7
            });
            insert1.payload = "first inserted elements payload";
            db.insert(2, insert1);

            DBElement <int, string> insert2 = new DBElement <int, string>();

            insert2.name      = "second inserted element";
            insert2.descr     = "int and string values";
            insert2.timeStamp = DateTime.Now;
            insert2.children.AddRange(new List <int> {
                1, 3, 5, 7
            });
            insert2.payload = "second inserted elements payload";
            db.insert(3, insert2);
            db.showDB();
            WriteLine();
            WriteLine(" \n Database before contents are removed");
            db.showDB();
            WriteLine("\n \n second element to be removed");
            db.remove(2);
            db.showDB();
            WriteLine();
        }
Beispiel #3
0
        // test stub for processor
        // main function
        static void Main(string[] args)
        {
            DBEngine <int, DBElement <int, string> > db = new DBEngine <int, DBElement <int, string> >();

            "Testing the Package".title('=');
            Console.WriteLine();
            Console.WriteLine("\n remote operations are done are and tested");
            Console.Write("\n");
            DBElement <int, string> elem = new DBElement <int, string>();

            Console.WriteLine("\n----------Delete Operation----------");
            Console.Write("\n Now deleting the element with key=3");
            bool result = db.remove(2);

            db.showDB();
            if (result == true)
            {
                XElement s = new XElement("result", "\n Element deleted successfully ");
            }
            else
            {
                XElement f = new XElement("result", "Failure");
            }
        }