public void TestLoadChildren()
        {
            string validXml = File.ReadAllText("../../test_files/valid.xml");

            gxtl = new GenericXmlTreeLoader(validXml);

            //Try some paths and check for correct return values.
            int[]      path1       = new int[] { 0, 3, 1 };
            TreeNode[] treeNodeArr = gxtl.LoadChildren(path1);
            Assert.IsNotNull(treeNodeArr, "LoadChildren returns null");
            Assert.AreEqual(treeNodeArr.Length, 2, "LoadChildren returns wrong node");
            Assert.AreEqual(treeNodeArr[0].Text, "ID (2)", "LoadChildren returns wrong node");

            int[] path2 = new int[] { 0, 3, 1 };
            treeNodeArr = gxtl.LoadChildren(path2);
            Assert.IsNotNull(treeNodeArr, "LoadChildren returns null");
            Assert.AreEqual(treeNodeArr.Length, 2, "LoadChildren returns wrong node");
            Assert.AreEqual(treeNodeArr[1].Text, "Date (\r\n        03/08/2007)", "LoadChildren returns wrong node");

            int[] path3 = new int[] { 0, 2 };
            treeNodeArr = gxtl.LoadChildren(path3);
            Assert.IsNotNull(treeNodeArr, "LoadChildren returns null");
            Assert.AreEqual(treeNodeArr.Length, 0, "LoadChildren returns wrong node");

            int[] path4 = new int[] { 0, 3 };
            treeNodeArr = gxtl.LoadChildren(path4);
            Assert.IsNotNull(treeNodeArr, "LoadChildren returns null");
            Assert.AreEqual(treeNodeArr.Length, 4, "LoadChildren returns wrong node");
            Assert.AreEqual(treeNodeArr[0].Text, "Entry", "LoadChildren returns wrong node");
            Assert.AreEqual(treeNodeArr[1].Text, "Entry", "LoadChildren returns wrong node");
            Assert.AreEqual(treeNodeArr[2].Text, "Entry (\r\n      Test with a mixed element  content\r\n    )",
                            "LoadChildren returns wrong node");
        }
        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 TestLoadChildrenFail4()
        {
            string validXml = File.ReadAllText("../../test_files/valid.xml");

            gxtl = new GenericXmlTreeLoader(validXml);

            gxtl.LoadChildren(new int[] { 0, 5 });
        }
        public void TestConstructor2()
        {
            string validXml = File.ReadAllText("../../test_files/valid.xml");

            //No exception should be thrown here
            gxtl = new GenericXmlTreeLoader(validXml);

            Assert.IsNotNull(gxtl, "GenericXmlTreeLoader constructor returns null.");
            Assert.IsTrue(gxtl is ITreeLoader, "GenericXmlTreeLoader instance has incorrect type.");
            Assert.AreEqual(gxtl.Xml, validXml, "Constructor implementation is incorrect.");
        }
        public void TestConstructor2_Fail3()
        {
            string xml = File.ReadAllText("../../test_files/invalid_comment.xml");

            gxtl = new GenericXmlTreeLoader(xml);
        }
 public void TestConstructor2_Fail2()
 {
     gxtl = new GenericXmlTreeLoader("           ");
 }
 public void TestConstructor2_Fail1()
 {
     gxtl = new GenericXmlTreeLoader((string)null);
 }
 public void TearDown()
 {
     gxtl = null;
 }
 public void TestLoadTreeFail1()
 {
     gxtl = new GenericXmlTreeLoader();
     gxtl.LoadTree();
 }
 public void SetUp()
 {
     gxtl = new GenericXmlTreeLoader();
 }
        public void TestConstructor2_Fail10()
        {
            string xml = File.ReadAllText("../../test_files/invalid_wrong_tag_order.xml");

            gxtl = new GenericXmlTreeLoader(xml);
        }
        public void TestConstructor2_Fail8()
        {
            string xml = File.ReadAllText("../../test_files/invalid_two_attributes_same_name.xml");

            gxtl = new GenericXmlTreeLoader(xml);
        }