void TestR4() { "Demonstrating Requirement #4".title(); WriteLine("\n Database before addition "); db.showDB(); //Demonstrating addition of relationships bool ar1 = db.addRelations <int, DBElement <int, string>, string>(1, 3); bool ar2 = db.addRelations <int, DBElement <int, string>, string>(3, 0); WriteLine("\n \n addition of relationships "); db.showDB(); if (ar1 && ar2) { WriteLine(" \n addition Succesfull "); } //Demonstrating removal of relationships WriteLine(" \n DataBase before removing relationships"); db.showDB(); bool remove1 = db.removeRelation <int, DBElement <int, string>, string>(1, 2); bool remove2 = db.removeRelation <int, DBElement <int, string>, string>(3, 1); WriteLine(); WriteLine("\n DataBase contents after removal"); db.showDB(); if (remove1 && remove2) { WriteLine("\n Removal Successful"); } //Demonstrating editing of metadata text WriteLine("\n DataBase before editing metadata text "); db2.showEnumerableDB(); bool editn1 = db2.editName <string, DBElement <string, List <string> >, List <string> >("2", "Edited name for second element"); bool editn2 = db2.editDescr <string, DBElement <string, List <string> >, List <string> >("2", "New description for second element"); WriteLine("\n \n DataBase after editing"); db2.showEnumerableDB(); }
static void Main(string[] args) { "Testing ItemEditor Package".title('='); WriteLine(); Write("\n --- Test DBElement<int,string> ---"); // new database created to test the functionaity DBEngine <int, DBElement <int, string> > db = new DBEngine <int, DBElement <int, string> >(); // new elements are created and inserted to the database DBElement <int, string> elem1 = new DBElement <int, string>("first element", "first element description"); DBElement <int, string> elem2 = new DBElement <int, string>("second element", "second element description"); DBElement <int, string> elem3 = new DBElement <int, string>("third element", "third element description"); elem1.payload = "Payload of 1"; elem1.children.AddRange(new List <int> { 1, 2, 3 }); elem2.payload = "Payload of 2"; elem2.children.AddRange(new List <int> { 11, 22, 33 }); elem3.payload = "Payload of 3"; elem3.children.AddRange(new List <int> { 111, 222, 333 }); // inserting elements to database db.insert(1, elem1); db.insert(2, elem2); db.insert(3, elem3); db.showDB(); // testing addition of relationships to elements Write("\n\n Testing of addition of new relationships"); bool addr1 = db.addRelations <int, DBElement <int, string>, string>(1, 2); bool addr2 = db.addRelations <int, DBElement <int, string>, string>(2, 3); bool addr3 = db.addRelations <int, DBElement <int, string>, string>(3, 111); db.showDB(); // testing removing relationships to elements Write("\n\n Testing of removal of relations"); bool remr1 = db.removeRelation <int, DBElement <int, string>, string>(2, 11); bool remr2 = db.removeRelation <int, DBElement <int, string>, string>(1, 3); db.showDB(); if (remr1 && remr2) { Write("\n \n Removal succeded"); } // Testing editing of text data Write("\n\n Testing of editing of text data"); bool ed_name1 = db.editName <int, DBElement <int, string>, string>(1, "renaming of element 1"); bool ed_descr = db.editDescr <int, DBElement <int, string>, string>(1, "editing description of element 1"); bool ed_inst = db.editInstance <int, DBElement <int, string>, string>(1, "new instance for element 1"); db.showDB(); Write("\n\n --- Test DBElement<string,List<string>> ---"); // creating elements to new database of type string,List of strings DBElement <string, List <string> > new_elem1 = new DBElement <string, List <string> >("new element 1", "Description of 1"); DBElement <string, List <string> > new_elem2 = new DBElement <string, List <string> >("new element 2", "Description of 2"); DBElement <string, List <string> > new_elem3 = new DBElement <string, List <string> >("new element 3", "Description of 3"); //creating new database DBEngine <string, DBElement <string, List <string> > > new_db = new DBEngine <string, DBElement <string, List <string> > >(); new_elem1.payload = new List <string> { "First data in payload ", "Second data in payload", "Third data in payload" }; new_elem1.children.AddRange(new List <string> { "one", "two", "three" }); new_elem2.payload = new List <string> { "DP", "SMA", "OOD" }; new_elem2.children.AddRange(new List <string> { "four", "five", "six" }); new_elem3.payload = new List <string> { "CE", "CS", "EE" }; new_elem3.children.AddRange(new List <string> { "seven", "eight", "nine" }); // inserting elements to database new_db.insert("One", new_elem1); new_db.insert("Two", new_elem2); new_db.insert("Three", new_elem3); new_db.showEnumerableDB(); // testing addition of relationships to elements Write("\n\n testing addition of relationship "); bool add1 = new_db.addRelations <string, DBElement <string, List <string> >, List <string> >("One", "two"); bool add2 = new_db.addRelations <string, DBElement <string, List <string> >, List <string> >("Two", "three"); bool add3 = new_db.addRelations <string, DBElement <string, List <string> >, List <string> >("Three", "one"); new_db.showEnumerableDB(); if (add1 && add2 && add3) { Write("\n \n Adding relationship successful."); } // testing removing relationships to elements Write("\n \n Now going to test removing of relationships in DB-element: Element-One"); bool rem1 = new_db.removeRelation <string, DBElement <string, List <string> >, List <string> >("One", "Nine"); bool rem2 = new_db.removeRelation <string, DBElement <string, List <string> >, List <string> >("One", "two"); new_db.showEnumerableDB(); if (rem1 && rem2) { Write("\n \n Deleting of relationships succeeded "); } // Testing editing of text data Write("\n \n Now going to test edition of name, description and replacing instance of payload with new instance in Element-One."); new_db.editName <string, DBElement <string, List <string> >, List <string> >("One", "Edited name for Element-One"); new_db.editDescr <string, DBElement <string, List <string> >, List <string> >("One", "New description for Element-One"); new_db.editInstance <string, DBElement <string, List <string> >, List <string> >("One", new List <string> { "New payload - String One", "New payload - String Two", "New payload - String Three" }); new_db.showEnumerableDB(); WriteLine(); }