/// <summary> /// Tests the ContentAfterSelf method on Node. /// </summary> /// <param name="context"></param> /// <returns></returns> //[Variation(Desc = "NodeContentAfterSelf")] public void NodeContentAfterSelf() { XElement parent = new XElement("parent"); XComment child = new XComment("Self is a comment"); XComment comment1 = new XComment("Another comment"); XComment comment2 = new XComment("Yet another comment"); XElement element1 = new XElement("childelement", new XElement("nested"), new XAttribute("foo", "bar")); XElement element2 = new XElement("childelement2", new XElement("nested"), new XAttribute("foo", "bar")); XAttribute attribute = new XAttribute("attribute", "value"); // If no parent, should not be any content after it. Validate.Enumerator(child.NodesAfterSelf(), new XNode[0]); // Add some content, including the child, and validate. parent.Add(attribute); parent.Add(comment1); parent.Add(element1); parent.Add(child); parent.Add(comment2); parent.Add(element2); Validate.Enumerator(child.NodesAfterSelf(), new XNode[] { comment2, element2 }); }
/// <summary> /// Tests the AllContentAfterSelf method on Node. /// </summary> /// <param name="context"></param> /// <returns></returns> //[Variation(Desc = "NodeAllContentAfterSelf")] public void NodeAllContentAfterSelf() { XElement parent = new XElement("parent"); XComment child = new XComment("Self is a comment"); XComment comment1 = new XComment("Another comment"); XComment comment2 = new XComment("Yet another comment"); XElement element1 = new XElement("childelement", new XElement("nested"), new XAttribute("foo", "bar")); XElement element2 = new XElement("childelement2", new XElement("nested"), new XAttribute("foo", "bar")); XAttribute attribute = new XAttribute("attribute", "value"); // If no parent, should not be any content after it. Validate.Enumerator<XNode>(child.NodesAfterSelf(), new XNode[0]); // Add child to parent. Should still be no content after it. // Attributes are not content. parent.Add(child); parent.Add(attribute); Validate.Enumerator<XNode>(child.NodesAfterSelf(), new XNode[0]); // Add more children and validate. parent.AddFirst(comment1); parent.AddFirst(element1); Validate.Enumerator<XNode>(child.NodesAfterSelf(), new XNode[0]); parent.Add(element2); parent.Add(comment2); Validate.Enumerator<XNode>(child.NodesAfterSelf(), new XNode[] { element2, comment2 }); }