public void AddAndGetBlacklistedDirectories()
        {
            var databaseService = _container.Resolve<IDatabaseService>();
            Assert.IsNotNull(databaseService);

            databaseService.SetDatabaseName(DatabaseName);
            List<BlackListedDirectory> blacklistedDirectories = databaseService.GetBlackListedDirectories();
            Assert.IsTrue(blacklistedDirectories.Count == 0);

            var blacklistedDirectory = new BlackListedDirectory
            {
                Name = "VIP"
            };

            databaseService.AddBlacklistedDirectory(blacklistedDirectory);
            blacklistedDirectories = databaseService.GetBlackListedDirectories();
            Assert.IsTrue(blacklistedDirectories.Count == 1);
            Assert.IsTrue(blacklistedDirectories[0].Name == "VIP");
        }
Exemplo n.º 2
0
        public void GetBlacklistedDirectories()
        {
            var blacklistedDirectory = new BlackListedDirectory
            {
                Name = "test"
            };

            var blacklistedDirectory2 = new BlackListedDirectory
            {
                Name = "test2"
            };

            string id = _context.Insert(DatabaseName, blacklistedDirectory);
            Assert.IsTrue(id != Guid.Empty.ToString());

            id = _context.Insert(DatabaseName, blacklistedDirectory2);
            Assert.IsTrue(id != Guid.Empty.ToString());

            List<BlackListedDirectory> blacklistedDirectories = _context.GetEntries<BlackListedDirectory>(DatabaseName);
            Assert.IsTrue(blacklistedDirectories != null);
            Assert.IsTrue(blacklistedDirectories.Count == 2);
        }
        private void AddFolder(object obj)
        {
            bool isAlreadyListed = _blackListedDirectories.Any(f => f.Name == _newFolder);

            if (!isAlreadyListed)
            {
                if (!string.IsNullOrEmpty(_newFolder))
                {
                    var blackFolder = new BlackListedDirectory
                    {
                        Name = _newFolder
                    };

                    _databaseService.AddBlacklistedDirectory(blackFolder);

                    BlackListedDirectories = _databaseService.GetBlackListedDirectories();

                    NewFolder = string.Empty;
                }
            }
        }
        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);
        }
Exemplo n.º 5
0
        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());
        }
Exemplo n.º 6
0
        public void GetBlacklistedDirectory()
        {
            var blacklistedDirectory = new BlackListedDirectory
            {
                Name = "test"
            };

            string id = _context.Insert(DatabaseName, blacklistedDirectory);
            Assert.IsTrue(id != Guid.Empty.ToString());

            blacklistedDirectory = _context.GetEntry<BlackListedDirectory>(DatabaseName, id);
            Assert.IsTrue(blacklistedDirectory != null);
            Assert.IsTrue(blacklistedDirectory.Name == "test");
        }