public void ChangeEvents_AreQueued_WhenFilesAreChanged(int numOfFiles, int expectedValue) { _manager.Monitor(_folders); var folder = _folders[0]; TestFileSystemHelper.CreateDummyFiles(folder.Path, numOfFiles); Parallel.ForEach(Directory.GetFiles(folder.Path), file => File.WriteAllText(file, "Hello World")); AssertQueueItemCount(expectedValue, item => item.EventArgs.ChangeType == WatcherChangeTypes.Changed); }
public void EventWorker_CommitsChangeToSvn_WhenFileIsChanged() { _manager.Monitor(_testFolders); _manager.StartProcessing(); var folder = _testFolders[0]; var fileName = TestFileSystemHelper.MakeUniqueFileName("css"); DoAndWaitForWorker(() => TestFileSystemHelper.CreateFile(fileName, folder.Path)); var filePath = folder.Path + "\\" + fileName; using (var client = new SvnClient()) { SvnInfoEventArgs info; client.GetInfo(folder.RepositoryUrl, out info); var revisionBeforeChange = info.Revision; DoAndWaitForWorker(() => File.AppendAllText(filePath, "Hello World")); client.GetInfo(folder.RepositoryUrl, out info); var revisionAfterChange = info.Revision; Assert.That(revisionAfterChange, Is.EqualTo(revisionBeforeChange + 1)); } }
public void Start() { _logger.Info("SvnAutoCommitService is starting."); try { var configurationSection = (SvnAutoCommitterConfigurationSection)ConfigurationManager.GetSection("svnAutoCommitter"); var configuration = new SvnAutoCommitterConfiguration(configurationSection); var svnCredential = new NetworkCredential(configuration.RepositoryUsername, configuration.RepositoryPassword); var poller = new FileSystemEventPoller(new FileSystemEventWorker(new SharpSvnClient(svnCredential, _logger), _logger), _logger); _fileMonitorManager = new FileMonitorManager(poller, _logger); _fileMonitorManager.Monitor(configuration.Folders); _fileMonitorManager.StartProcessing(); } catch (Exception ex) { _logger.FatalFormat("SvnAutoCommitService failed to start: {0}.", ex); throw; } }