public void DeleteSingle() { var blacklistedFile = new BlackListedFile { FileName = "*", FileExtension = "lnk" }; string id = _context.Insert(DatabaseName, blacklistedFile); Assert.IsTrue(id != Guid.Empty.ToString()); blacklistedFile = _context.GetEntry<BlackListedFile>(DatabaseName, id); //delete _context.Delete(DatabaseName, blacklistedFile); blacklistedFile = _context.GetEntry<BlackListedFile>(DatabaseName, id); Assert.IsTrue(blacklistedFile == null); }
public void AddAndGetBlacklistedFiles() { var databaseService = _container.Resolve<IDatabaseService>(); Assert.IsNotNull(databaseService); databaseService.SetDatabaseName(DatabaseName); List<BlackListedFile> blacklistedFiles = databaseService.GetBlackListedFiles(); Assert.IsTrue(blacklistedFiles.Count == 0); var blacklistedFile = new BlackListedFile { FileName = "*", FileExtension = ".zip" }; databaseService.AddBlacklistedFile(blacklistedFile); blacklistedFiles = databaseService.GetBlackListedFiles(); Assert.IsTrue(blacklistedFiles.Count == 1); Assert.IsTrue(blacklistedFiles[0].FileName == "*"); Assert.IsTrue(blacklistedFiles[0].FileExtension == ".zip"); }
private void AddFile(object obj) { bool isAlreadyListed = _blackListedFiles.Any(f => f.FileExtension == _newExtension && f.FileName == _newFilename); if (!isAlreadyListed) { if (!string.IsNullOrEmpty(_newExtension)) { var blackFile = new BlackListedFile { FileName = _newFilename, FileExtension = "." + _newExtension, }; _databaseService.AddBlacklistedFile(blackFile); BlackListedFiles = _databaseService.GetBlackListedFiles(); NewFilename = "*"; NewExtension = string.Empty; MessageBox.Show(Resources.ConfigurationViewModel_AddFile_File_added_to_Blacklist_, Resources.ConfigurationViewModel_AddFile_Info, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show( Resources.ConfigurationViewModel_AddFile_File_not_added_to_Blacklist__Extension_cannot_be_empty_, Resources.ConfigurationViewModel_AddFile_Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
public static void MyClassInitialize(TestContext testContext) { _container = DIContainerHelper.Setup(out _context); _context.ClearDb(DatabaseName); //create test directory, which simulates the desktop folder if (!Directory.Exists(DesktopTestDirectory)) { Directory.CreateDirectory(DesktopTestDirectory); } if (!Directory.Exists(DestinationDirectory)) { Directory.CreateDirectory(DestinationDirectory); } //create test files on the 'desktop' File.Create(Path.Combine(DesktopTestDirectory, "test.txt")).Close(); File.Create(Path.Combine(DesktopTestDirectory, "test1.zip")).Close(); File.Create(Path.Combine(DesktopTestDirectory, "test2.zip")).Close(); File.Create(Path.Combine(DesktopTestDirectory, "test3.xml")).Close(); File.Create(Path.Combine(DesktopTestDirectory, "test4.xml")).Close(); File.Create(Path.Combine(DesktopTestDirectory, "test5.xml")).Close(); //simulates a shortcut on the desktop File.Create(Path.Combine(DesktopTestDirectory, "Desktop.lnk")).Close(); //create test directories var dir1Path = Path.Combine(DesktopTestDirectory, "dir1"); Directory.CreateDirectory(dir1Path); File.Create(Path.Combine(dir1Path, "dirTest1.txt")).Close(); var dir2Path = Path.Combine(DesktopTestDirectory, "dir2"); Directory.CreateDirectory(dir2Path); File.Create(Path.Combine(dir2Path, "dirTest2.txt")).Close(); var vipDirPath = Path.Combine(DesktopTestDirectory, "VIPdir"); Directory.CreateDirectory(vipDirPath); File.Create(Path.Combine(vipDirPath, "vipText.xml")).Close(); //configure blacklisted files and directories var blacklistedFile1 = new BlackListedFile { FileName = "test", FileExtension = ".txt" }; var blacklistedFile2 = new BlackListedFile { FileName = "*", FileExtension = ".zip" }; var blacklistedDir = new BlackListedDirectory { Name = "VIPdir" }; var databaseService = _container.Resolve<IDatabaseService>(); databaseService.AddBlacklistedFile(blacklistedFile1); databaseService.AddBlacklistedFile(blacklistedFile2); databaseService.AddBlacklistedDirectory(blacklistedDir); }
public void UpdateSingle() { var blacklistedFile = new BlackListedFile { FileName = "*", FileExtension = "lnk" }; string id = _context.Insert(DatabaseName, blacklistedFile); Assert.IsTrue(id != Guid.Empty.ToString()); blacklistedFile = _context.GetEntry<BlackListedFile>(DatabaseName, id); Assert.IsTrue(blacklistedFile != null); Assert.IsTrue(blacklistedFile.FileName == "*"); Assert.IsTrue(blacklistedFile.FileExtension == "lnk"); //update blacklistedFile.FileName = "*_bak"; _context.Update(DatabaseName, blacklistedFile); blacklistedFile = _context.GetEntry<BlackListedFile>(DatabaseName, id); Assert.IsTrue(blacklistedFile != null); Assert.IsTrue(blacklistedFile.FileName == "*_bak"); Assert.IsTrue(blacklistedFile.FileExtension == "lnk"); }
public void InsertSingle() { var blacklistedFile = new BlackListedFile { FileName = "*", FileExtension = "lnk" }; string id = _context.Insert(DatabaseName, blacklistedFile); Assert.IsTrue(id != Guid.Empty.ToString()); var blacklistedDirectory = new BlackListedDirectory { Name = "test" }; id = _context.Insert(DatabaseName, blacklistedDirectory); Assert.IsTrue(id != Guid.Empty.ToString()); }
public void GetBlacklistedFilesByIdList() { var idList = new List<string>(); var blacklistedFile = new BlackListedFile { FileName = "*", FileExtension = "lnk" }; var blacklistedFile2 = new BlackListedFile { FileName = "*", FileExtension = "exe" }; string id = _context.Insert(DatabaseName, blacklistedFile); Assert.IsTrue(id != Guid.Empty.ToString()); idList.Add(id); id = _context.Insert(DatabaseName, blacklistedFile2); Assert.IsTrue(id != Guid.Empty.ToString()); idList.Add(id); Assert.IsTrue(idList.Count == 2); List<BlackListedFile> blacklistedFiles = _context.GetEntries<BlackListedFile>(DatabaseName, idList); Assert.IsTrue(blacklistedFiles != null); Assert.IsTrue(blacklistedFiles.Count == 2); }