예제 #1
0
        private static Differences GetDifferences(string path1, string path2)
        {
            var calculator = new DifferenceCalculator(path1, path2);
            var diffs      = calculator.GetDifferences();

            return(diffs);
        }
예제 #2
0
        private Differences TryGetZipChanges(string zipFilePath, string previewZipFilePath)
        {
            var calculator  = new DifferenceCalculator(zipFilePath, previewZipFilePath);
            var differences = calculator.GetDifferences();

            return(differences);
        }
예제 #3
0
        static void Main(string[] args)
        {
            OutputLogo();

            var options = new Options();

            if (!CommandLine.Parser.Default.ParseArguments(args, options))
            {
                Console.WriteLine("No checksum hash files have been specified.");
                Environment.Exit(EXITCODE_ERROR);
            }

            var file1 = new FileInfo(options.File1);
            var file2 = new FileInfo(options.File2);

            CheckFile(file1);
            CheckFile(file2);

            Console.WriteLine("File 1 = {0}", file1.Name);
            Console.WriteLine("File 2 = {0}", file2.Name);
            Console.WriteLine();

            var calc = new DifferenceCalculator(file1.FullName, file2.FullName)
            {
                IgnoreCase = options.IgnoreCase,
                Verbose    = options.Verbose
            };

            var diff = calc.GetDifferences();

            if (!string.IsNullOrWhiteSpace(options.OutputFile))
            {
                WriteOutputFile(options.OutputFile, diff);
            }

            if (diff.HasDifferences())
            {
                if (options.Verbose)
                {
                    Console.WriteLine(diff);
                    Console.WriteLine("{0} and {1} are different", options.File1, options.File2);
                }

                if (options.ExitWithErrorOnDifference)
                {
                    Environment.Exit(EXITCODE_DIFF);
                }
            }
            else
            {
                Console.WriteLine("No differences found.");
            }

            Console.Read();
        }
            public void CalculateDifferences_ZipsSameEntriesDifferentContent()
            {
                var calc = new DifferenceCalculator(ZipOneEntryA1, ZipOneEntryA1_Changed);
                var diff = calc.GetDifferences();

                Assert.IsTrue(diff.HasDifferences());
                Assert.IsTrue(diff.Added.Count == 0);
                Assert.IsTrue(diff.Removed.Count == 0);
                Assert.IsTrue(diff.Changed.ContainsKey("A"));

                this.ExerciseOutputBuilders(diff);
            }
            public void CalculateDifferences_SameZip()
            {
                var calc = new DifferenceCalculator(ZipOneEntryA1, ZipOneEntryA1);
                var diff = calc.GetDifferences();

                Assert.IsFalse(diff.HasDifferences());
                Assert.IsTrue(diff.Added.Count == 0);
                Assert.IsTrue(diff.Removed.Count == 0);
                Assert.IsTrue(diff.Changed.Count == 0);

                this.ExerciseOutputBuilders(diff);
            }
        public void CalculateDifferences_DifferentEntries()
        {
            var calc = new DifferenceCalculator(TestHashes_A1, TestHashes_B1);
            var diff = calc.GetDifferences();

            Assert.IsTrue(diff.HasDifferences());
            Assert.IsTrue(diff.Added.ContainsKey("GGGGGGGG.txt"));
            Assert.IsTrue(diff.Removed.ContainsKey("WWWWWWWW.txt"));
            Assert.IsTrue(diff.Changed.Count == 0);

            this.ExerciseOutputBuilders(diff);
        }
예제 #7
0
        private Differences TryGetZipChanges(string zipFilePath, string previewZipFilePath)
        {
            var calculator = new DifferenceCalculator(zipFilePath, previewZipFilePath);
            var differences = calculator.GetDifferences();

            return differences;
        }
예제 #8
0
 private static Differences GetDifferences( string path1, string path2 )
 {
     var calculator = new DifferenceCalculator( path1, path2 );
     var diffs = calculator.GetDifferences();
     return diffs;
 }