コード例 #1
0
        public void UpdateRelevantFileOneSubscriptionDifferentCase()
        {
            List <string>        updates     = new List <string>();
            FakeDirectoryWatcher watcher     = new FakeDirectoryWatcher(new DirectoryInfo(@"X:\root"));
            DirectoryWatcherBase watcherBase = watcher;

            watcherBase.Subscribe("file1.txt", f => updates.Add(f.FullName));

            watcher.Update(@"X:\root\FILE1.txt");

            updates.Should().ContainSingle().Which.Should().Be(@"X:\root\file1.txt");
        }
コード例 #2
0
        public void UpdateIrrelevantFileOneSubscription()
        {
            List <string>        updates     = new List <string>();
            FakeDirectoryWatcher watcher     = new FakeDirectoryWatcher(new DirectoryInfo(@"X:\root"));
            DirectoryWatcherBase watcherBase = watcher;

            watcherBase.Subscribe("file1.txt", f => updates.Add(f.FullName));

            watcher.Update(@"X:\root\not-relevant.txt");

            updates.Should().BeEmpty();
        }
コード例 #3
0
        public void UpdateAfterDispose()
        {
            List <string>        updates = new List <string>();
            FakeDirectoryWatcher watcher = new FakeDirectoryWatcher(new DirectoryInfo(@"X:\root"));

            using (DirectoryWatcherBase watcherBase = watcher)
            {
                watcherBase.Subscribe("file1.txt", f => updates.Add(f.FullName));
            }

            watcher.Update(@"X:\root\file1.txt");

            updates.Should().BeEmpty();
        }
コード例 #4
0
        public void UpdateTwoFilesTwoSubscriptions()
        {
            List <string>        updates     = new List <string>();
            FakeDirectoryWatcher watcher     = new FakeDirectoryWatcher(new DirectoryInfo(@"X:\root"));
            DirectoryWatcherBase watcherBase = watcher;

            watcherBase.Subscribe("file1.txt", f => updates.Add(f.FullName));
            watcherBase.Subscribe("file2.txt", f => updates.Add(f.FullName));

            watcher.Update(@"X:\root\file2.txt");
            watcher.Update(@"X:\root\file1.txt");

            updates.Should().HaveCount(2).And.ContainInOrder(
                @"X:\root\file2.txt",
                @"X:\root\file1.txt");
        }
コード例 #5
0
        public void UpdateTwoAfterOneSubscriptionDispose()
        {
            List <string>        updates     = new List <string>();
            FakeDirectoryWatcher watcher     = new FakeDirectoryWatcher(new DirectoryInfo(@"X:\root"));
            DirectoryWatcherBase watcherBase = watcher;

            using (watcherBase.Subscribe("file1.txt", f => updates.Add(f.FullName)))
            {
            }

            watcherBase.Subscribe("file2.txt", f => updates.Add(f.FullName));
            watcher.Update(@"X:\root\file1.txt");
            watcher.Update(@"X:\root\file2.txt");

            updates.Should().ContainSingle().Which.Should().Be(@"X:\root\file2.txt");
        }