public void MoveBad() { var sortedTree = new SortedTree <int, String>(); sortedTree.Visit(1).Set("1"); sortedTree.Visit(1, 2).Set("12"); sortedTree.Visit(1, 2, 3).Set("123"); Assert.ThrowsException <CircularStructureException>(() => sortedTree.Visit(1).MoveTo(sortedTree.Visit(1, 2, 3))); }
public void MoveRoot() { var sortedTree = new SortedTree <int, String>(); sortedTree.Visit(1).Set("Node"); Assert.ThrowsException <CircularStructureException>(() => sortedTree.MoveTo(sortedTree.Visit(1))); }
public void Order() { var sortedTree = new SortedTree <int, String>(); sortedTree.Visit(1, 3).Set("ing"); sortedTree.Visit(1, 1).Set("Pa"); sortedTree.Visit(1, 2).Set("ss"); var singleNode = sortedTree.Next(); StringBuilder nodeValues = new StringBuilder(); while (singleNode != null) { nodeValues.Append(singleNode.Value); singleNode = singleNode.Next(); } Assert.AreEqual("Passing", nodeValues.ToString()); }
public void OrderWithMoveWithReplace() { var sortedTree = new SortedTree <int, String>(); sortedTree.Visit(1, 1).Set("Pa"); sortedTree.Visit(1, 3).Set("ing"); sortedTree.Visit(1, 2).Set("REPLACENODE"); sortedTree.Visit(1, 2, 3).Set("REPLACECHILD"); sortedTree.Visit(2).Set("ss"); sortedTree.Visit(2).MoveTo(sortedTree.Visit(1), true); var singleNode = sortedTree.Next(); StringBuilder nodeValues = new StringBuilder(); while (singleNode != null) { nodeValues.Append(singleNode.Value); singleNode = singleNode.Next(); } Assert.AreEqual("Passing", nodeValues.ToString()); }