Exemplo n.º 1
0
        public void CloseInCallback()
        {
            string directory = TestHelper.CreateTempDirectory();

            this.directoryList.Add(directory);

            string file1 = TestHelper.CreateTempFile(directory);
            string file2 = TestHelper.CreateTempFile(directory);
            string file3 = TestHelper.CreateTempFile(directory);
            string file4 = TestHelper.CreateTempFile(directory);
            string file5 = TestHelper.CreateTempFile(directory);

            FSEvent fsEvent = this.loop.CreateFSEvent();

            fsEvent.Start(directory, this.OnFSeventClose);

            /* Generate a couple of fs events. */
            TestHelper.TouchFile(file1, 10);
            TestHelper.TouchFile(file2, 20);
            TestHelper.TouchFile(file3, 30);
            TestHelper.TouchFile(file4, 40);
            TestHelper.TouchFile(file5, 50);

            this.loop.RunDefault();

            Assert.Equal(1, this.closeCount);
            Assert.Equal(3, this.callbackCount);
        }
Exemplo n.º 2
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.º 3
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);
        }