public void Setup()
        {
            processCaller = Substitute.For<IProcessCaller>();
            validateFile = Substitute.For<IValidateFile>();

            createCloneGit = new CreateCloneGit(processCaller, validateFile);
        }
示例#2
0
        public void Initialization()
        {
            IValidateFile validator = Substitute.For <IValidateFile>();
            FileList      fileList  = new FileList(validator);

            Assert.AreEqual(validator, fileList.FileValidator);
        }
 public EventManagement(IEventService eventService, IFileService fileService, IObtainFileService obtainFileService, IValidateFile validateFile, IDisplayInfoService displayInfoService)
 {
     _eventService       = eventService ?? throw new ArgumentNullException(nameof(eventService));
     _fileService        = fileService ?? throw new ArgumentNullException(nameof(fileService));
     _obtainFileService  = obtainFileService ?? throw new ArgumentNullException(nameof(obtainFileService));
     _validateFile       = validateFile ?? throw new ArgumentNullException(nameof(validateFile));
     _displayInfoService = displayInfoService ?? throw new ArgumentNullException(nameof(displayInfoService));
 }
示例#4
0
        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);
        }
示例#5
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);
        }
示例#6
0
        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);
        }
示例#7
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);
        }
示例#8
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);
        }
示例#9
0
        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);
        }
示例#10
0
        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);
        }
示例#11
0
        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);
        }
示例#12
0
        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);
        }
示例#13
0
        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);
        }
示例#14
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);
        }
示例#15
0
        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);
        }
示例#16
0
 public PyramidLogic(IProcessPyramidFile fileReader, IValidateFile validateFile)
 {
     _fileReader   = fileReader;
     _validateFile = validateFile;
 }
示例#17
0
 public SortName(IFileServices iFileServices, IValidateFile iValidateFile, ILoggerFactory iLoggerFactory)
 {
     this._IfileServices = iFileServices;
     this._IValidateFile = iValidateFile;
     _ILoggerFactory     = iLoggerFactory.CreateLogger <SortName>();
 }
 public CreateCloneGit(IProcessCaller processCaller, IValidateFile validateFile) {
     this.processCaller = processCaller;
     this.validateFile = validateFile;
 }