public void Constuctor_WithNode_Should() { var node = GetTagNode(); var tree = new NodeTree(node); Assert.AreEqual(node, tree.Root); Assert.AreEqual(node, tree.Current); }
public void FirstChild_WithNodeWithoutChildren_ShouldReturnFalseAndNotMoveCurrent() { var node = GetTagNode(); var tree = new NodeTree(node); var result = tree.FirstChild(); Assert.IsFalse(result); Assert.AreEqual(node, tree.Current); }
public void LastChild_WithNodeWithChildren_ShouldReturnTrueAndMoveCurrentToCurrentsLastChild() { var first = GetTagNode(); var last = GetTagNode(); var node = GetTagNodeWithChildren(first, last); var tree = new NodeTree(node); var result = tree.LastChild(); Assert.IsTrue(result); Assert.AreEqual(last, tree.Current); }
/// <summary> /// /// </summary> /// <param name="selector"></param> /// <param name="builder"></param> public HtmlBuilder(string selector, IHtmlTreeBuilder builder) { _builder = builder; _selector = selector; if (string.IsNullOrEmpty(selector)) { throw new ArgumentException("A selector is required to seed the node tree."); } _nodeTree = _builder.Build(_selector); }
public void Next_WithNodeThatHasNextSibling_ShouldReturnTrueAndMoveCurrentToCurrentsNextSibling() { var next = GetTagNode(); var node = GetTagNodeWithNextSibling(next); var tree = new NodeTree(node); var result = tree.Next(); Assert.IsTrue(result); Assert.AreEqual(next, tree.Current); }
public void Constuctor_WithNullNode_ShouldThrowArgumentNullException() { Node node = null; var tree = new NodeTree(node); }
public void Constuctor_WithNullNodeList_ShouldThrowArgumentNullException() { var tree = new NodeTree(null); }
public void ToString_WithNodeWithSiblings_ShouldReturnANodeWithSiblings() { var next = GetTagNode(); var node = GetTagNodeWithNextSibling(next); var tree = new NodeTree(node); Assert.AreEqual("<div></div><div></div>", tree.ToString()); }
public void ToString_WithNodeWithoutChildrenOrSiblings_ShouldReturnASimpleNode() { var node = GetTagNode(); var tree = new NodeTree(node); Assert.AreEqual("<div></div>", tree.ToString()); }
public void ToString_WithNodeWithChildren_ShouldReturnANodeWithChildren() { var first = GetTagNode(); var last = GetTagNode(); var node = GetTagNodeWithChildren(first, last); var tree = new NodeTree(node); Assert.AreEqual("<div><div></div><div></div></div>", tree.ToString()); }
public void Previous_WithNodeWithoutPreviousSibling_ShouldReturnFalseAndNotMoveCurrent() { var node = GetTagNode(); var tree = new NodeTree(node); var result = tree.Previous(); Assert.IsFalse(result); Assert.AreEqual(node, tree.Current); }
public void Previous_WithNodeThatHasPreviousSibling_ShouldReturnTrueAndMoveCurrentToCurrentsPreviousSibling() { var prev = GetTagNode(); var node = GetTagNodeWithPrevSibling(prev); var tree = new NodeTree(node); var result = tree.Previous(); Assert.IsTrue(result); Assert.AreEqual(prev, tree.Current); }
public void Parent_WithNodeWithParent_ShouldReturnTrueAndMoveCurrentToCurrentsParent() { var parent = GetTagNode(); var node = GetTagNodeWithParent(parent); var tree = new NodeTree(node); var result = tree.Parent(); Assert.IsTrue(result); Assert.AreEqual(parent, tree.Current); }