Example #1
0
        public void StartReturnsFalseIfAlreadyStarted()
        {
            IFileSystemWatcher fakeFileSystemWatcher = A.Fake <IFileSystemWatcher>();

            A.CallTo(() => fakeFileSystemWatcher.EnableRaisingEvents).Returns(true);
            FolderWatcher.FolderWatcher folderWatcher = new FolderWatcher.FolderWatcher(fakeFileSystemWatcher);

            bool isStarted = folderWatcher.Start();

            Assert.False(isStarted);
        }
Example #2
0
        public void Starts()
        {
            IFileSystemWatcher fakeFileSystemWatcher = A.Fake <IFileSystemWatcher>();

            A.CallTo(() => fakeFileSystemWatcher.EnableRaisingEvents).Returns(false);
            FolderWatcher.FolderWatcher folderWatcher = new FolderWatcher.FolderWatcher(fakeFileSystemWatcher);

            bool isStarted = folderWatcher.Start();

            Assert.True(isStarted);
            A.CallToSet(() => fakeFileSystemWatcher.EnableRaisingEvents).To(true).MustHaveHappened();
        }
Example #3
0
        static void Main(string[] args)
        {
            InitializeLogger();
            if (!LoadConfiguration())
            {
                return;
            }

            try
            {
                FolderWatcher watcher = new FolderWatcher(new FileSystemWatcherWrapper(new FileSystemWatcher(path, filter)));
                watcher.Start();
                WaitForControlC();
                watcher.Stop();
            }
            catch (Exception e)
            {
                Log.Error(e, "Unexpected error");
            }
        }