public void IsSatisfiedBy_ForSingleRule_WithFalse_ReturnsFalse()
        {
            var info       = new RenamerInfo();
            var fileSystem = new Mock <IFileSystem>().Object;
            var rule1      = new RenamerRule("rule 1", (a, b) => false);

            var result = rule1.IsSatisfiedBy(info, fileSystem);

            Assert.IsFalse(result, "False rule is meant to be false");
        }
        public void IsSatisfiedBy_ForMultipleRules_WithTrueAndTrue_ReturnsTrue()
        {
            var info       = new RenamerInfo();
            var fileSystem = new Mock <IFileSystem>().Object;
            var rule1      = new RenamerRule("rule 1", (a, b) => true);
            var rule2      = new RenamerRule("rule 2", (a, b) => true);

            rule1.Next = rule2;

            var result = rule1.IsSatisfiedBy(info, fileSystem);

            Assert.IsTrue(result, "True and true rules are meant to be true");
        }
        public void IsSatisfiedBy_ForMultipleRules_WithFalseAndFalse_ReturnsFalse()
        {
            var info       = new RenamerInfo();
            var fileSystem = new Mock <IFileSystem>().Object;
            var rule1      = new RenamerRule("rule 1", (a, b) => false);
            var rule2      = new RenamerRule("rule 2", (a, b) => false);

            rule1.Next = rule2;

            var result = rule1.IsSatisfiedBy(info, fileSystem);

            Assert.IsFalse(result, "False and false rules are meant to be false");
        }
        private void RecursiveBuildRenamerInfo(RenamerInfo parent, RenamerRule ruleSet, bool isRoot)
        {
            // go through each of the children
            // create renamer around each file/folder
            var entries = Directory.EnumerateFileSystemEntries(parent.Path).ToList();

            foreach (var path in entries)
            {
                var fixedPath = path.ToLower();
                var info      = new RenamerInfo
                {
                    Path     = path,
                    FileType = Directory.Exists(fixedPath) ? FileType.Directory
                        : fixedPath.EndsWith(".sln") ? FileType.Solution
                        : fixedPath.EndsWith(".dll") ? FileType.Library
                        : fixedPath.EndsWith(".exe") ? FileType.Executable
                        : fixedPath.EndsWith(".config") ? FileType.Config
                        : fixedPath.EndsWith(".cs") ? FileType.Code
                        : fixedPath.EndsWith(".csproj") ? FileType.Project
                        : fixedPath.EndsWith(".sqlproj") ? FileType.Project
                        : FileType.Other
                };
                info.IsIncluded = ruleSet.IsSatisfiedBy(info, this);

                parent.Children.Add(info);
            }

            // for speed, only continue if we are in a solution folder
            if (!isRoot || parent.ContainsSolutionFile)
            {
                foreach (var info in parent.Children)
                {
                    if (info.FileType == FileType.Directory)
                    {
                        RecursiveBuildRenamerInfo(info, ruleSet, false);
                    }
                }
            }
        }