public void ProcessPaths_of_InValid_Path_without_Subdirectories_Does_Not_Add_Path()
        {
            string validPath        = @"C:\Foo\Bar\Moo\Sar";
            string targetDirectory1 = Path.GetFullPath(Path.Combine(validPath, @"..\"));
            string targetDirectory2 = Path.GetFullPath(Path.Combine(validPath, @"..\..\"));
            string targetDirectory3 = Path.GetFullPath(Path.Combine(validPath, @"..\..\..\"));

            string[] paths = { targetDirectory1, targetDirectory2, targetDirectory3 };

            IValidateFolder validator = Substitute.For <IValidateFolder>();

            validator.IsValidFolder(validPath).Returns(true);

            IProcessFolder processor = new FolderList(validator);

            FolderList processorResult = (FolderList)RecursiveFolderProcessor.ProcessPaths(paths,
                                                                                           processor,
                                                                                           includeSubDirectories: false);

            Assert.IsTrue(processorResult.Paths.Count == 0);
        }
        public void ProcessPaths_of_Valid_Path_without_Subdirectories_Adds_Path()
        {
            string validPath        = _assemblyFolder;
            string targetDirectory1 = Path.GetFullPath(Path.Combine(validPath, @"..\"));
            string targetDirectory2 = Path.GetFullPath(Path.Combine(validPath, @"..\..\"));
            string targetDirectory3 = Path.GetFullPath(Path.Combine(validPath, @"..\..\..\"));

            string[] paths = { targetDirectory1, targetDirectory2, targetDirectory3 };

            IValidateFolder validator = Substitute.For <IValidateFolder>();

            validator.IsValidFolder(targetDirectory1).Returns(true);

            IProcessFolder processor = new FolderList(validator);

            FolderList processorResult = (FolderList)RecursiveFolderProcessor.ProcessPaths(paths,
                                                                                           processor,
                                                                                           includeSubDirectories: false);

            Assert.IsTrue(processorResult.Paths.Count == 1);
            Assert.AreEqual(processorResult.Paths[0], targetDirectory1);
        }
        public void ProcessPaths_of_InValid_Path_without_Subdirectories_Events_Messenger()
        {
            string validPath        = @"C:\Foo\Bar\Moo\Sar";
            string targetDirectory1 = Path.GetFullPath(Path.Combine(validPath, @"..\"));
            string targetDirectory2 = Path.GetFullPath(Path.Combine(validPath, @"..\..\"));
            string targetDirectory3 = Path.GetFullPath(Path.Combine(validPath, @"..\..\..\"));

            string[] paths = { targetDirectory1, targetDirectory2, targetDirectory3 };

            IValidateFolder validator = Substitute.For <IValidateFolder>();

            validator.IsValidFolder(validPath).Returns(true);

            IProcessFolder processor = new FolderList(validator);

            var wasCalled = false;

            RecursiveFolderProcessor.Messenger += (e) => wasCalled = true;

            RecursiveFolderProcessor.ProcessPaths(paths,
                                                  processor,
                                                  includeSubDirectories: false);
            Assert.IsTrue(wasCalled);
        }