public void BeginEndInit_Repeated() { using (var watcher = new TestFileSystemWatcher(TestDirectory, "*")) { watcher.BeginInit(); watcher.EndInit(); watcher.BeginInit(); watcher.EndInit(); Assert.False(watcher.EnableRaisingEvents); } }
public void BeginEndInit_Repeated() { using (var testDirectory = new TempDirectory(GetTestFilePath())) using (var watcher = new TestFileSystemWatcher(testDirectory.Path, "*")) { watcher.BeginInit(); watcher.EndInit(); watcher.BeginInit(); watcher.EndInit(); Assert.False(watcher.EnableRaisingEvents); } }
public void EndInit_ResumesPausedEnableRaisingEvents() { using (var testDirectory = new TempDirectory(GetTestFilePath())) using (var watcher = new TestFileSystemWatcher(testDirectory.Path, "*")) { watcher.BeginInit(); watcher.EnableRaisingEvents = true; watcher.EndInit(); ExpectEvent(watcher, WatcherChangeTypes.Created | WatcherChangeTypes.Deleted, () => new TempFile(Path.Combine(testDirectory.Path, GetTestFileName())).Dispose(), null); } }
public void EndInit_DoesNotEnableEventRaisedEvents() { using (var watcher = new TestFileSystemWatcher(TestDirectory, "*")) { watcher.Created += (obj, e) => { Assert.False(true, "Created event should not occur"); }; watcher.Deleted += (obj, e) => { Assert.False(true, "Deleted event should not occur"); }; watcher.BeginInit(); watcher.EndInit(); new TempFile(Path.Combine(TestDirectory, GetTestFileName())).Dispose(); Thread.Sleep(WaitForExpectedEventTimeout); } }
public void EndRaisingEventsDuringPause() { using (var watcher = new TestFileSystemWatcher(TestDirectory, "*")) { watcher.EnableRaisingEvents = true; watcher.BeginInit(); watcher.EnableRaisingEvents = false; watcher.EndInit(); new TempFile(Path.Combine(TestDirectory, GetTestFileName())).Dispose(); Thread.Sleep(WaitForExpectedEventTimeout); } }
public void EndInit_ResumesPausedEnableRaisingEvents(bool setBeforeBeginInit) { FileSystemWatcherTest.Execute(() => { using (var watcher = new TestFileSystemWatcher(TestDirectory, "*")) { if (setBeforeBeginInit) { watcher.EnableRaisingEvents = true; } watcher.BeginInit(); if (!setBeforeBeginInit) { watcher.EnableRaisingEvents = true; } watcher.EndInit(); ExpectEvent(watcher, WatcherChangeTypes.Created | WatcherChangeTypes.Deleted, () => new TempFile(Path.Combine(TestDirectory, GetTestFileName())).Dispose(), null); } }, maxAttempts: DefaultAttemptsForExpectedEvent, backoffFunc: (iteration) => RetryDelayMilliseconds, retryWhen: e => e is XunitException); }
public void EndInit_DoesNotEnableEventRaisedEvents() { using (var testDirectory = new TempDirectory(GetTestFilePath())) using (var watcher = new TestFileSystemWatcher(testDirectory.Path, "*")) { watcher.Created += (obj, e) => { Assert.False(true, "Created event should not occur"); }; watcher.Deleted += (obj, e) => { Assert.False(true, "Deleted event should not occur"); }; watcher.BeginInit(); watcher.EndInit(); new TempFile(Path.Combine(testDirectory.Path, GetTestFileName())).Dispose(); Thread.Sleep(WaitForExpectedEventTimeout); } }
public void EndRaisingEventsDuringPause() { using (var testDirectory = new TempDirectory(GetTestFilePath())) using (var watcher = new TestFileSystemWatcher(testDirectory.Path, "*")) { watcher.EnableRaisingEvents = true; watcher.BeginInit(); watcher.EnableRaisingEvents = false; watcher.EndInit(); new TempFile(Path.Combine(testDirectory.Path, GetTestFileName())).Dispose(); Thread.Sleep(WaitForExpectedEventTimeout); } }
public void EndInit_ResumesPausedEnableRaisingEvents(bool setBeforeBeginInit) { using (var testDirectory = new TempDirectory(GetTestFilePath())) using (var watcher = new TestFileSystemWatcher(testDirectory.Path, "*")) { if (setBeforeBeginInit) watcher.EnableRaisingEvents = true; watcher.BeginInit(); if (!setBeforeBeginInit) watcher.EnableRaisingEvents = true; watcher.EndInit(); ExpectEvent(watcher, WatcherChangeTypes.Created | WatcherChangeTypes.Deleted, () => new TempFile(Path.Combine(testDirectory.Path, GetTestFileName())).Dispose(), null); } }