Esempio n. 1
0
        public void ShouldVerifyCandidates()
        {
            var directoryPath = SetupTests();

            var candidates = service.CollectCandidates(directoryPath);
            var files      = service.VerifyCandidates(candidates).ToList();

            files.Count.ShouldBe(2);
            files.ShouldContain(x => x.FilePaths.Count() == 3 && x.FilePaths.All(p => p.EndsWith("foo.txt")));
            files.ShouldContain(x => x.FilePaths.Count() == 2 && x.FilePaths.All(p => p.EndsWith("bar.txt")));
        }
        private void PerformSecondPass(IEnumerable<IDuplicateFile> duplicateFiles, string path, ComparisonMode mode)
        {
            var candidates = duplicateDetectionService.VerifyCandidates(duplicateFiles).ToList();
            if (candidates.Any())
            {
                System.Console.WriteLine($"Found {candidates.Count} duplicate(s):");
                System.Console.WriteLine();

                foreach (var candidate in candidates)
                {
                    foreach (var filePath in candidate.FilePaths)
                    {
                        System.Console.WriteLine($"{filePath}");
                    }

                    System.Console.WriteLine();
                }
            }
            else
            {
                System.Console.WriteLine($"No duplicate files found in {path} for mode ${mode} in second pass.");
            }
        }
Esempio n. 3
0
        public void ShouldVerifyCandidates()
        {
            var firstFilePath  = "foo.txt";
            var secondFilePath = "bar.txt";
            var hash           = new byte[] { 0x00, 0x00, 0x00, 0x00 };

            fileHashService.CalculateHash(firstFilePath).Returns(hash);
            fileHashService.CalculateHash(secondFilePath).Returns(hash);

            var candidates = Substitute.For <IDuplicateFile>();

            candidates.FilePaths.Returns(new List <string> {
                firstFilePath, secondFilePath
            });

            var files = service.VerifyCandidates(new List <IDuplicateFile> {
                candidates
            }).ToList();

            files.Count.ShouldBe(1);
            files.Single().FilePaths.ShouldContain(firstFilePath);
            files.Single().FilePaths.ShouldContain(secondFilePath);
        }