Example #1
0
        public void TestDiff_withComparisonListener_shouldCallListener()
        {
            // prepare testData
            string             control            = "<a><b attr=\"abc\"></b></a>";
            string             test               = "<a><b attr=\"xyz\"></b></a>";
            List <Difference>  diffs              = new List <Difference>();
            ComparisonListener comparisonListener = (comparison, outcome) => {
                diffs.Add(new Difference(comparison, outcome));
            };

            // run test
            var myDiff = DiffBuilder.Compare(control).WithTest(test)
                         .WithComparisonListeners(comparisonListener)
                         .Build();

            // validate result
            Assert.IsTrue(myDiff.HasDifferences(), myDiff.ToString());
            Assert.That(diffs.Count, Is.GreaterThan(1));
        }
Example #2
0
        private void FireComparisonPerformed(Comparison comp,
                                             ComparisonResult outcome)
        {
            ComparisonListener cl = ComparisonListener;
            ComparisonListener ml = MatchListener;
            ComparisonListener dl = DifferenceListener;

            if (cl != null)
            {
                cl(comp, outcome);
            }
            if (outcome == ComparisonResult.EQUAL && ml != null)
            {
                ml(comp, outcome);
            }
            else if (outcome != ComparisonResult.EQUAL && dl != null)
            {
                dl(comp, outcome);
            }
        }