public FileListener(IDirectoryWorker directoryWorker, string defaultDestinationDirectoryPath, IFileSystemWorker fileSystemWorker) { this.directoryWorker = directoryWorker ?? throw new ArgumentNullException(); this.defaultDestinationDirectoryPath = defaultDestinationDirectoryPath ?? throw new ArgumentNullException(); this.fileSystemWorker = fileSystemWorker ?? throw new ArgumentNullException(); if (directoryWorker.Path == null) { throw new ArgumentNullException(); } if (!this.fileSystemWorker.IsDirectoryExists(directoryWorker.Path)) { throw new ArgumentOutOfRangeException(); } directoryWorker.Created += OnCreated; generateNewFileName = fileRelocationInfo => fileRelocationInfo.FileName; rules = new Dictionary <Regex, string>(); }
public void Init() { fileSystemWorkerMock = MockRepository.GenerateMock <IFileSystemWorker>(); directoryWorkerMock = MockRepository.GenerateMock <IDirectoryWorker>(); directoryWorkerMock.Stub(x => x.Path).Return(directoryToWatchPath); existingDirectoryPaths = new List <string> { $"{directoryToWatchPath}", $"{directoryToWatchPath}/{firstLevelFolderName}" }; filesToAddNames = new List <string> { "a.txt", "b1.txt", "c2.txt" }; foreach (var directoryPath in existingDirectoryPaths) { fileSystemWorkerMock.Stub(provider => provider.IsDirectoryExists(directoryPath)).Return(true); } }