コード例 #1
0
 public void CreateDiffResult()
 {
     _result = new DiffResult();
     _diff = new XmlDiff("<a/>", "<b/>");
     _majorDifference = new Difference(DifferenceType.ElementTagName, XmlNodeType.Element, XmlNodeType.Element);
     _minorDifference = new Difference(DifferenceType.AttributeSequence, XmlNodeType.Comment, XmlNodeType.Comment);
 }
コード例 #2
0
 public void AssertDifferentStringsNotEqualNorIdentical()
 {
     string control = "<assert>true</assert>";
     string test = "<assert>false</assert>";
     XmlDiff xmlDiff = new XmlDiff(control, test);
     XmlAssert.XmlNotIdentical(xmlDiff);
     XmlAssert.XmlNotEquals(xmlDiff);
 }
コード例 #3
0
 public void AssertXmlIdenticalUsesOptionalDescription()
 {
     string description = "An Optional Description";
     try {
         XmlDiff diff = new XmlDiff(new XmlInput("<a/>"), new XmlInput("<b/>"),
                                    new DiffConfiguration(description));
         XmlAssert.XmlIdentical(diff);
     } catch (AssertionException e) {
         Assert.AreEqual(true, e.Message.StartsWith(description));
     }
 }
コード例 #4
0
 public void DifferenceFound(XmlDiff inDiff, Difference difference)
 {
     _identical = false;
     if (difference.MajorDifference) {
         _equal = false;
     }
     _difference = difference;
     if (_stringBuilder.Length == 0) {
         _stringBuilder.Append(inDiff.OptionalDescription);
     }
     _stringBuilder.Append(Environment.NewLine).Append(difference);
 }
コード例 #5
0
 private void PerformAssertion(string control, string test, bool assertion, 
                               DiffConfiguration xmlUnitConfiguration) {
     XmlDiff diff = new XmlDiff(new XmlInput(control), new XmlInput(test), 
                                xmlUnitConfiguration);
     PerformAssertion(diff, assertion);
 }        
コード例 #6
0
 //[Test] public void DefaultConfiguredToUseValidatingParser() {
 //    DiffConfiguration diffConfiguration = new DiffConfiguration();
 //    OldAssert.AreEqual(DiffConfiguration.DEFAULT_USE_VALIDATING_PARSER, 
 //                           diffConfiguration.UseValidatingParser);
     
 //    Stream controlFileStream = ValidatorTests.ValidFile;
 //    Stream testFileStream = ValidatorTests.InvalidFile;
 //    try {         
 //        XmlDiff diff = new XmlDiff(new StreamReader(controlFileStream), 
 //                                   new StreamReader(testFileStream));
 //        diff.Compare();
 //        OldAssert.Fail("Expected validation failure");
 //    } catch (XmlSchemaException e) {
 //        string message = e.Message; // to prevent 'unused variable' compiler warning 
 //    } finally {
 //        controlFileStream.Close();
 //        testFileStream.Close();
 //    }
 //}
         
 //[Test] public void CanConfigureNotToUseValidatingParser() {
 //    DiffConfiguration diffConfiguration = new DiffConfiguration(false);
 //    OldAssert.AreEqual(false, diffConfiguration.UseValidatingParser);
     
 //    Stream controlFileStream = ValidatorTests.ValidFile;
 //    Stream testFileStream = ValidatorTests.InvalidFile;
 //    try {         
 //        XmlDiff diff = new XmlDiff(new XmlInput(controlFileStream), 
 //                                   new XmlInput(testFileStream),
 //                                   diffConfiguration);
 //        diff.Compare();
 //    } catch (XmlSchemaException e) {
 //        OldAssert.Fail("Unexpected validation failure: " + e.Message);
 //    } finally {
 //        controlFileStream.Close();
 //        testFileStream.Close();
 //    }
 //}
 
 //[Test] public void DefaultConfiguredWithWhitespaceHandlingAll() {
 //    DiffConfiguration diffConfiguration = new DiffConfiguration();
 //    OldAssert.AreEqual(WhitespaceHandling.All, diffConfiguration.WhitespaceHandling);
     
 //    PerformAssertion(xmlWithoutWhitespace, xmlWithWhitespaceElement, false);
 //    PerformAssertion(xmlWithoutWhitespace, xmlWithoutWhitespaceElement, false);
 //    PerformAssertion(xmlWithoutWhitespace, xmlWithWhitespace, false);
 //    PerformAssertion(xmlWithoutWhitespaceElement, xmlWithWhitespaceElement, false);
 //}
 
 private void PerformAssertion(string control, string test, bool assertion) {
     XmlDiff diff = new XmlDiff(control, test);
     PerformAssertion(diff, assertion);
 }
コード例 #7
0
 private void PerformAssertion(XmlDiff diff, bool assertion) {
     OldAssert.AreEqual(assertion, diff.Compare().Equal);            
     OldAssert.AreEqual(assertion, diff.Compare().Identical);            
 }
コード例 #8
0
 public static void XmlEquals(XmlDiff xmlDiff)
 {
     XmlEquals(xmlDiff, true);
 }
コード例 #9
0
 private static void XmlIdentical(XmlDiff xmlDiff, bool identical)
 {
     DiffResult diffResult = xmlDiff.Compare();
     Assert.AreEqual(identical, diffResult.Identical,xmlDiff.OptionalDescription);
 }
コード例 #10
0
 private static void XmlEquals(XmlDiff xmlDiff, bool equal)
 {
     if (equal)
         xmlDiff.Compare();
     else
     {
         try
         {
             xmlDiff.Compare();
         }
         catch(Exception ex)
         {
             if(ex.GetType()!=typeof(FlowControlException))
                 throw;
         }
     }
 }
コード例 #11
0
 public static void XmlNotIdentical(XmlDiff xmlDiff)
 {
     XmlIdentical(xmlDiff, false);
 }
コード例 #12
0
 public static void XmlNotEquals(XmlDiff xmlDiff)
 {
     XmlEquals(xmlDiff, false);
 }
コード例 #13
0
 public static void XmlIdentical(XmlDiff xmlDiff)
 {
     XmlIdentical(xmlDiff, true);
 }
コード例 #14
0
 /// <summary>
 /// Asserts that two pieces of XML are similar (or not) given their diff and a boolean value
 /// </summary>
 /// <param name="xmlDiff">The XML diff.</param>
 /// <param name="equal">if set to <c>true</c> the assert passes if the XML is similar.
 /// if <c>false</c>, the assert passes if the XML is not similar.</param>
 private static void XmlEquals(XmlDiff xmlDiff, bool equal)
 {
     DiffResult diffResult = xmlDiff.Compare();
     OldAssert.AreEqual(equal, diffResult.Equal, FailMessage(equal, xmlDiff.OptionalDescription));
 }
コード例 #15
0
 private DiffResult PerformDiff(TextReader reader1, TextReader reader2)
 {
     _xmlDiff = new XmlDiff(reader1, reader2);
     DiffResult result = _xmlDiff.Compare();
     return result;
 }