private void TestFilePickup(string originalFilename, string originalContent)
        {
            var resetEvent = new AutoResetEvent(false);
            var mockHandler = new Mock<IHandleFiles>();

            using (var listener = new PollingBasedFileProcessor(endpoint, mockHandler.Object, new DefaultFileFilter()))
            {
                listener.Start();
                resetEvent.WaitOne(1000);
            }

            mockHandler.Verify(x => x.Notify(It.IsAny<ProcessingFile>()));
            AssertDirectoryIsEmpty(dropLocation);

            var filePaths = Directory.GetFiles(acknowledgedLocation);
            Assert.AreEqual(filePaths.Length, 1);

            var actualFile = new FileInfo(filePaths[0]);
            AssertFileMatches(originalContent, originalFilename, actualFile);
        }
        public void FilterPreventsProcessing()
        {
            var fileData = this.CreateTestFileIn(this.tempLocation);

            var resetEvent = new AutoResetEvent(false);
            var mockHandler = MockRepository.GenerateMock<IHandleFiles>();

            using (var listener = new PollingBasedFileProcessor(this.endpoint, mockHandler, new FalseFileFilter()))
            {
                listener.Start();

                new FileInfo(Path.Combine(this.tempLocation, fileData.Filename)).MoveTo(Path.Combine(this.dropLocation, fileData.Filename));

                resetEvent.WaitOne(1000);
            }

            mockHandler.AssertWasNotCalled(x => x.Notify(Arg<ProcessingFile>.Is.NotNull));

            var filePaths = Directory.GetFiles(this.dropLocation);
            Assert.AreEqual(filePaths.Length, 1);

            var actualFile = new FileInfo(filePaths[0]);
            AssertFileMatches(fileData.Content, fileData.Filename, actualFile);
        }
        public void StartDropNewFileProcessFile()
        {
            var fileData = CreateTestFileIn(tempLocation);

            var resetEvent = new AutoResetEvent(false);
            var mockHandler = new Mock<IHandleFiles>();

            using (var listener = new PollingBasedFileProcessor(endpoint, mockHandler.Object, new DefaultFileFilter()))
            {
                listener.Start();

                new FileInfo(Path.Combine(tempLocation, fileData.Filename)).MoveTo(Path.Combine(dropLocation, fileData.Filename));

                resetEvent.WaitOne(1000);
            }

            mockHandler.Verify(x => x.Notify(It.IsAny<ProcessingFile>()));
            AssertDirectoryIsEmpty(dropLocation);

            var filePaths = Directory.GetFiles(acknowledgedLocation);
            Assert.AreEqual(filePaths.Length, 1);

            var actualFile = new FileInfo(filePaths[0]);
            AssertFileMatches(fileData.Content, fileData.Filename, actualFile);
        }
        private void TestFilePickup(string originalFilename, string originalContent)
        {
            var resetEvent = new AutoResetEvent(false);
            var mockHandler = MockRepository.GenerateMock<IHandleFiles>();

            using (var listener = new PollingBasedFileProcessor(this.endpoint, mockHandler, new DefaultFileFilter()))
            {
                listener.Start();
                resetEvent.WaitOne(1000);
            }

            mockHandler.AssertWasCalled(x => x.Notify(Arg<ProcessingFile>.Is.NotNull));
            this.AssertDirectoryIsEmpty(this.dropLocation);

            var filePaths = Directory.GetFiles(this.acknowledgedLocation);
            Assert.AreEqual(filePaths.Length, 1);

            var actualFile = new FileInfo(filePaths[0]);
            AssertFileMatches(originalContent, originalFilename, actualFile);
        }