void TestR6() { "Demonstrating Requirement #6".title(); Write("\n --- Test sheduler---"); dbInt.showDB(); PersistWapper <int, DBElement <int, string> > persist = new IntAndString(dbInt); Schedular <int, DBElement <int, string> > test = new Schedular <int, DBElement <int, string> >(); Write("\n persist database in ./DatabaseContent2.xml"); test.autoSave(persist, 1000, "DatabaseContent2.xml"); ReadKey(); WriteLine(); }
// test write DBEngine<int,DBElement<int,string>> to xml static void TestWriteToXML() { Write("\n ---convert database content to XML ---"); DBElement <int, string> elem1 = new DBElement <int, string>(); elem1.descr = "payload desxription"; elem1.name = "element 1"; elem1.timeStamp = DateTime.Now; elem1.payload = "a payload"; WriteLine(); DBElement <int, string> elem2 = new DBElement <int, string>("Darth Vader", "Evil Overlord"); elem2.descr = "star war 2"; elem2.name = "element 2"; elem2.timeStamp = new DateTime(2015, 9, 10, 12, 30, 1); elem2.payload = "The Empire strikes back!"; WriteLine(); var elem3 = new DBElement <int, string>("Luke Skywalker", "Young HotShot"); elem3.name = "element 3"; elem3.descr = "star war 3"; elem3.timeStamp = new DateTime(2015, 10, 2, 8, 0, 0); elem3.children = new List <int> { 1, 2, 3 }; elem3.payload = "X-Wing fighter in swamp - Oh oh!"; WriteLine(); int key = 0; Func <int> keyGen = () => { ++key; return(key); }; // anonymous function to generate keys DBEngine <int, DBElement <int, string> > db = new DBEngine <int, DBElement <int, string> >(); bool p1 = db.insert(keyGen(), elem1); bool p2 = db.insert(keyGen(), elem2); bool p3 = db.insert(keyGen(), elem3); db.show <int, DBElement <int, string>, string>(); WriteLine(); IntAndString test = new IntAndString(db); test.writeToXML("DatabaseContent.xml"); Write("\n XML file has been created in ./bin/Debug"); }
static void Main(string[] args) { DBElement <int, string> elem1 = new DBElement <int, string>(); elem1.descr = "payload desxription"; elem1.name = "element 1"; elem1.timeStamp = DateTime.Now; elem1.payload = "a payload"; DBElement <int, string> elem2 = new DBElement <int, string>("Darth Vader", "Evil Overlord"); elem2.descr = "star war 2"; elem2.name = "element 2"; elem2.timeStamp = new DateTime(2015, 9, 10, 12, 30, 1); elem2.payload = "The Empire strikes back!"; var elem3 = new DBElement <int, string>("Luke Skywalker", "Young HotShot"); elem3.name = "element 3"; elem3.descr = "star war 3"; elem3.timeStamp = new DateTime(2015, 10, 2, 8, 0, 0); elem3.children = new List <int> { 1, 2, 3 }; elem3.payload = "X-Wing fighter in swamp - Oh oh!"; int key = 0; Func <int> keyGen = () => { ++key; return(key); }; // anonymous function to generate keys DBEngine <int, DBElement <int, string> > db = new DBEngine <int, DBElement <int, string> >(); bool p1 = db.insert(keyGen(), elem1); bool p2 = db.insert(keyGen(), elem2); bool p3 = db.insert(keyGen(), elem3); WriteLine("--- Test Scheduler ---"); PersistWapper <int, DBElement <int, string> > persist = new IntAndString(db); Schedular <int, DBElement <int, string> > test = new Schedular <int, DBElement <int, string> >(); test.autoSave(persist, 1000, "DatabaseContent.xml"); ReadKey(); }