Exemplo n.º 1
0
        public void NotifyExistingFiles_All()
        {
            var path = Path.Join(_tempExistingFilesFolder, "test.txt");

            new StorageHostFullPathFilesystem().WriteStream(
                new MemoryStream(new byte[] { }), path);

            var watcher = new FileSystemWatcher(_tempExistingFilesFolder);
            var wrapper = new BufferingFileSystemWatcher(watcher);

            wrapper.OrderByOldestFirst = true;

            var message = "";
            FileSystemEventHandler welcome = (_, s) =>
            {
                message = s.FullPath;
            };

            wrapper.All += welcome;

            wrapper.NotifyExistingFiles();

            Assert.IsTrue(message.StartsWith(_tempFolder));

            // and remove event
            wrapper.All -= welcome;

            wrapper.EnableRaisingEvents = false;
            wrapper.Dispose();
            watcher.Dispose();
        }
Exemplo n.º 2
0
        public void NotifyExistingFiles()
        {
            var path = Path.Join(_tempExistingFilesFolder, "test.txt");

            new StorageHostFullPathFilesystem().WriteStream(
                new MemoryStream(new byte[] { }), path);

            var watcher = new FileSystemWatcher(_tempExistingFilesFolder);
            var wrapper = new BufferingFileSystemWatcher(watcher);

            var message = "";

            wrapper.Existed += (_, s) =>
            {
                message = s.FullPath;
            };

            wrapper.NotifyExistingFiles();

            Assert.IsTrue(message.StartsWith(_tempExistingFilesFolder));

            wrapper.EnableRaisingEvents = false;
            wrapper.Dispose();
            watcher.Dispose();
        }
Exemplo n.º 3
0
        public void NotifyExistingFiles_All_Remove()
        {
            var watcher = new FileSystemWatcher(_tempFolder);
            var wrapper = new BufferingFileSystemWatcher(watcher);

            wrapper.OrderByOldestFirst = true;

            var message = "";

            // ReSharper disable once EventUnsubscriptionViaAnonymousDelegate
            wrapper.All -= (_, s) =>
            {
                message = s.FullPath;
            };

            wrapper.NotifyExistingFiles();

            Assert.IsFalse(message.StartsWith(_tempFolder));

            wrapper.EnableRaisingEvents = false;
            wrapper.Dispose();
            watcher.Dispose();
        }
Exemplo n.º 4
0
        public void NotifyExistingFiles_Created_Remove()
        {
            var watcher = new FileSystemWatcher(_tempFolder);
            var wrapper = new BufferingFileSystemWatcher(watcher);

            wrapper.OrderByOldestFirst = true;

            var message = "";
            FileSystemEventHandler welcome = (_, s) =>
            {
                message = s.FullPath;
            };

            wrapper.Created += welcome;
            wrapper.Created -= welcome;

            wrapper.NotifyExistingFiles();

            Assert.IsFalse(message.StartsWith(_tempFolder));

            wrapper.EnableRaisingEvents = false;
            wrapper.Dispose();
            watcher.Dispose();
        }