Beispiel #1
0
        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); });
            }
        }
Beispiel #2
0
        public static void TestChangedEvent()
        {
            using (FileSystemState state = new FileSystemState())
            {
                state.Load(OS.Current.FileInfo(_mystateXmlPath));
                bool wasHere;
                state.Changed += new EventHandler <ActiveFileChangedEventArgs>((object sender, ActiveFileChangedEventArgs e) => { wasHere = true; });
                ActiveFile activeFile = new ActiveFile(OS.Current.FileInfo(_encryptedAxxPath), OS.Current.FileInfo(_decryptedTxtPath), new AesKey(), ActiveFileStatus.AssumedOpenAndDecrypted, null);

                wasHere = false;
                state.Add(activeFile);
                Assert.That(state.ActiveFiles.Count(), Is.EqualTo(1), "After the Add() the state should have one active file.");
                Assert.That(wasHere, Is.True, "After the Add(), the changed event should have been raised.");

                wasHere = false;
                state.Remove(activeFile);
                Assert.That(wasHere, Is.True, "After the Remove(), the changed event should have been raised.");
                Assert.That(state.ActiveFiles.Count(), Is.EqualTo(0), "After the Remove() the state should have no active files.");
            }
        }