Example #1
0
 public void should_find_no_differences_between_left_and_right()
 {
     var comparison = new Comparison();
     var left = new Dictionary<string, string>();
     var right = new Dictionary<string, string>();
     left.Add("A", "1");
     left.Add("B", "2");
     right.Add("A", "1");
     right.Add("B", "2");
     comparison.Compare(left, right);
     Assert.That(comparison.AreSame(), Is.EqualTo(true));
 }
Example #2
0
 public void should_find_one_difference_missing_on_left_between_left_and_right()
 {
     var comparison = new Comparison();
     var left = new Dictionary<string, string>();
     var right = new Dictionary<string, string>();
     left.Add("A", "1");
     left.Add("B", "2");
     right.Add("A", "1");
     right.Add("B", "2");
     right.Add("AA", "4");
     comparison.Compare(left, right);
     Assert.That(comparison.AreSame(), Is.EqualTo(false));
     Assert.That(comparison.Diff.Count, Is.EqualTo(1));
     Assert.That(comparison.Same.Count, Is.EqualTo(2));
     Assert.That(comparison.Diff["AA"].GetType(), Is.EqualTo(typeof(MissingOnLeftSideResult)));
     var item = (MissingOnLeftSideResult)comparison.Diff["AA"];
     Assert.That(item.Hash, Is.EqualTo("4"));
 }
Example #3
0
        public int Compare(string leftPath, string rightPath, List<string> ignoreList,bool showFileDiff)
        {
            var startTime = DateTime.Now;
            var leftCompare = new FolderHasher(new Hasher(new Hash(), ignoreList),debug);
            var rightCompare = new FolderHasher(new Hasher(new Hash(), ignoreList),debug);

            leftCompare.SetFolder(leftPath);
            rightCompare.SetFolder(rightPath);
            var l = new Thread(leftCompare.Process1);
            var r = new Thread(rightCompare.Process1);

            l.Start();
            r.Start();
            while(l.IsAlive || r.IsAlive)
            {
                Thread.Sleep(10);
            }
            var comparison = new Comparison();
            comparison.Compare(leftCompare.Results,  rightCompare.Results);
            var executionTime = DateTime.Now.Subtract(startTime);
            if(showFileDiff)
            {
                foreach (var diff in comparison.Diff)
                {
                    Console.WriteLine(string.Format("{0} reason {1}", diff.Key, diff.Value.GetType()));
                }
            }

            if(verbose)
            {
                Console.WriteLine(string.Format("Took {0} to run", executionTime));
                Console.WriteLine(string.Format("Folders are same = {0}", comparison.AreSame()));
                Console.WriteLine(string.Format("Number of files are same = {0}", comparison.Same.Count));
                Console.WriteLine(string.Format("Number of files are different = {0}", comparison.Diff.Count));
            }

            return !comparison.AreSame() ? 1 : 0;
        }
Example #4
0
 public void should_return_timespan_of_time_taken_to_compare()
 {
     var comparison = new Comparison();
     var left = new Dictionary<string, string>();
     var right = new Dictionary<string, string>();
     left.Add("A", "1");
     left.Add("B", "2");
     left.Add("AA", "4");
     right.Add("A", "1");
     right.Add("B", "2");
     right.Add("BB", "5");
     comparison.Compare(left, right);
     Assert.That(comparison.ExecutionTime, Is.Not.Null);
 }