public void different_extensions_same_content()
        {
            var rootFolder = ZapperFileTestHelper.GetTestFileSubfolder("PhaseCalculateHashesTester");
            System.Diagnostics.Trace.WriteLine(rootFolder.FullPath);

            List<ZapperFile> files = new List<ZapperFile>();

            string sFilePath = Path.Combine(rootFolder.FullPath, "charlie.txt");
            files.Add(new ZapperFile { FullPath = sFilePath, Size = 999, Extension = ".txt", SampleHash = "2" });

            sFilePath = Path.Combine(rootFolder.FullPath, "delta.foo");
            files.Add(new ZapperFile { FullPath = sFilePath, Size = 999, Extension = ".foo", SampleHash = "2" });

            FileZapperSettings settings = new FileZapperSettings();
            List<ZapperFolder> folders = new List<ZapperFolder>();
            folders.Add(rootFolder);
            settings.RootFolders = folders;

            List<IZapperPhase> allphases = new List<IZapperPhase>();
            var phase = new PhaseCalculateHashes { PhaseOrder = 1, IsInitialPhase = true };
            allphases.Add(phase);

            var processor = new ZapperProcessor(settings, allphases);
            foreach (var zfile in files)
            {
                Assert.IsTrue(processor.ZapperFiles.TryAdd(zfile.FullPath, zfile));
            }

            phase.Process();

            Assert.AreEqual(2, processor.ZapperFiles.Count);
            Assert.That(files[0].ContentHash, Is.Null.Or.Empty);
            Assert.That(files[1].ContentHash, Is.Null.Or.Empty);
        }
        public void process()
        {
            var rootFolder = ZapperFileTestHelper.GetTestFileSubfolder("PhaseParseFilesystemTester");
            System.Diagnostics.Trace.WriteLine(rootFolder.FullPath);
            rootFolder.Priority = 1;
            string sKeeperFilePath = Path.Combine(rootFolder.FullPath, "keeper.txt");
            ZapperFileTestHelper.CreateTextFile(sKeeperFilePath, 5);
            string sUnwantedFilePath = Path.Combine(rootFolder.FullPath, "unwanted.foo");
            ZapperFileTestHelper.CreateTextFile(sUnwantedFilePath, 5);
            string sSmallFilePath = Path.Combine(rootFolder.FullPath, "small.txt");
            ZapperFileTestHelper.CreateTextFile(sSmallFilePath, 1);
            string sLargeFilePath = Path.Combine(rootFolder.FullPath, "large.txt");
            ZapperFileTestHelper.CreateTextFile(sLargeFilePath, 10);

            FileZapperSettings settings = new FileZapperSettings();
            settings.UnwantedExtensions = new string[] { ".foo" };
            List<ZapperFolder> folders = new List<ZapperFolder>();
            folders.Add(rootFolder);
            settings.RootFolders = folders;
            settings.IgnoreFilesBelowBytes = 1000;
            settings.IgnoreFilesOverBytes = 3000;

            List<IZapperPhase> allphases = new List<IZapperPhase>();
            var phase = new PhaseParseFilesystem { PhaseOrder = 1, IsInitialPhase = true };
            allphases.Add(phase);

            var processor = new ZapperProcessor(settings, allphases);
            phase.Process();
            Assert.IsTrue(File.Exists(sKeeperFilePath));
            Assert.IsFalse(File.Exists(sUnwantedFilePath));
            Assert.AreEqual(1, processor.ZapperFiles.Count);
            Assert.AreEqual(1, processor.ZapperFilesDeleted.Count);
        }
        public void process()
        {
            var rootFolder = ZapperFileTestHelper.GetTestFileSubfolder("PhaseCalculateSamplesTester");
            System.Diagnostics.Trace.WriteLine(rootFolder.FullPath);

            List<ZapperFile> files = new List<ZapperFile>();

            string sFilePath = Path.Combine(rootFolder.FullPath, "alpha.txt");
            ZapperFileTestHelper.CreateTextFile(sFilePath, 50);
            var alpha = new ZapperFile(sFilePath);
            files.Add(alpha);

            sFilePath = Path.Combine(rootFolder.FullPath, "bravo.txt");
            ZapperFileTestHelper.CreateTextFile(sFilePath, 50);
            var bravo = new ZapperFile(sFilePath);
            files.Add(bravo);

            sFilePath = Path.Combine(rootFolder.FullPath, "charlie.txt");
            ZapperFileTestHelper.CreateTextFile(sFilePath, 50, ZapperFileTestHelper.AltFillerText);
            var charlie = new ZapperFile(sFilePath);
            files.Add(charlie);

            FileZapperSettings settings = new FileZapperSettings();
            List<ZapperFolder> folders = new List<ZapperFolder>();
            folders.Add(rootFolder);
            settings.RootFolders = folders;

            List<IZapperPhase> allphases = new List<IZapperPhase>();
            var phase = new PhaseCalculateSamples { PhaseOrder = 1, IsInitialPhase = true };
            allphases.Add(phase);

            var processor = new ZapperProcessor(settings, allphases);
            foreach (var zfile in files)
            {
                Assert.IsTrue(processor.ZapperFiles.TryAdd(zfile.FullPath, zfile));
            }

            phase.Process();

            Assert.AreEqual(3, processor.ZapperFiles.Count);
            Assert.That(files[0].SampleHash, Is.Not.Null.And.Not.Empty);
            Assert.AreEqual(files[0].SampleHash, files[1].SampleHash);
            Assert.That(files[2].SampleHash, Is.Null.Or.Empty);
        }
        public void calculate_score()
        {
            var rootFolder = ZapperFileTestHelper.GetTestFileSubfolder("PhaseRemoveDuplicatesTester");
            rootFolder.Priority = 100000;
            System.Diagnostics.Trace.WriteLine(rootFolder.FullPath);

            FileZapperSettings settings = new FileZapperSettings();
            List<ZapperFolder> folders = new List<ZapperFolder>();
            folders.Add(rootFolder);
            settings.RootFolders = folders;

            List<IZapperPhase> allphases = new List<IZapperPhase>();
            var phase = new PhaseRemoveDuplicates { PhaseOrder = 1, IsInitialPhase = true };
            allphases.Add(phase);

            var processor = new ZapperProcessor(settings, allphases);
            var zfile = new ZapperFile { Directory = rootFolder.FullPath, FullPath = Path.Combine(rootFolder.FullPath, "test.txt"), FileModified = DateTime.Now };
            phase.CalculateScore(zfile);
            int iScore = 110000 + ((zfile.Directory.Count(x => x == '\\') + 1) * 1000);
            Assert.AreEqual(iScore, zfile.Score);
        }
示例#5
0
        public void process()
        {
            var rootFolder = ZapperFileTestHelper.GetTestFileSubfolder("PhaseCleanupTester");
            System.Diagnostics.Trace.WriteLine(rootFolder.FullPath);

            string sUnwantedFolderName = "unwanted";
            var wantedFolder = ZapperFileTestHelper.GetTestFileSubfolder(rootFolder.FullPath, "wanted");
            var unwantedFolder = ZapperFileTestHelper.GetTestFileSubfolder(rootFolder.FullPath, sUnwantedFolderName);

            FileZapperSettings settings = new FileZapperSettings();
            settings.UnwantedFolders = new string[] { sUnwantedFolderName };
            List<ZapperFolder> folders = new List<ZapperFolder>();
            folders.Add(rootFolder);
            settings.RootFolders = folders;

            List<IZapperPhase> allphases = new List<IZapperPhase>();
            var phase = new PhaseCleanup { PhaseOrder = 1, IsInitialPhase = true };
            allphases.Add(phase);

            var processor = new ZapperProcessor(settings, allphases);
            phase.Process();
            Assert.IsTrue(Directory.Exists(wantedFolder.FullPath));
            Assert.IsTrue(!Directory.Exists(unwantedFolder.FullPath));
        }
        public void SetUp()
        {
            FileZapperSettings settings = new FileZapperSettings();
            List<ZapperFolder> folders = new List<ZapperFolder>();
            folders.Add(new ZapperFolder { FullPath = "test path 1", Priority = 150 });
            settings.RootFolders = folders;

            List<IZapperPhase> allphases = new List<IZapperPhase>();
            allphases.Add(new TestPhase { PhaseOrder = 1, Name = "Alpha", IsInitialPhase = true });
            allphases.Add(new TestPhase { PhaseOrder = 2, Name = "Bravo" });
            allphases.Add(new TestPhase { PhaseOrder = 3, Name = "Charlie" });

            _processor = new ZapperProcessor(settings, allphases);
        }
        public void process_folders_hierarchyonly_multiroot()
        {
            var rootFolder = ZapperFileTestHelper.GetTestFileSubfolder("PhaseCalculateSamplesTester");
            System.Diagnostics.Trace.WriteLine(rootFolder.FullPath);

            var alphaFolder = ZapperFileTestHelper.GetTestFileSubfolder(rootFolder.FullPath, "Alpha");
            alphaFolder.Priority = 300000;
            var bravoFolder = ZapperFileTestHelper.GetTestFileSubfolder(rootFolder.FullPath, "Bravo");
            bravoFolder.Priority = 100000;

            List<ZapperFile> files = new List<ZapperFile>();

            string sFilePath = Path.Combine(alphaFolder.FullPath, "alpha.txt");
            ZapperFileTestHelper.CreateTextFile(sFilePath, 50);
            var alpha = new ZapperFile(sFilePath);
            files.Add(alpha);

            sFilePath = Path.Combine(bravoFolder.FullPath, "bravo.txt");
            ZapperFileTestHelper.CreateTextFile(sFilePath, 50);
            var bravo = new ZapperFile(sFilePath);
            files.Add(bravo);

            FileZapperSettings settings = new FileZapperSettings();
            List<ZapperFolder> folders = new List<ZapperFolder>();
            folders.Add(alphaFolder);
            folders.Add(bravoFolder);
            settings.RootFolders = folders;

            List<IZapperPhase> allphases = new List<IZapperPhase>();
            var phase = new PhaseCalculateSamples { PhaseOrder = 1, IsInitialPhase = true };
            allphases.Add(phase);

            var processor = new ZapperProcessor(settings, allphases);
            foreach (var zfile in files)
            {
                Assert.IsTrue(processor.ZapperFiles.TryAdd(zfile.FullPath, zfile));
            }

            settings.DupeCheckIgnoresHierarchy = false;
            phase.Process();
            Assert.AreEqual(2, processor.ZapperFiles.Count);
            Assert.That(files[0].SampleHash, Is.Null.Or.Empty);
            Assert.That(files[1].SampleHash, Is.Null.Or.Empty);
        }
        public void process()
        {
            var rootFolder = ZapperFileTestHelper.GetTestFileSubfolder("PhaseRemoveDuplicatesTester");
            System.Diagnostics.Trace.WriteLine(rootFolder.FullPath);

            var importantFolder = ZapperFileTestHelper.GetTestFileSubfolder(rootFolder.FullPath, "important");
            importantFolder.Priority = 900000;
            var loserFolder = ZapperFileTestHelper.GetTestFileSubfolder(rootFolder.FullPath, "loser");
            loserFolder.Priority = 100000;

            List<ZapperFile> files = new List<ZapperFile>();
            string sFilePath = Path.Combine(importantFolder.FullPath, "alpha.txt");
            files.Add(new ZapperFile { Directory = importantFolder.FullPath, FullPath = sFilePath, FileModified = DateTime.Now, ContentHash = "something" });
            ZapperFileTestHelper.CreateTextFile(sFilePath, 5);

            sFilePath = Path.Combine(loserFolder.FullPath, "bravo.txt");
            files.Add(new ZapperFile { Directory = loserFolder.FullPath, FullPath = sFilePath, FileModified = DateTime.Now, ContentHash = "something" });
            ZapperFileTestHelper.CreateTextFile(sFilePath, 5);

            FileZapperSettings settings = new FileZapperSettings();
            List<ZapperFolder> folders = new List<ZapperFolder>();
            folders.Add(importantFolder);
            folders.Add(loserFolder);
            settings.RootFolders = folders;

            List<IZapperPhase> allphases = new List<IZapperPhase>();
            var phase = new PhaseRemoveDuplicates { PhaseOrder = 1, IsInitialPhase = true };
            allphases.Add(phase);

            var processor = new ZapperProcessor(settings, allphases);
            foreach (var zfile in files)
            {
                Assert.IsTrue(processor.ZapperFiles.TryAdd(zfile.FullPath, zfile));
            }

            phase.Process();

            Assert.AreEqual(1, processor.ZapperFiles.Count);
            Assert.AreEqual(1, processor.ZapperFilesDeleted.Count);
        }
示例#9
0
 static void Main(string[] args)
 {
     ZapperProcessor z = new ZapperProcessor();
     z.StartConsole();
 }
        public void matching_files()
        {
            var rootFolder = ZapperFileTestHelper.GetTestFileSubfolder("PhaseCalculateHashesTester");
            System.Diagnostics.Trace.WriteLine(rootFolder.FullPath);

            List<ZapperFile> files = new List<ZapperFile>();
            string sFilePath = Path.Combine(rootFolder.FullPath, "alpha.txt");
            files.Add(new ZapperFile { FullPath = sFilePath, Size = 500, Extension = ".txt", SampleHash = "1" });
            ZapperFileTestHelper.CreateTextFile(sFilePath, 5);

            sFilePath = Path.Combine(rootFolder.FullPath, "bravo.txt");
            files.Add(new ZapperFile { FullPath = sFilePath, Size = 500, Extension = ".txt", SampleHash = "1" });
            ZapperFileTestHelper.CreateTextFile(sFilePath, 5);

            FileZapperSettings settings = new FileZapperSettings();
            List<ZapperFolder> folders = new List<ZapperFolder>();
            folders.Add(rootFolder);
            settings.RootFolders = folders;

            List<IZapperPhase> allphases = new List<IZapperPhase>();
            var phase = new PhaseCalculateHashes { PhaseOrder = 1, IsInitialPhase = true };
            allphases.Add(phase);

            var processor = new ZapperProcessor(settings, allphases);
            foreach (var zfile in files)
            {
                Assert.IsTrue(processor.ZapperFiles.TryAdd(zfile.FullPath, zfile));
            }

            phase.Process();

            Assert.AreEqual(2, processor.ZapperFiles.Count);
            Assert.That(files[0].ContentHash, Is.Not.Null.And.Not.Empty);
            Assert.That(files[1].ContentHash, Is.Not.Null.And.Not.Empty);
            Assert.AreEqual(files[0].ContentHash, files[1].ContentHash);
        }