Exemplo n.º 1
0
        void OnFSeventClose(FSEvent fsEvent, FileSystemEvent fileSystemEvent)
        {
            this.callbackCount++;

            if (this.callbackCount == 3)
            {
                fsEvent.CloseHandle(this.OnClose);
            }
        }
Exemplo n.º 2
0
        void OnTimer(Timer handle)
        {
            FSEvent fsEvent = this.loop
                              .CreateFSEvent()
                              .Start(".", this.OnFSEvent);

            fsEvent.CloseHandle(this.OnClose);
            handle.CloseHandle(this.OnClose);
        }
Exemplo n.º 3
0
        void OnFSEventDirectory(FSEvent fsEvent, FileSystemEvent fileSystemEvent)
        {
            if (fileSystemEvent.EventType == FSEventType.Rename)
            {
                this.callbackCount++;
            }

            fsEvent.Stop();
            fsEvent.CloseHandle(this.OnClose);
        }
Exemplo n.º 4
0
        void OnFSEventFile(FSEvent fsEvent, FileSystemEvent fileSystemEvent)
        {
            if (fileSystemEvent.EventType == FSEventType.Change)
            {
                this.callbackCount++;
            }

            fsEvent.Stop();
            fsEvent.CloseHandle(this.OnClose);
        }
Exemplo n.º 5
0
        public void WatchFileRootDir()
        {
            string  root    = TestHelper.RootSystemDirectory();
            FSEvent fsEvent = this.loop
                              .CreateFSEvent()
                              .Start(root, this.OnFSEvent);

            fsEvent.CloseHandle(this.OnClose);

            this.loop.RunDefault();
            Assert.Equal(0, this.callbackCount);
            Assert.Equal(1, this.closeCount);
        }
Exemplo n.º 6
0
        void OnFSEventDirMultipleFile(FSEvent fsEvent, FileSystemEvent fileSystemEvent)
        {
            this.callbackCount++;

            if (this.fileCreated + this.fileRemoved == FileEventCount)
            {
                // Once we've processed all create events, delete all files
                this.timer.Start(this.OnTimerDeleteFile, 1, 0);
            }
            else if (this.callbackCount == 2 * FileEventCount)
            {
                // Once we've processed all create and delete events, stop watching
                this.timer.CloseHandle(this.OnClose);
                fsEvent.CloseHandle(this.OnClose);
            }
        }
Exemplo n.º 7
0
        public void NoCallbackOnClose()
        {
            string directory = TestHelper.CreateTempDirectory();

            this.directoryList.Add(directory);

            string file = TestHelper.CreateTempFile(directory);

            FSEvent fsEvent = this.loop
                              .CreateFSEvent()
                              .Start(file, this.OnFSEventFile);

            fsEvent.CloseHandle(this.OnClose);

            this.loop.RunDefault();
            Assert.Equal(0, this.callbackCount);
            Assert.Equal(1, this.closeCount);
        }
Exemplo n.º 8
0
        public void StartAndClose()
        {
            string directory = TestHelper.CreateTempDirectory();

            this.directoryList.Add(directory);

            FSEvent fsEvent1 = this.loop.CreateFSEvent();

            fsEvent1.Start(directory, this.OnFSEventDirectory);

            FSEvent fsEvent2 = this.loop.CreateFSEvent();

            fsEvent2.Start(directory, this.OnFSEventDirectory);

            fsEvent1.CloseHandle(this.OnClose);
            fsEvent2.CloseHandle(this.OnClose);

            this.loop.RunDefault();

            Assert.Equal(2, this.closeCount);
            Assert.Equal(0, this.callbackCount);
        }
Exemplo n.º 9
0
        public void GetPath()
        {
            FSEvent fsEvent = this.loop.CreateFSEvent();
            var     error   = Assert.Throws <OperationException>(() => fsEvent.GetPath());

            Assert.Equal(ErrorCode.EINVAL, error.ErrorCode);

            string directory = TestHelper.CreateTempDirectory();

            this.directoryList.Add(directory);

            fsEvent.Start(directory, this.OnFSEvent);
            string path = fsEvent.GetPath();

            Assert.Equal(directory, path);

            fsEvent.Stop();
            fsEvent.CloseHandle(this.OnClose);

            this.loop.RunDefault();
            Assert.Equal(0, this.callbackCount);
            Assert.Equal(1, this.closeCount);
        }