private void AssertExpectedIdenticalResult(string input1, string input2, bool expected) { DiffResult result = GetDiffResult(input1, input2); string msg = "Identical: comparing " + input1 + " to " + input2 + ": " + result.Difference; OldAssert.AreEqual(expected, result.Identical, msg); }
/// <summary> /// Asserts that the flattened String obtained by executing an Xpath on some XML is a particular value /// </summary> /// <param name="anXPathExpression">An X path expression.</param> /// <param name="inXml">The XML to test.</param> /// <param name="expectedValue">The expected value.</param> public static void XPathEvaluatesTo(string anXPathExpression, XmlInput inXml, string expectedValue) { XPath xpath = new XPath(anXPathExpression); OldAssert.AreEqual(expectedValue, xpath.EvaluateXPath(inXml)); }
[SetUp] public void CreateMinorDifference() { DifferenceType id = DifferenceType.AttributeSequence; OldAssert.AreEqual(false, Differences.IsMajorDifference(id)); minorDifference = new Difference(id); }
[Test] public void XpathExistsFalseForUnmatchedExpression() { XPath xpath = new XPath(NONEXISTENT_XPATH); OldAssert.AreEqual(false, xpath.XPathExists(SIMPLE_XML)); }
[Test] public void XpathExistsTrueForXpathThatExists() { XPath xpath = new XPath(EXISTENT_XPATH); OldAssert.AreEqual(true, xpath.XPathExists(SIMPLE_XML)); }
[Test] public void TextReaderInputTranslatesToXmlReader() { XmlInput input = new XmlInput(new StringReader(INPUT)); string actual = ReadOuterXml(input.CreateXmlReader()); OldAssert.AreEqual(_expected, actual); }
public void EqualResultForSameReader() { TextReader reader = new StringReader("<empty/>"); DiffResult result = PerformDiff(reader, reader); OldAssert.AreEqual(true, result.Equal); }
[Test] public void XpathEvaluatesMultiNodeExpression() { string expectedValue = "onetwo"; XPath xpath = new XPath(MULTI_NODE_XPATH); OldAssert.AreEqual(expectedValue, xpath.EvaluateXPath(MORE_COMPLEX_XML)); }
[Test] public void XpathEvaluatesCountExpression() { string expectedValue = "2"; XPath xpath = new XPath(COUNT_XPATH); OldAssert.AreEqual(expectedValue, xpath.EvaluateXPath(MORE_COMPLEX_XML)); }
[Test] public void XpathEvaluatesToEmptyStringForUnmatchedExpression() { string expectedValue = ""; XPath xpath = new XPath(NONEXISTENT_XPATH); OldAssert.AreEqual(expectedValue, xpath.EvaluateXPath(SIMPLE_XML)); }
[Test] public void XpathEvaluatesToTextValueForSimpleString() { string expectedValue = "one two"; XPath xpath = new XPath(EXISTENT_XPATH); OldAssert.AreEqual(expectedValue, xpath.EvaluateXPath(SIMPLE_XML)); }
[Test] public void CanPerformTransform() { Xslt xslt = new Xslt(IDENTITY_TRANSFORM); string input = "<qwerty>uiop</qwerty>"; string output = new string(input.ToCharArray()); OldAssert.AreEqual(output, xslt.Transform(input).AsString()); OldAssert.AreEqual(output, xslt.Transform(input).AsString()); }
[Test] public void NotIdenticalButEqualAfterMinorDifferenceFound() { _result.DifferenceFound(_diff, _minorDifference); OldAssert.AreEqual(false, _result.Identical); OldAssert.AreEqual(true, _result.Equal); OldAssert.AreEqual(_diff.OptionalDescription + Environment.NewLine + _minorDifference.ToString(), _result.StringValue); }
/// <summary> /// Verifies that the property value <see cref="ICollection.Count"/> /// of <paramref name="actual"/> is equal to <paramref name="expected"/>. /// </summary> /// <param name="expected"> /// Expected value. /// </param> /// <param name="actual"> /// Instance containing the tested value. /// </param> public static void AreCountEqual( Int32 expected, ICollection actual ) { OldAssert.IsNotNull(actual); OldAssert.AreEqual(expected, actual.Count, "Property Count not equal"); }
private Validator PerformAssertion(Stream input, bool expected) { using (input) { Validator validator = new Validator(new XmlInput(new StreamReader(input))); OldAssert.AreEqual(expected, validator.IsValid, validator.ValidationMessage); return(validator); } }
/// <summary> /// Verifies that the property value <see cref="ICollection.IsSynchronized"/> /// of <paramref name="actual"/> is equal to <paramref name="expected"/>. /// </summary> /// <param name="expected"> /// Expected value. /// </param> /// <param name="actual"> /// Instance containing the tested value. /// </param> public static void AreIsSynchronizedEqual( Boolean expected, ICollection actual ) { OldAssert.IsNotNull(actual); OldAssert.AreEqual(expected, actual.IsSynchronized, "Property IsSynchronized not equal"); }
[Test] public void DefaultConfiguredWithGenericDescription() { DiffConfiguration diffConfiguration = new DiffConfiguration(); OldAssert.AreEqual(DiffConfiguration.DEFAULT_DESCRIPTION, diffConfiguration.Description); OldAssert.AreEqual(DiffConfiguration.DEFAULT_DESCRIPTION, new XmlDiff("", "").OptionalDescription); }
[Test] public void ToStringContainsId() { string commentDifference = minorDifference.ToString(); string idValue = "type: " + (int)DifferenceType.AttributeSequence; OldAssert.AreEqual( true, commentDifference.IndexOfAny(idValue.ToCharArray()) > 0, "contains " + idValue); }
/// <summary> /// Verifies that the <see cref="ICollection.Count"/> property /// is synchronized with the number of iterated elements. /// </summary> /// <param name="col"> /// Collection to test. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="col"/> is a null reference (Nothing in Visual Basic). /// </exception> public static void IsCountCorrect(ICollection col) { if (col == null) { throw new ArgumentNullException("col"); } int i = 0; foreach (Object o in col) { ++i; } OldAssert.AreEqual(i, col.Count); }
/// <summary> /// Verifies that the property value <see cref="ICollection.SyncRoot"/> /// of <paramref name="actual"/> is equal to <paramref name="expected"/>. /// </summary> /// <param name="expected"> /// Expected value. /// </param> /// <param name="actual"> /// Instance containing the tested value. /// </param> public static void AreSyncRootEqual( Object expected, ICollection actual ) { if (expected == null && actual == null) { return; } OldAssert.IsNotNull(expected); OldAssert.IsNotNull(actual); OldAssert.AreEqual(expected, actual.SyncRoot, "Property SyncRoot not equal"); }
[Test] public void StreamInputTranslatesToXmlReader() { MemoryStream stream = new MemoryStream(); StreamWriter writer = new StreamWriter(stream, Encoding.Default); writer.WriteLine(INPUT); writer.Flush(); stream.Seek(0, SeekOrigin.Begin); XmlInput input = new XmlInput(stream); string actual = ReadOuterXml(input.CreateXmlReader()); try { OldAssert.AreEqual(_expected, actual); } finally { writer.Close(); } }
public static void AreEqual(int[] expected, int[] actual) { if (expected == null && actual == null) { return; } OldAssert.IsNotNull(expected); OldAssert.IsNotNull(actual); OldAssert.AreEqual(expected.Rank, actual.Rank, "Rank are not equal"); OldAssert.AreEqual(expected.Length, actual.Length); for (int i = 0; i < expected.Length; ++i) { OldAssert.AreEqual(expected[i], actual[i]); } }
/// <summary> /// Asserts that some XML is valid. /// </summary> /// <param name="validator">A <see cref="Validator"/> object containing the XML to validate.</param> public static void XmlValid(Validator validator) { OldAssert.AreEqual(true, validator.IsValid, validator.ValidationMessage); }
/// <summary> /// Asserts that two pieces of XML are identical (or not) given their diff and a boolean value /// </summary> /// <param name="xmlDiff">The XML diff.</param> /// <param name="identical">if set to <c>true</c> the assert passes if the XML is identical. /// if <c>false</c>, the assert passes if the XML is not identical.</param> private static void XmlIdentical(XmlDiff xmlDiff, bool identical) { DiffResult diffResult = xmlDiff.Compare(); OldAssert.AreEqual(identical, diffResult.Identical, xmlDiff.OptionalDescription); }
/// <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)); }
[Test] public void EqualsSelf() { XmlInput input = new XmlInput(INPUT); OldAssert.AreEqual(input, input); }
[Test] public void NotEqualsADifferentClass() { XmlInput input = new XmlInput(INPUT); OldAssert.AreEqual(false, input.Equals(INPUT)); }
[Test] public void NewDiffResultIsEqualAndIdentical() { OldAssert.AreEqual(true, _result.Identical); OldAssert.AreEqual(true, _result.Equal); OldAssert.AreEqual("Identical", _result.StringValue); }
[Test] public void NotEqualsNull() { XmlInput input = new XmlInput(INPUT); OldAssert.AreEqual(false, input.Equals(null)); }
/// <summary> /// Assert that an XPath expression matches at least one node in someXml /// </summary> /// <param name="anXPathExpression">An X path expression.</param> /// <param name="inXml">The XML to test.</param> public static void XPathExists(string anXPathExpression, XmlInput inXml) { XPath xpath = new XPath(anXPathExpression); OldAssert.AreEqual(true, xpath.XPathExists(inXml)); }