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); }
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); }
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)); } }
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); }
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); }
//[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); }
private void PerformAssertion(XmlDiff diff, bool assertion) { OldAssert.AreEqual(assertion, diff.Compare().Equal); OldAssert.AreEqual(assertion, diff.Compare().Identical); }
public static void XmlEquals(XmlDiff xmlDiff) { XmlEquals(xmlDiff, true); }
private static void XmlIdentical(XmlDiff xmlDiff, bool identical) { DiffResult diffResult = xmlDiff.Compare(); Assert.AreEqual(identical, diffResult.Identical,xmlDiff.OptionalDescription); }
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; } } }
public static void XmlNotIdentical(XmlDiff xmlDiff) { XmlIdentical(xmlDiff, false); }
public static void XmlNotEquals(XmlDiff xmlDiff) { XmlEquals(xmlDiff, false); }
public static void XmlIdentical(XmlDiff xmlDiff) { XmlIdentical(xmlDiff, true); }
/// <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)); }
private DiffResult PerformDiff(TextReader reader1, TextReader reader2) { _xmlDiff = new XmlDiff(reader1, reader2); DiffResult result = _xmlDiff.Compare(); return result; }