public void SetUp() { _fakeMonitorFactory = Substitute.For <IMonitorFactory>(); _fakeFileMonitor = Substitute.For <IFileMonitor>(); _fakeMonitorFactory.CreateFileMonitor().Returns(_fakeFileMonitor); _fakeProjectionFolderCreator = Substitute.For <IProjectionFolderCreator>(); _fakeProjectionPipelineFactory = Substitute.For <IProjectionPipelineFactory>(); _uut = new SubfolderController(_fakeProjectionFolderCreator, _fakeMonitorFactory, _fakeProjectionPipelineFactory); }
public void MonitorNewFolderAsync_StartsMonitor_FileMonitorIsStarted() { //Arrange: var path = "Some path"; _fakeMonitorFactory.CreateFileMonitor().Returns(_fakeFileMonitor); //Act: Task task = _uut.StartNewFileMonitorInNewFolderAsync(path, "Some name"); Task.WaitAll(task); //Assert: _fakeFileMonitor.Received(1).StartMonitoringAsync(path); }
public Task StartNewFileMonitorInNewFolderAsync(string path, string folderName) { return(Task.Run(async() => { var folderStructure = await _projectionFolderCreator.CreateFolderStructure(); var newFileMonitor = await Task.Run(() => _monitorFactory.CreateFileMonitor()); var processor = StartPipeline(newFileMonitor, folderStructure); TaskWatcher.AddTask(Task.Run(() => PipelineStarted?.Invoke(this, new PipelineStartedArgs(folderStructure, processor)))); Logger.Info(CultureInfo.CurrentCulture, "Starts file monitoring at path: {0}", path); TaskWatcher.AddTask(newFileMonitor.StartMonitoringAsync(path)); })); }