public void OnButtonOKClickedTest() { Form1_Accessor target = new Form1_Accessor(); // TODO: Initialize to an appropriate value object sender = null; // TODO: Initialize to an appropriate value EventArgs e = null; // TODO: Initialize to an appropriate value // empty the data.xml if it exists XmlDocument doc = new XmlDocument(); try { doc.Load("data.xml"); } catch (Exception) { doc.LoadXml("<item></item>"); } XmlTextWriter writer = new XmlTextWriter("data.xml", null); writer.Formatting = Formatting.Indented; doc.WriteTo(writer); writer.Close(); target.textBox_play.Text = "Control + P"; target.textBox_stop.Text = "Control + S"; target.textBox_full.Text = "Alt + Enter"; target.textBox_mute.Text = "F7"; target.textBox_fwd.Text = "Shift + Control + F"; target.textBox_bwd.Text = "Shift + Control + B"; target.textBox_vup.Text = "F9"; target.textBox_vdown.Text = "F8"; target.textBox_class_name.Text = "WMPlayerApp"; target.OnButtonOKClicked(sender, e); //check the elements in the xml doc.Load("data.xml"); //the test shows NULL, need to parse in next time XmlNode root = doc.FirstChild; if (root.HasChildNodes) { XmlNode child = root.FirstChild; if (child.HasChildNodes) { for (int i = 0; i < child.ChildNodes.Count; i++) { if(i == 0) Assert.AreEqual(child.ChildNodes[i].InnerText, "WMPlayerApp"); if (i == 1) Assert.AreEqual(child.ChildNodes[i].InnerText, "Control + P"); if (i == 2) Assert.AreEqual(child.ChildNodes[i].InnerText, "Control + S"); if (i == 3) Assert.AreEqual(child.ChildNodes[i].InnerText, "Alt + Enter"); if (i == 4) Assert.AreEqual(child.ChildNodes[i].InnerText, "Shift + Control + F"); if (i == 5) Assert.AreEqual(child.ChildNodes[i].InnerText, "Shift + Control + B"); if (i == 6) Assert.AreEqual(child.ChildNodes[i].InnerText, "F7"); if (i == 7) Assert.AreEqual(child.ChildNodes[i].InnerText, "F9"); if (i == 8) Assert.AreEqual(child.ChildNodes[i].InnerText, "F8"); } } } }