public static void TestFindEncryptedAndDecryptedPath() { using (FileSystemState state = new FileSystemState()) { state.Load(OS.Current.FileInfo(_mystateXmlPath)); ActiveFile activeFile = new ActiveFile(OS.Current.FileInfo(_encryptedAxxPath), OS.Current.FileInfo(_decryptedTxtPath), new AesKey(), ActiveFileStatus.AssumedOpenAndDecrypted | ActiveFileStatus.Error | ActiveFileStatus.IgnoreChange | ActiveFileStatus.NotShareable, null); state.Add(activeFile); ActiveFile byDecryptedPath = state.FindDecryptedPath(_decryptedTxtPath); Assert.That(byDecryptedPath, Is.EqualTo(activeFile), "The search should return the same instance."); ActiveFile byEncryptedPath = state.FindEncryptedPath(_encryptedAxxPath); Assert.That(byEncryptedPath, Is.EqualTo(byDecryptedPath), "The search should return the same instance."); ActiveFile notFoundEncrypted = state.FindEncryptedPath(Path.Combine(_rootPath, "notfoundfile.txt")); Assert.That(notFoundEncrypted, Is.Null, "A search that does not succeed should return null."); ActiveFile notFoundDecrypted = state.FindDecryptedPath(Path.Combine(_rootPath, "notfoundfile.txt")); Assert.That(notFoundDecrypted, Is.Null, "A search that does not succeed should return null."); } }
public static void TestArgumentNull() { using (FileSystemState state = new FileSystemState()) { ActiveFile nullActiveFile = null; string nullPath = null; Func <ActiveFile, ActiveFile> nullAction = null; IRuntimeFileInfo nullFileInfo = null; Assert.Throws <ArgumentNullException>(() => { state.Remove(nullActiveFile); }); Assert.Throws <ArgumentNullException>(() => { state.Add(nullActiveFile); }); Assert.Throws <ArgumentNullException>(() => { state.FindEncryptedPath(nullPath); }); Assert.Throws <ArgumentNullException>(() => { state.FindDecryptedPath(nullPath); }); Assert.Throws <ArgumentNullException>(() => { state.ForEach(ChangedEventMode.RaiseAlways, nullAction); }); Assert.Throws <ArgumentNullException>(() => { state.Load(nullFileInfo); }); } }