Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
 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);
     }
 }
Exemple #4
0
        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));
            }
        }