public void TestLoadTree() { string validXml = File.ReadAllText("../../test_files/valid.xml"); gxtl = new GenericXmlTreeLoader(validXml); TreeNode treeNode = gxtl.LoadTree(); //Check if LoadTree has expected results Assert.IsNotNull(treeNode, "LoadTree returns null."); Assert.AreEqual(treeNode.ChildCount, 1, "LoadTree implementation is incorrect."); TreeNode treeNode1 = (TreeNode)(treeNode.Children[0]); Assert.AreEqual(treeNode1.ChildCount, 4, "LoadTree implementation is incorrect."); Assert.AreEqual(treeNode1.Text, "Message", "LoadTree implementation is incorrect."); TreeNode treeNode11 = (TreeNode)(treeNode1.Children[0]); TreeNode treeNode12 = (TreeNode)(treeNode1.Children[1]); TreeNode treeNode13 = (TreeNode)(treeNode1.Children[2]); TreeNode treeNode14 = (TreeNode)(treeNode1.Children[3]); Assert.AreEqual(treeNode11.ChildCount, 0, "LoadTree implementation is incorrect."); Assert.AreEqual(treeNode11.Text, "Status (Pending)", "LoadTree implementation is incorrect."); Assert.AreEqual(treeNode12.ChildCount, 0, "LoadTree implementation is incorrect."); Assert.AreEqual(treeNode12.Text, "User (John)", "LoadTree implementation is incorrect."); Assert.AreEqual(treeNode13.ChildCount, 0, "LoadTree implementation is incorrect."); Assert.AreEqual(treeNode13.Text, "Security (None)", "LoadTree implementation is incorrect."); Assert.AreEqual(treeNode14.ChildCount, 4, "LoadTree implementation is incorrect."); Assert.AreEqual(treeNode14.Text, "Entries", "LoadTree implementation is incorrect."); }
public void TestLoadTreeFail1() { gxtl = new GenericXmlTreeLoader(); gxtl.LoadTree(); }