public void FileList_of_Invalid_Path_Does_Not_AddsPath() { IValidateFile validator = Substitute.For <IValidateFile>(); FileList fileList = new FileList(validator); string filePath = @"C:\Foo\Bar"; validator.IsValidFile(filePath).Returns(false); fileList.ProcessFile(filePath); Assert.IsTrue(fileList.Paths.Count == 0); }
public void FileList_of_Valid_Path_Adds_Path() { IValidateFile validator = Substitute.For <IValidateFile>(); FileList fileList = new FileList(validator); string filePath = @"C:\Foo\Bar"; validator.IsValidFile(filePath).Returns(true); fileList.ProcessFile(filePath); Assert.IsTrue(fileList.Paths.Count == 1); Assert.AreEqual(fileList.Paths[0], filePath); }
public void ProcessFile_of_InValid_Path_Does_Not_Add_Path() { string targetFile = @"C:\Foo\Bar\Foo.Bar"; IValidateFile validator = Substitute.For <IValidateFile>(); validator.IsValidFile(targetFile).Returns(true); IProcessFile processor = new FileList(validator); FileList processorResult = (FileList)RecursiveFileProcessor.ProcessFile(targetFile, processor); Assert.IsTrue(processorResult.Paths.Count == 0); }
public void ProcessDirectory_of_InValid_Path_without_Subdirectories_Does_Not_Add_Path() { string targetDirectory = @"C:\Foo\Bar"; IValidateFile validator = Substitute.For <IValidateFile>(); validator.IsValidFile(targetDirectory).Returns(true); IProcessFile processor = new FileList(validator); FileList processorResult = (FileList)RecursiveFileProcessor.ProcessDirectory(targetDirectory, processor, includeSubDirectories: false); Assert.IsTrue(processorResult.Paths.Count == 0); }
public void ProcessFile_of_Valid_Path_Adds_Path() { string validFilePath = Process.GetCurrentProcess().MainModule.FileName; IValidateFile validator = Substitute.For <IValidateFile>(); validator.IsValidFile(validFilePath).Returns(true); IProcessFile processor = new FileList(validator); FileList processorResult = (FileList)RecursiveFileProcessor.ProcessFile(validFilePath, processor); Assert.IsTrue(processorResult.Paths.Count == 1); Assert.AreEqual(processorResult.Paths[0], validFilePath); }
public void FileList_of_Invalid_Path_Does_Not_Event_Messenger() { IValidateFile validator = Substitute.For <IValidateFile>(); FileList fileList = new FileList(validator); var wasCalled = false; FileProcessor.Messenger += (e) => wasCalled = true; string filePath = @"C:\Foo\Bar"; validator.IsValidFile(filePath).Returns(false); fileList.ProcessFile(filePath); Assert.IsFalse(wasCalled); }
public void ProcessDirectory_of_Valid_Path_without_Subdirectories_Adds_Path() { string validFilePath = Process.GetCurrentProcess().MainModule.FileName; string targetDirectory = Path.GetDirectoryName(validFilePath); IValidateFile validator = Substitute.For <IValidateFile>(); validator.IsValidFile(validFilePath).Returns(true); IProcessFile processor = new FileList(validator); FileList processorResult = (FileList)RecursiveFileProcessor.ProcessDirectory(targetDirectory, processor, includeSubDirectories: false); Assert.IsTrue(processorResult.Paths.Count == 1); Assert.AreEqual(processorResult.Paths[0], validFilePath); }
public void ProcessFile_of_InValid_Path_Events_Messenger() { string targetFile = @"C:\Foo\Bar\Foo.Bar"; IValidateFile validator = Substitute.For <IValidateFile>(); validator.IsValidFile(targetFile).Returns(true); IProcessFile processor = new FileList(validator); var wasCalled = false; RecursiveFileProcessor.Messenger += (e) => wasCalled = true; RecursiveFileProcessor.ProcessFile(targetFile, processor); Assert.IsTrue(wasCalled); }
public void ProcessDirectory_of_InValid_Path_without_Subdirectories_Events_Messenger() { string targetDirectory = @"C:\Foo\Bar"; IValidateFile validator = Substitute.For <IValidateFile>(); validator.IsValidFile(targetDirectory).Returns(true); IProcessFile processor = new FileList(validator); var wasCalled = false; RecursiveFileProcessor.Messenger += (e) => wasCalled = true; RecursiveFileProcessor.ProcessDirectory(targetDirectory, processor, includeSubDirectories: false); Assert.IsTrue(wasCalled); }
public void ProcessPaths_of_InValid_Path_without_Subdirectories_Does_Not_Add_Path() { string validPath = @"C:\Foo\Bar\Moo\Sar.txt"; 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 }; IValidateFile validator = Substitute.For <IValidateFile>(); validator.IsValidFile(validPath).Returns(true); IProcessFile processor = new FileList(validator); FileList processorResult = (FileList)RecursiveFileProcessor.ProcessPaths(paths, processor, includeSubDirectories: false); Assert.IsTrue(processorResult.Paths.Count == 0); }
public void ProcessPaths_of_Valid_File_Path_Adds_All_Valid_Path() { string validFilePath = Process.GetCurrentProcess().MainModule.FileName; string targetDirectory1 = Path.GetFullPath(Path.Combine(validFilePath, @"..\")); string targetDirectory2 = Path.GetFullPath(Path.Combine(validFilePath, @"..\..\")); string targetDirectory3 = Path.GetFullPath(Path.Combine(validFilePath, @"..\..\..\")); string[] paths = { validFilePath, targetDirectory1, targetDirectory2, targetDirectory3 }; IValidateFile validator = Substitute.For <IValidateFile>(); validator.IsValidFile(validFilePath).Returns(true); IProcessFile processor = new FileList(validator); FileList processorResult = (FileList)RecursiveFileProcessor.ProcessPaths(paths, processor, includeSubDirectories: true); Assert.IsTrue(processorResult.Paths.Count == 1); Assert.AreEqual(processorResult.Paths[0], validFilePath); }
public void ProcessPaths_of_InValid_Path_without_Subdirectories_Events_Messenger() { string validPath = @"C:\Foo\Bar\Moo\Sar.txt"; 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 }; IValidateFile validator = Substitute.For <IValidateFile>(); validator.IsValidFile(validPath).Returns(true); IProcessFile processor = new FileList(validator); var wasCalled = false; RecursiveFileProcessor.Messenger += (e) => wasCalled = true; RecursiveFileProcessor.ProcessPaths(paths, processor, includeSubDirectories: false); Assert.IsTrue(wasCalled); }