static void Main(string[] args) { "Testing ItemEditor Package".title('='); WriteLine(); ItemEditorTest iET = new ItemEditorTest(); iET.insertData(db); DBEngine <int, DBElement <int, string> > db = new DBEngine <int, DBElement <int, string> >(); ItemEditor <int, DBElement <int, string> > iEditor = new ItemEditor <int, DBElement <int, string> >(db); "\n1) Editing metadata".title(); "\nBefore editing metadata for key 1".title(); db.showDB(); "\nAfter editing metadata for key 1".title(); iEditor = new ItemEditor <int, DBElement <int, string> >(db); iEditor.editMetaData(1, "Sachin Tendulkar", "Cricket player"); //send the values to be edited to the editMetaData() function db.showDB(); WriteLine(); "\n2) Adding children".title(); "\nBefore adding relationship(children) for key 1".title(); db.showDB(); "\nAfter adding relationship(children) for Key 1".title(); iEditor.addrelationships(1, new List <int> { 3 }); //send a new list with children to be added to a key db.showDB(); WriteLine(); "\n3) Deleting children".title(); "\nBefore deleting relationship(children) for key 1".title(); db.showDB(); WriteLine(); "\nAfter deleting relationship(children) to Key 1".title(); //send a new list with children to be deleted from a key iEditor.deleteRelationships(1, new List <int> { 3 }); db.showDB(); WriteLine(); "\n4) Replacing value instance".title(); DBElement <int, string> elem = new DBElement <int, string>(); //create a new element for replacing value elem.name = "Messi"; elem.payload = "Plays for Argentina"; elem.descr = "Football player"; elem.children.AddRange(new List <int> { 2 }); elem.timeStamp = DateTime.Now; "\nBefore replacing the value instance for key 2".title(); db.showDB(); WriteLine(); "\nAfter replacing the value instance for key 2".title(); iEditor.replaceValueInstance(2, elem); //send value to be replaced for a key db.showDB(); }
static void Main(string[] args) { DBEngine <int, DBElement <int, string> > db = new DBEngine <int, DBElement <int, string> >(); ItemFactory <int, string> itemFactory = new ItemFactory <int, string>(); "Demonstrating Requirement #2".title(); DBElement <int, string> elem = itemFactory.Create(); elem.name = "element"; elem.descr = "test element"; elem.timeStamp = DateTime.Now.AddDays(-4); elem.children.AddRange(new List <int> { 1, 2, 3 }); elem.payload = "elem's payload"; WriteLine("\n Item to be inserted.. \n"); elem.showElement(); db.insert(1, elem); db.showDB(); WriteLine(); WriteLine("\n Inserting second element into DB :"); DBElement <int, string> elem2 = new DBElement <int, string>(); elem2.name = "element2"; elem2.descr = "test element2"; elem2.timeStamp = DateTime.Now; elem2.children.AddRange(new List <int> { 1, 2, 3, 4 }); elem2.payload = "elem2's payload"; WriteLine("\nItem to be inserted.. \n"); elem2.showElement(); db.insert(2, elem2); WriteLine("\n\n DB after insertion:"); db.showDB(); "Adding relationship :".title('.'); WriteLine("\n Elements in DB :"); db.showDB(); int key = 2; var children = new List <int> { 5, 6 }; WriteLine("\n Add children for key {0} : ", key); foreach (var child in children) { Write("{0}, ", child); } WriteLine(); db.addRelationship(key, children); WriteLine("\n\n DB after the change :"); db.showDB(); WriteLine(); "".demarcation(); ItemEditorTest editorTest = new ItemEditorTest(); editorTest.test(); }
static void Main(string[] args) { "Testing ItemEditor Package".title('='); WriteLine(); ItemEditorTest iET = new ItemEditorTest(); iET.insertData(db); DBEngine<int,DBElement<int,string>> db = new DBEngine<int, DBElement<int, string>>(); ItemEditor<int, DBElement<int,string>> iEditor = new ItemEditor<int, DBElement<int,string>>(db); "\n1) Editing metadata".title(); "\nBefore editing metadata for key 1".title(); db.showDB(); "\nAfter editing metadata for key 1".title(); iEditor = new ItemEditor<int, DBElement<int, string>>(db); iEditor.editMetaData(1, "Sachin Tendulkar", "Cricket player"); //send the values to be edited to the editMetaData() function db.showDB(); WriteLine(); "\n2) Adding children".title(); "\nBefore adding relationship(children) for key 1".title(); db.showDB(); "\nAfter adding relationship(children) for Key 1".title(); iEditor.addrelationships(1, new List<int> { 3 }); //send a new list with children to be added to a key db.showDB(); WriteLine(); "\n3) Deleting children".title(); "\nBefore deleting relationship(children) for key 1".title(); db.showDB(); WriteLine(); "\nAfter deleting relationship(children) to Key 1".title(); //send a new list with children to be deleted from a key iEditor.deleteRelationships(1, new List<int> { 3 }); db.showDB(); WriteLine(); "\n4) Replacing value instance".title(); DBElement<int, string> elem = new DBElement<int, string>(); //create a new element for replacing value elem.name = "Messi"; elem.payload = "Plays for Argentina"; elem.descr = "Football player"; elem.children.AddRange(new List<int> { 2 }); elem.timeStamp = DateTime.Now; "\nBefore replacing the value instance for key 2".title(); db.showDB(); WriteLine(); "\nAfter replacing the value instance for key 2".title(); iEditor.replaceValueInstance(2, elem); //send value to be replaced for a key db.showDB(); }