public void Builds_xml_document() { IXmlDocumentBuilder builder = new XmlDocumentBuilder(); XmlDocument document = builder.Build("<test />"); Assert.That(document.Name, Is.EqualTo("#document")); Assert.That(document.ChildNodes.Count, Is.EqualTo(1)); Assert.That(document.ChildNodes[0].Name, Is.EqualTo("test")); }
public void Sort_Nodes_Benchmark_Legacy() { XmlDocument xml = _builder.Build(); XmlElement original = xml.GetElementById(1173.ToString()); Assert.IsNotNull(original); long totalTime = 0; var watch = new Stopwatch(); var iterations = 10000; for (var i = 0; i < iterations; i++) { // don't measure the time for clone! XmlNode parentNode = original.Clone(); watch.Start(); LegacySortNodes(ref parentNode); watch.Stop(); totalTime += watch.ElapsedMilliseconds; watch.Reset(); // Do assertions just to make sure it is working properly. var currSort = 0; foreach (XmlNode child in parentNode.SelectNodes("./* [@id]").Cast <XmlNode>()) { Assert.AreEqual(currSort, int.Parse(child.Attributes["sortOrder"].Value)); currSort++; } // Ensure the parent node's properties still exist first. Assert.AreEqual("content", parentNode.ChildNodes[0].Name); Assert.AreEqual("umbracoUrlAlias", parentNode.ChildNodes[1].Name); // Then the child nodes should come straight after. Assert.IsTrue(parentNode.ChildNodes[2].Attributes["id"] != null); } Debug.WriteLine("Total time for " + iterations + " iterations is " + totalTime); }