Esempio n. 1
0
        public void WatcherComponent_RenamedEvent()
        {
            String path = String.Empty;

            EventHandler <RenamedEventArgs> myEvent = (_, fseArgs) => { path = fseArgs.FullPath; };

            // Assign event
            mock.Renamed += myEvent;

            var args = new RenamedEventArgs(WatcherChangeTypes.Renamed, "SomeRootDir", "SomePath", "OldPathName");

            Assert.That(path, Is.EqualTo(String.Empty));

            // Call event on mock object
            mock.OnRenamed(args);
            Assert.That(path, Is.EqualTo(@"SomeRootDir\SomePath"));

            // Reset path
            path = String.Empty;
            Assert.That(path, Is.EqualTo(String.Empty));

            // Remove the event
            mock.Renamed -= myEvent;

            mock.OnChanged(args);
            Assert.That(path, Is.EqualTo(String.Empty));
        }
Esempio n. 2
0
        public async Task WatcherObservable_GetObservable_RenameEvent()
        {
            String monitorPath = "";
            // Set monitorPath to the path that is updated when it is changed
            var asyncObs = watcherObservable.GetObservable()
                           .Select(eventPath => monitorPath = eventPath)
                           .FirstAsync().ToTask();

            //Invoke Rename Event on Mock
            String newRoot     = "SomeRoot";
            String newPath     = "SomePath";
            String oldName     = "NotImportant";
            String newFullPath = String.Format("{0}\\{1}", newRoot, newPath);
            var    args        = new RenamedEventArgs(WatcherChangeTypes.Renamed, newRoot, newPath, oldName);

            mock.OnRenamed(args);

            var obs = await asyncObs;

            Assert.That(monitorPath, Is.EqualTo(newFullPath));
        }