Esempio n. 1
0
        public void FileFilterThrowsArgumentNull()
        {
            FileFilter filter = new FileFilter();

            Assert.Throws <ArgumentNullException>(() => filter.AddUnencryptable(null));
            Assert.Throws <ArgumentNullException>(() => filter.AddUnencryptableExtension(null));
            Assert.Throws <ArgumentNullException>(() => filter.IsEncryptable(null));
        }
Esempio n. 2
0
        public void FileFilterTestUnencryptablePatterns()
        {
            FileFilter filter = new FileFilter();

            string s = $"\\{Path.DirectorySeparatorChar}";

            filter.AddUnencryptable(new Regex(@"\\\.dropbox$".Replace(@"\\", s)));
            filter.AddUnencryptable(new Regex(@"\\desktop\.ini$".Replace(@"\\", s)));
            filter.AddUnencryptable(new Regex(@".*\.tmp$"));

            Assert.That(filter.IsEncryptable(new FakeDataStore(@"anywhere\.dropbox")), Is.False);
            Assert.That(filter.IsEncryptable(new FakeDataStore(@"C:\Somewhere\file.dropbox")), Is.True);
            Assert.That(filter.IsEncryptable(new FakeDataStore(@".dropboxx")), Is.True);
            Assert.That(filter.IsEncryptable(new FakeDataStore(@".dropbo")), Is.True);
            Assert.That(filter.IsEncryptable(new FakeDataStore(@"folder\desktop.ini")), Is.False);
            Assert.That(filter.IsEncryptable(new FakeDataStore(@"file-desktop.ini")), Is.True);
            Assert.That(filter.IsEncryptable(new FakeDataStore(@"anything.tmp")), Is.False);
            Assert.That(filter.IsEncryptable(new FakeDataStore(@"C:\anywhere\anything.tmp.tmp")), Is.False);
            Assert.That(filter.IsEncryptable(new FakeDataStore(@"C:\anywhere\anything.tmp.tmpx")), Is.True);
        }
Esempio n. 3
0
        public void FileFilterTestOfficeTemporaryFiles()
        {
            FileFilter filter = new FileFilter();

            string s = $"\\{Path.DirectorySeparatorChar}";

            filter.AddUnencryptable(new Regex(@"^.*\\~\$[^\\]*$".Replace(@"\\", s)));

            Assert.That(filter.IsEncryptable(new FakeDataStore(@"C:\Folder\~$")), Is.False);
            Assert.That(filter.IsEncryptable(new FakeDataStore(@"C:\Folder\~$\")), Is.True);
            Assert.That(filter.IsEncryptable(new FakeDataStore(@"C:\Folder\~$\~$")), Is.False);
            Assert.That(filter.IsEncryptable(new FakeDataStore(@"C:\Folder\~$Temp")), Is.False);
            Assert.That(filter.IsEncryptable(new FakeDataStore(@"C:\Folder\~$Temp.docx")), Is.False);
            Assert.That(filter.IsEncryptable(new FakeDataStore(@"C:\Folder\~$Temp.docx\The-file.txt")), Is.True);
        }