public void GetAncestorsAndSelf_CorrectNodesReturned() { // Get a valid tree. var tree = Node.Create(0).AddChildren( Node.Create(1).AddChildren( Node.Create(2))); // Get a valid ITreeWalker. NodeWalker <int> walker = new NodeWalker <int>(); Node <int> node = tree[0][0]; // Assert. Assert.Equal( Enumerable.Concat(new Node <int>[] { node }, walker.GetAncestors(node)).ToArray(), walker.GetAncestorsAndSelf(node).ToArray()); }
public void GetBranches_MultipleBranches() { // Get a valid tree. var tree = TestTreeFactory.GetSimpleTree(); // Get a valid ITreeWalker. NodeWalker <int> walker = new NodeWalker <int>(); // Assert. Assert.Equal( walker .GetLeaves(tree) .Select(x => EnumerableEx .Return(x) .Concat(walker.GetAncestors(x)) .Reverse() .ToArray()) .ToArray(), walker.GetBranches(tree).Select(x => x.ToArray()).ToArray()); }