Exemple #1
0
        public static void TestWatchedFolders()
        {
            using (FileSystemState state = new FileSystemState())
            {
                IRuntimeFileInfo stateInfo = OS.Current.FileInfo(_mystateXmlPath);
                state.Load(stateInfo);

                Assert.That(state.WatchedFolders, Is.Not.Null, "There should be a Watched Folders instance.");
                Assert.That(state.WatchedFolders.Count(), Is.EqualTo(0), "There should be no Watched folders.");

                state.AddWatchedFolder(new WatchedFolder(_rootPath));
                Assert.That(state.WatchedFolders.Count(), Is.EqualTo(1), "There should be one Watched Folder.");

                state.AddWatchedFolder(new WatchedFolder(_rootPath));
                Assert.That(state.WatchedFolders.Count(), Is.EqualTo(1), "There should still only be one Watched Folder.");

                state.Save();
            }

            using (FileSystemState state = new FileSystemState())
            {
                IRuntimeFileInfo stateInfo = OS.Current.FileInfo(_mystateXmlPath);
                state.Load(stateInfo);

                Assert.That(state.WatchedFolders.Count(), Is.EqualTo(1), "There should be one Watched Folder.");

                Assert.That(state.WatchedFolders.First(), Is.EqualTo(new WatchedFolder(_rootPath)), "The Watched Folder should be equal to this.");

                state.RemoveWatchedFolder(new WatchedFolder(_mystateXmlPath));
                Assert.That(state.WatchedFolders.Count(), Is.EqualTo(1), "There should still be one Watched folders.");

                state.RemoveWatchedFolder(new WatchedFolder(_rootPath));
                Assert.That(state.WatchedFolders.Count(), Is.EqualTo(0), "There should still be no Watched folders now.");
            }
        }
        public virtual async Task RemoveWatchedFoldersAction(IEnumerable <string> folders)
        {
            if (!folders.Any())
            {
                return;
            }
            foreach (string watchedFolder in folders)
            {
                await _fileSystemState.RemoveWatchedFolder(New <IDataContainer>(watchedFolder));
            }

            await _fileSystemState.Save();
        }