Ejemplo n.º 1
0
        private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker bw = sender as BackgroundWorker;

            if (bw.CancellationPending)
            {
                e.Cancel = true;
            }
            else
            {
                // Run the file notifier to process parsed files
                NewFileNotifier nfn = new NewFileNotifier();
                while (true)
                {
                    Thread.Sleep(5000);
                    _CurrentCaptureFiles = new BindingList<CurrentCaptureFile>();
                    //_CurrentCaptureFiles = nfn.CheckForNewFiles(_ParseFolderPath, _ProcessedFilesPath);
                    _CurrentCaptureFiles = nfn.CheckForNewFiles(_ParsedFilesPath, _ProcessedFilesPath);
                }
            }
        }
Ejemplo n.º 2
0
        public void NewFileNotifierReturnsNewFile()
        {
            // Arrange
            string inputFolderPath = @"C:\Temp\InputFileTest";
            string outputFolderPath = @"C:\Temp\OutputFileTest";
            string inputFileName = "TestFile.txt";

            if (!Directory.Exists(inputFolderPath))
            {
                Directory.CreateDirectory(inputFolderPath);
            }

            NewFileNotifier nfn = new NewFileNotifier(inputFolderPath);
            if (File.Exists(inputFolderPath + '\\' + inputFileName))
            {
                File.Delete(inputFolderPath + '\\' + inputFileName);
            }

            StreamWriter sw = File.CreateText(inputFolderPath + '\\' + inputFileName);
            sw.Close();

            if(!Directory.Exists(outputFolderPath))
            {
                Directory.CreateDirectory(outputFolderPath);
            }

            // Act
            BindingList<CurrentCaptureFile> actual = new BindingList<CurrentCaptureFile>();
            actual = nfn.CheckForNewFiles(inputFolderPath, outputFolderPath);

            bool fileIsPresent = File.Exists(outputFolderPath + '\\' + inputFileName);
            Assert.IsTrue(fileIsPresent);
            // Assert
            //Assert.IsTrue(actual.Count > 0);
        }