public void LevelOrderTest(int treeIndex, string expected) { BinaryNode[] tree = _trees[treeIndex]; string result = string.Join(",", Traversals.LevelOrder(tree[0], tree.GetLeft, tree.GetRight).Select(node => node.ToString())); Assert.AreEqual(expected, result); }
public void LevelOrderTest(int treeIndex, string expected) { var tree = _trees[treeIndex]; string result = string.Join(",", Traversals.LevelOrder(tree[0], tree.GetChildren).Select(node => node.ToString())); Assert.AreEqual(expected, result); }
public TransactionContextState GetExpectedCommitState() { if (Traversals.LevelOrder(this.GetController(), node => node.Children.Where(child => !child.IsController)).All(node => node.VoteAction == VoteAction.VoteCommit)) { return(TransactionContextState.ToBeCommitted); } else { return(TransactionContextState.ToBeRollbacked); } }
public static IEnumerable <string> EnumerateDirectories(string path, string searchPattern = "*.*", SearchOption searchOption = SearchOption.TopDirectoryOnly) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException(nameof(path)); } if (string.IsNullOrEmpty(searchPattern)) { throw new ArgumentNullException(nameof(searchPattern)); } Func <string, IEnumerable <string> > getChildren = child => SafeGetFileSystemEnumerable(() => Directory.EnumerateDirectories(child, searchPattern, SearchOption.TopDirectoryOnly)); if (searchOption == SearchOption.TopDirectoryOnly) { return(getChildren(path)); } else { return(Traversals.LevelOrder(path, getChildren)); } }