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 static void TestDecryptedFilesInWatchedFolders() { DateTime utcNow = OS.Current.UtcNow; FakeRuntimeFileInfo.AddFolder(_documentsFolder); FakeRuntimeFileInfo.AddFile(_encryptedFile1, utcNow, utcNow, utcNow, Stream.Null); FakeRuntimeFileInfo.AddFile(_decryptedFile1, utcNow, utcNow, utcNow, Stream.Null); FakeRuntimeFileInfo.AddFolder(_underDocumentsFolder); FakeRuntimeFileInfo.AddFile(_encryptedFile11, utcNow, utcNow, utcNow, Stream.Null); FakeRuntimeFileInfo.AddFile(_decryptedFile11, utcNow, utcNow, utcNow, Stream.Null); _fileSystemState.AddWatchedFolder(new WatchedFolder(_underDocumentsFolder)); IEnumerable <IRuntimeFileInfo> decryptedFiles = _fileSystemState.DecryptedFilesInWatchedFolders(); Assert.That(decryptedFiles.Count(), Is.EqualTo(1), "There should be exactly one decrypted file here."); Assert.That(decryptedFiles.First().FullName, Is.EqualTo(_decryptedFile11), "This is the file that is decrypted here."); }