/// <summary> /// TestR2 sub method created /// </summary> /// <param name="msg"></param> /// <param name="sndr"></param> /// <param name="temp"></param> /// <param name="wc"></param> /// <param name="xmlStr"></param> /// <param name="doc"></param> /// <param name="msgid"></param> /// <param name="key"></param> private static void TestR21(Message msg, Sender sndr, out string temp, BasicRequirementTest wc, out string xmlStr, out XDocument doc, out string msgid, out string key) { doc = XDocument.Load("Input.xml"); msgid = ""; key = ""; xmlStr = wc.InsertGenerator(doc, ref msgid, ref key, "int"); //Generate data using the xml structure temp = key; msg.content = xmlStr; Console.Write("\nSending Message..Message is \n {0} \n", msg.content); if (sndr.sendMessage(msg)) { Console.Write("\nInserted in DB with Message ID {0} successfully \n\n", msgid); Thread.Sleep(50); } WriteLine(); Write("\nShowing the <int,string> db insert"); WriteLine(); doc = XDocument.Load("Input.xml"); xmlStr = wc.InsertGenerator(doc, ref msgid, ref key, "Insert"); msg.content = xmlStr; Console.Write("\n Sending Message..Message is \n {0} \n", msg.content); if (sndr.sendMessage(msg)) { Console.Write("\nInserted in DB with Message ID {0} successfully \n\n", msgid); Thread.Sleep(50); } WriteLine(); Write("\nShowing the <string,List<string>> db insert"); WriteLine(); doc = XDocument.Load("Input.xml"); xmlStr = wc.InsertGenerator(doc, ref msgid, ref key, "StringDBInsert"); msg.content = xmlStr; Console.Write("\n Sending Message..Message is \n {0} \n", msg.content); if (sndr.sendMessage(msg)) { Console.Write("\nInserted in DB with Message ID {0} successfully \n\n", msgid); Thread.Sleep(50); } WriteLine(); Write("\nShowing the <string,List<string>> db insert"); WriteLine(); }
/// <summary> /// Requirement 3 tested for Deletion of Key/Value pairs /// </summary> void TestR3(ref Message msg, Sender sndr) { try { XmlTextReader textReader = new XmlTextReader("Input.xml"); BasicRequirementTest te = new BasicRequirementTest(); string xmlStr = ""; Console.ForegroundColor = ConsoleColor.Green; "Demonstrating Requirement #3".title('='); Write("\nAdding and Deleting key/value pairs\n"); WriteLine(); "Adding new element to DBEngine<int, string>".title(); if (File.Exists("Input.xml")) { XDocument doc = XDocument.Load("Input.xml"); string msgid = "", key = ""; xmlStr = te.InsertGenerator(doc, ref msgid, ref key, "int"); //Generate data using the xml structure msg.content = xmlStr; Console.Write("\n Sending Message..Message is \n {0} \n", msg.content); if (sndr.sendMessage(msg)) { Console.Write("\nInserted in DB with Message ID {0} successfully \n\n", msgid); Thread.Sleep(50); } "\nRemoving the new element".title(); doc = XDocument.Load("Input.xml"); //Construct DB Delete xmlStr = te.WriteDataForDelete(doc, ref msgid, ref key); //Generate data using the xml structure msg.content = xmlStr; Console.Write("\n Sending Message..Message is \n {0} \n", msg.content); if (sndr.sendMessage(msg)) { Console.Write("\nMessage sent for deletion : Key {0}, Message ID {0} successfully \n\n", key, msgid); Thread.Sleep(50); } } Thread.Sleep(3000); } catch (Exception ex) { throw new CustomException("Error occured in TestR4", ex); } }
/// <summary> /// Requirement 2& 3 tested /// </summary> void TestR2(ref Message msg, Sender sndr, ref string temp) { try { Console.ForegroundColor = ConsoleColor.Green; "Demonstrating Requirement #2".title(); Write("\nDBEngine works for two sets of Key/Value pair types"); WriteLine(); Write("\nShowing the <int,string> db insert"); WriteLine(); XmlTextReader textReader = new XmlTextReader("Input.xml"); BasicRequirementTest wc = new BasicRequirementTest(); string xmlStr = ""; if (File.Exists("Input.xml")) { XDocument doc; string msgid, key; TestR21(msg, sndr, out temp, wc, out xmlStr, out doc, out msgid, out key); doc = XDocument.Load("Input.xml"); xmlStr = wc.InsertGenerator(doc, ref msgid, ref key, "StringDBInsert"); msg.content = xmlStr; Console.Write("\nSending Message..Message is \n {0} \n", msg.content); if (sndr.sendMessage(msg)) { Console.Write("\nInserted in DB with Message ID {0} successfully \n\n", msgid); Thread.Sleep(50); } msg = new Message(); msg.fromUrl = localUrl; msg.toUrl = remoteUrl; msg.content = "done"; sndr.sendMessage(msg); } Thread.Sleep(3000); } catch (CustomException ex) { throw new CustomException("Error occured while modifying the item", ex); } }