public void AddElementTest()
        {
            var doc     = new XmlDocument();
            var simpson = XmlExtensions.AddElement(doc, "Simpson");

            XmlExtensions.AddElement(simpson, "Homer", "Father");
            XmlExtensions.AddElement(simpson, "Marge", "Mother");

            Assert.AreEqual <string>("Simpson", doc.DocumentElement.Name, "DocElement name is wrong");
            Assert.AreEqual <int>(2, doc.DocumentElement.ChildNodes.Count, "Number of child nodes is wrong.");
            Assert.AreEqual <string>("Homer", doc.DocumentElement.ChildNodes[0].Name, "Name of 1st node is wrong");
            Assert.AreEqual <string>("Father", doc.DocumentElement.ChildNodes[0].InnerText, "Contents of 1st node is wrong");
            Assert.AreEqual <string>("Marge", doc.DocumentElement.ChildNodes[1].Name, "Name of 2nd node is wrong");
            Assert.AreEqual <string>("Mother", doc.DocumentElement.ChildNodes[1].InnerText, "Contents of 2nd node is wrong");

            XmlExtensions.AddElementWithAttribute(simpson, "Bart", "Child", 1);
            Assert.AreEqual <string>("Bart", doc.DocumentElement.ChildNodes[2].Name, "Bart is wrong");
            Assert.AreEqual <string>("Child", doc.DocumentElement.ChildNodes[2].Attributes[0].Name, "Name of Bart's attribute is wrong.");
            Assert.AreEqual <string>("1", doc.DocumentElement.ChildNodes[2].Attributes[0].Value, "Value of Bart's attribute is wrong.");
        }
        public void AddElementToDocTest()
        {
            var doc = new XmlDocument();

            XmlExtensions.AddElementWithAttribute(doc, "Griffin", "Dysfunctional", "Very");
            Assert.AreEqual <string>("Griffin", doc.DocumentElement.Name, "Name of the main element is wrong");
            Assert.AreEqual <string>("Dysfunctional", doc.DocumentElement.Attributes[0].Name, "Name of attribute is wrong.");
            Assert.AreEqual <string>("Very", doc.DocumentElement.Attributes[0].Value, "Value of the attribute is wrong");

            try
            {
                XmlNode node = doc.DocumentElement.Attributes[0];
                XmlExtensions.AddElementWithAttribute(node, "This", "Should", "not work!");
                Assert.Fail("Expected exception of type '" + typeof(ArgumentException).Name + "' but none was thrown.");
            }
            catch (ArgumentException) { }
            catch (Exception __e)
            {
                Assert.Fail("Expected exception of type ArgumentException, but " + __e.GetType().ToString() + " was generated instead.");
            }
        }