Exemplo n.º 1
0
 /// <summary>
 /// The "standard" difference evaluator which decides which
 /// differences make two XML documents really different and which
 /// still leave them similar.
 /// </summary>
 public static ComparisonResult Default(Comparison comparison,
                                        ComparisonResult outcome)
 {
     if (outcome == ComparisonResult.DIFFERENT) {
         switch (comparison.Type) {
         case ComparisonType.NODE_TYPE:
             XmlNodeType control =
                 (XmlNodeType) comparison.ControlDetails.Value;
             XmlNodeType test =
                 (XmlNodeType) comparison.TestDetails.Value;
             if ((control == XmlNodeType.Text && test == XmlNodeType.CDATA)
                 ||
                 (control == XmlNodeType.CDATA && test == XmlNodeType.Text)
                 ) {
                 outcome = ComparisonResult.SIMILAR;
             }
             break;
         case ComparisonType.XML_ENCODING:
         case ComparisonType.HAS_DOCTYPE_DECLARATION:
         case ComparisonType.DOCTYPE_SYSTEM_ID:
         case ComparisonType.SCHEMA_LOCATION:
         case ComparisonType.NO_NAMESPACE_SCHEMA_LOCATION:
         case ComparisonType.NAMESPACE_PREFIX:
         case ComparisonType.ATTR_VALUE_EXPLICITLY_SPECIFIED:
         case ComparisonType.CHILD_NODELIST_SEQUENCE:
             outcome = ComparisonResult.SIMILAR;
             break;
         }
     }
     return outcome;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Difference evaluator that just echos the result passed in.
 /// </summary>
 public static ComparisonResult Accept(Comparison comparison,
                                       ComparisonResult outcome)
 {
     return outcome;
 }
 public void ComparisonPerformed(Comparison comparison,
                                 ComparisonResult outcome)
 {
     Assert.Greater(expectedInvocations, invoked);
     invoked++;
     Assert.AreEqual(type, comparison.Type);
     Assert.AreEqual(ComparisonResult.CRITICAL, outcome);
     if (withXPath) {
         Assert.AreEqual(controlXPath,
                         comparison.ControlDetails.XPath,
                         "Control XPath");
         Assert.AreEqual(testXPath,
                         comparison.TestDetails.XPath,
                         "Test XPath");
     }
 }
 /// <summary>
 /// Compares the detail values for object equality, lets the
 /// difference evaluator evaluate the result, notifies all
 /// listeners and returns the outcome.
 /// </summary>
 protected internal ComparisonResult Compare(Comparison comp)
 {
     object controlValue = comp.ControlDetails.Value;
     object testValue = comp.TestDetails.Value;
     bool equal = controlValue == null
         ? testValue == null : controlValue.Equals(testValue);
     ComparisonResult initial =
         equal ? ComparisonResult.EQUAL : ComparisonResult.DIFFERENT;
     ComparisonResult altered = DifferenceEvaluator(comp, initial);
     FireComparisonPerformed(comp, altered);
     return altered;
 }
 private void FireComparisonPerformed(Comparison comp,
                                      ComparisonResult outcome)
 {
     if (ComparisonListener != null) {
         ComparisonListener(comp, outcome);
     }
     if (outcome == ComparisonResult.EQUAL && MatchListener != null) {
         MatchListener(comp, outcome);
     } else if (outcome != ComparisonResult.EQUAL
                && DifferenceListener != null) {
         DifferenceListener(comp, outcome);
     }
 }
 public ComparisonResult Evaluate(Comparison comparison,
                                  ComparisonResult orig)
 {
     Called = true;
     return ret;
 }
 private ComparisonResult ResultGrabber(Comparison comparison,
                                        ComparisonResult outcome)
 {
     this.outcome = outcome;
     return outcome;
 }