From: <bo...@us...> - 2007-04-23 16:09:50
|
Revision: 200 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=200&view=rev Author: bodewig Date: 2007-04-23 08:47:38 -0700 (Mon, 23 Apr 2007) Log Message: ----------- modernize NUnit usage: Assertion -> Assert Modified Paths: -------------- trunk/xmlunit/src/csharp/XmlAssertion.cs trunk/xmlunit/tests/csharp/DiffConfigurationTests.cs trunk/xmlunit/tests/csharp/DiffResultTests.cs trunk/xmlunit/tests/csharp/DifferenceTests.cs trunk/xmlunit/tests/csharp/ValidatorTests.cs trunk/xmlunit/tests/csharp/XPathTests.cs trunk/xmlunit/tests/csharp/XmlAssertionTests.cs trunk/xmlunit/tests/csharp/XmlDiffTests.cs trunk/xmlunit/tests/csharp/XmlInputTests.cs trunk/xmlunit/tests/csharp/XsltTests.cs Modified: trunk/xmlunit/src/csharp/XmlAssertion.cs =================================================================== --- trunk/xmlunit/src/csharp/XmlAssertion.cs 2007-04-23 15:18:56 UTC (rev 199) +++ trunk/xmlunit/src/csharp/XmlAssertion.cs 2007-04-23 15:47:38 UTC (rev 200) @@ -2,7 +2,7 @@ using NUnit.Framework; using System.IO; - public class XmlAssertion : Assertion { + public class XmlAssertion : Assert { public static void AssertXmlEquals(TextReader controlTextReader, TextReader testTextReader) { AssertXmlEquals(new XmlDiff(controlTextReader, testTextReader)); } @@ -37,7 +37,11 @@ private static void AssertXmlEquals(XmlDiff xmlDiff, bool equalOrNot) { DiffResult diffResult = xmlDiff.Compare(); - Assertion.AssertEquals(diffResult.StringValue, equalOrNot, diffResult.Equal); + if (equalOrNot) { + IsTrue(diffResult.Equal, diffResult.StringValue); + } else { + IsFalse(diffResult.Equal, diffResult.StringValue); + } } public static void AssertXmlIdentical(XmlDiff xmlDiff) { @@ -50,7 +54,11 @@ private static void AssertXmlIdentical(XmlDiff xmlDiff, bool identicalOrNot) { DiffResult diffResult = xmlDiff.Compare(); - AssertEquals(xmlDiff.OptionalDescription, identicalOrNot, diffResult.Identical); + if (identicalOrNot) { + IsTrue(diffResult.Identical, xmlDiff.OptionalDescription); + } else { + IsFalse(diffResult.Identical, xmlDiff.OptionalDescription); + } } public static void AssertXmlValid(string someXml) { @@ -75,7 +83,7 @@ } public static void AssertXmlValid(Validator validator) { - AssertEquals(validator.ValidationMessage, true, validator.IsValid); + IsTrue(validator.IsValid, validator.ValidationMessage); } public static void AssertXPathExists(string anXPathExpression, string inXml) { @@ -88,7 +96,7 @@ public static void AssertXPathExists(string anXPathExpression, XmlInput inXml) { XPath xpath = new XPath(anXPathExpression); - AssertEquals(true, xpath.XPathExists(inXml)); + AreEqual(true, xpath.XPathExists(inXml)); } public static void AssertXPathEvaluatesTo(string anXPathExpression, string inXml, @@ -104,7 +112,7 @@ public static void AssertXPathEvaluatesTo(string anXPathExpression, XmlInput inXml, string expectedValue) { XPath xpath = new XPath(anXPathExpression); - AssertEquals(expectedValue, xpath.EvaluateXPath(inXml)); + AreEqual(expectedValue, xpath.EvaluateXPath(inXml)); } public static void AssertXslTransformResults(string xslTransform, string xmlToTransform, string expectedResult) { Modified: trunk/xmlunit/tests/csharp/DiffConfigurationTests.cs =================================================================== --- trunk/xmlunit/tests/csharp/DiffConfigurationTests.cs 2007-04-23 15:18:56 UTC (rev 199) +++ trunk/xmlunit/tests/csharp/DiffConfigurationTests.cs 2007-04-23 15:47:38 UTC (rev 200) @@ -14,16 +14,16 @@ [Test] public void DefaultConfiguredWithGenericDescription() { DiffConfiguration diffConfiguration = new DiffConfiguration(); - Assertion.AssertEquals(DiffConfiguration.DEFAULT_DESCRIPTION, + Assert.AreEqual(DiffConfiguration.DEFAULT_DESCRIPTION, diffConfiguration.Description); - Assertion.AssertEquals(DiffConfiguration.DEFAULT_DESCRIPTION, + Assert.AreEqual(DiffConfiguration.DEFAULT_DESCRIPTION, new XmlDiff("", "").OptionalDescription); } [Test] public void DefaultConfiguredToUseValidatingParser() { DiffConfiguration diffConfiguration = new DiffConfiguration(); - Assertion.AssertEquals(DiffConfiguration.DEFAULT_USE_VALIDATING_PARSER, + Assert.AreEqual(DiffConfiguration.DEFAULT_USE_VALIDATING_PARSER, diffConfiguration.UseValidatingParser); FileStream controlFileStream = File.Open(ValidatorTests.VALID_FILE, @@ -34,7 +34,7 @@ XmlDiff diff = new XmlDiff(new StreamReader(controlFileStream), new StreamReader(testFileStream)); diff.Compare(); - Assertion.Fail("Expected validation failure"); + Assert.Fail("Expected validation failure"); } catch (XmlSchemaException e) { string message = e.Message; // to prevent 'unused variable' compiler warning } finally { @@ -45,7 +45,7 @@ [Test] public void CanConfigureNotToUseValidatingParser() { DiffConfiguration diffConfiguration = new DiffConfiguration(false); - Assertion.AssertEquals(false, diffConfiguration.UseValidatingParser); + Assert.AreEqual(false, diffConfiguration.UseValidatingParser); FileStream controlFileStream = File.Open(ValidatorTests.VALID_FILE, FileMode.Open, FileAccess.Read); @@ -57,7 +57,7 @@ diffConfiguration); diff.Compare(); } catch (XmlSchemaException e) { - Assertion.Fail("Unexpected validation failure: " + e.Message); + Assert.Fail("Unexpected validation failure: " + e.Message); } finally { controlFileStream.Close(); testFileStream.Close(); @@ -66,7 +66,7 @@ [Test] public void DefaultConfiguredWithWhitespaceHandlingAll() { DiffConfiguration diffConfiguration = new DiffConfiguration(); - Assertion.AssertEquals(WhitespaceHandling.All, diffConfiguration.WhitespaceHandling); + Assert.AreEqual(WhitespaceHandling.All, diffConfiguration.WhitespaceHandling); PerformAssertion(xmlWithoutWhitespace, xmlWithWhitespaceElement, false); PerformAssertion(xmlWithoutWhitespace, xmlWithoutWhitespaceElement, false); @@ -85,8 +85,8 @@ PerformAssertion(diff, assertion); } private void PerformAssertion(XmlDiff diff, bool assertion) { - Assertion.AssertEquals(assertion, diff.Compare().Equal); - Assertion.AssertEquals(assertion, diff.Compare().Identical); + Assert.AreEqual(assertion, diff.Compare().Equal); + Assert.AreEqual(assertion, diff.Compare().Identical); } [Test] public void CanConfigureWhitespaceHandlingSignificant() { Modified: trunk/xmlunit/tests/csharp/DiffResultTests.cs =================================================================== --- trunk/xmlunit/tests/csharp/DiffResultTests.cs 2007-04-23 15:18:56 UTC (rev 199) +++ trunk/xmlunit/tests/csharp/DiffResultTests.cs 2007-04-23 15:47:38 UTC (rev 200) @@ -18,25 +18,25 @@ } [Test] public void NewDiffResultIsEqualAndIdentical() { - Assertion.AssertEquals(true, _result.Identical); - Assertion.AssertEquals(true, _result.Equal); - Assertion.AssertEquals("Identical", _result.StringValue); + Assert.AreEqual(true, _result.Identical); + Assert.AreEqual(true, _result.Equal); + Assert.AreEqual("Identical", _result.StringValue); } [Test] public void NotEqualOrIdenticalAfterMajorDifferenceFound() { _result.DifferenceFound(_diff, _majorDifference); - Assertion.AssertEquals(false, _result.Identical); - Assertion.AssertEquals(false, _result.Equal); - Assertion.AssertEquals(_diff.OptionalDescription + Assert.AreEqual(false, _result.Identical); + Assert.AreEqual(false, _result.Equal); + Assert.AreEqual(_diff.OptionalDescription + Environment.NewLine + _majorDifference.ToString(), _result.StringValue); } [Test] public void NotIdenticalButEqualAfterMinorDifferenceFound() { _result.DifferenceFound(_diff, _minorDifference); - Assertion.AssertEquals(false, _result.Identical); - Assertion.AssertEquals(true, _result.Equal); - Assertion.AssertEquals(_diff.OptionalDescription + Assert.AreEqual(false, _result.Identical); + Assert.AreEqual(true, _result.Equal); + Assert.AreEqual(_diff.OptionalDescription + Environment.NewLine + _minorDifference.ToString(), _result.StringValue); } Modified: trunk/xmlunit/tests/csharp/DifferenceTests.cs =================================================================== --- trunk/xmlunit/tests/csharp/DifferenceTests.cs 2007-04-23 15:18:56 UTC (rev 199) +++ trunk/xmlunit/tests/csharp/DifferenceTests.cs 2007-04-23 15:47:38 UTC (rev 200) @@ -9,16 +9,15 @@ [SetUp] public void CreateMinorDifference() { DifferenceType id = DifferenceType.ATTR_SEQUENCE_ID; - Assertion.AssertEquals(false, Differences.isMajorDifference(id)); + Assert.IsFalse(Differences.isMajorDifference(id)); minorDifference = new Difference(id); } [Test] public void ToStringContainsId() { string commentDifference = minorDifference.ToString(); string idValue = "type: " + (int)DifferenceType.ATTR_SEQUENCE_ID; - Assertion.AssertEquals("contains " + idValue, - true, - commentDifference.IndexOfAny(idValue.ToCharArray()) > 0); + Assert.IsTrue(commentDifference.IndexOfAny(idValue.ToCharArray()) > 0, + "contains " + idValue); } } } Modified: trunk/xmlunit/tests/csharp/ValidatorTests.cs =================================================================== --- trunk/xmlunit/tests/csharp/ValidatorTests.cs 2007-04-23 15:18:56 UTC (rev 199) +++ trunk/xmlunit/tests/csharp/ValidatorTests.cs 2007-04-23 15:47:38 UTC (rev 200) @@ -19,7 +19,7 @@ FileStream input = File.Open(file, FileMode.Open, FileAccess.Read); try { Validator validator = new Validator(new XmlInput(new StreamReader(input))); - Assertion.AssertEquals(expected, validator.IsValid); + Assert.AreEqual(expected, validator.IsValid); return validator; } finally { input.Close(); @@ -29,7 +29,7 @@ [Test] public void XsdInvalidFileIsNotValid() { Validator validator = PerformAssertion(INVALID_FILE, false); string expected = "The element 'http://www.publishing.org:Book' has incomplete content"; - Assertion.AssertEquals(true, + Assert.AreEqual(true, validator.ValidationMessage.StartsWith(expected)); } } Modified: trunk/xmlunit/tests/csharp/XPathTests.cs =================================================================== --- trunk/xmlunit/tests/csharp/XPathTests.cs 2007-04-23 15:18:56 UTC (rev 199) +++ trunk/xmlunit/tests/csharp/XPathTests.cs 2007-04-23 15:47:38 UTC (rev 200) @@ -13,39 +13,39 @@ private static readonly string COUNT_XPATH = "count(//b)"; [Test] public void XpathExistsTrueForXpathThatExists() { XPath xpath = new XPath(EXISTENT_XPATH); - Assertion.AssertEquals(true, + Assert.AreEqual(true, xpath.XPathExists(SIMPLE_XML)); } [Test] public void XpathExistsFalseForUnmatchedExpression() { XPath xpath = new XPath(NONEXISTENT_XPATH); - Assertion.AssertEquals(false, + Assert.AreEqual(false, xpath.XPathExists(SIMPLE_XML)); } [Test] public void XpathEvaluatesToTextValueForSimpleString() { string expectedValue = "one two"; XPath xpath = new XPath(EXISTENT_XPATH); - Assertion.AssertEquals(expectedValue, + Assert.AreEqual(expectedValue, xpath.EvaluateXPath(SIMPLE_XML)); } [Test] public void XpathEvaluatesToEmptyStringForUnmatchedExpression() { string expectedValue = ""; XPath xpath = new XPath(NONEXISTENT_XPATH); - Assertion.AssertEquals(expectedValue, + Assert.AreEqual(expectedValue, xpath.EvaluateXPath(SIMPLE_XML)); } [Test] public void XpathEvaluatesCountExpression() { string expectedValue = "2"; XPath xpath = new XPath(COUNT_XPATH); - Assertion.AssertEquals(expectedValue, + Assert.AreEqual(expectedValue, xpath.EvaluateXPath(MORE_COMPLEX_XML)); } [Test] public void XpathEvaluatesMultiNodeExpression() { string expectedValue = "onetwo"; XPath xpath = new XPath(MULTI_NODE_XPATH); - Assertion.AssertEquals(expectedValue, + Assert.AreEqual(expectedValue, xpath.EvaluateXPath(MORE_COMPLEX_XML)); } } Modified: trunk/xmlunit/tests/csharp/XmlAssertionTests.cs =================================================================== --- trunk/xmlunit/tests/csharp/XmlAssertionTests.cs 2007-04-23 15:18:56 UTC (rev 199) +++ trunk/xmlunit/tests/csharp/XmlAssertionTests.cs 2007-04-23 15:47:38 UTC (rev 200) @@ -27,7 +27,7 @@ new DiffConfiguration(description)); XmlAssertion.AssertXmlIdentical(diff); } catch (NUnit.Framework.AssertionException e) { - Assertion.AssertEquals(true, e.Message.StartsWith(description)); + Assert.IsTrue(e.Message.StartsWith(description)); } } @@ -38,7 +38,7 @@ new DiffConfiguration(description)); XmlAssertion.AssertXmlEquals(diff); } catch (NUnit.Framework.AssertionException e) { - Assertion.AssertEquals(true, e.Message.StartsWith(description)); + Assert.AreEqual(true, e.Message.StartsWith(description)); } } @@ -55,7 +55,7 @@ StreamReader reader = GetStreamReader(ValidatorTests.INVALID_FILE); try { XmlAssertion.AssertXmlValid(reader); - Assertion.Fail("Expected assertion failure"); + Assert.Fail("Expected assertion failure"); } catch(AssertionException e) { AvoidUnusedVariableCompilerWarning(e); } finally { @@ -79,7 +79,7 @@ try { XmlAssertion.AssertXPathExists("//star[@name='alpha centauri']", MY_SOLAR_SYSTEM); - Assertion.Fail("Expected assertion failure"); + Assert.Fail("Expected assertion failure"); } catch (AssertionException e) { AvoidUnusedVariableCompilerWarning(e); } @@ -131,7 +131,7 @@ try { XmlAssertion.AssertXslTransformResults(xslt, xmlToTransform, expectedXml); exceptionExpected = false; - Assertion.Fail("Expected dog not cat!"); + Assert.Fail("Expected dog not cat!"); } catch (AssertionException e) { AvoidUnusedVariableCompilerWarning(e); if (!exceptionExpected) { Modified: trunk/xmlunit/tests/csharp/XmlDiffTests.cs =================================================================== --- trunk/xmlunit/tests/csharp/XmlDiffTests.cs 2007-04-23 15:18:56 UTC (rev 199) +++ trunk/xmlunit/tests/csharp/XmlDiffTests.cs 2007-04-23 15:47:38 UTC (rev 200) @@ -10,14 +10,14 @@ [Test] public void EqualResultForSameReader() { TextReader reader = new StringReader("<empty/>"); DiffResult result = PerformDiff(reader, reader); - Assertion.AssertEquals(true, result.Equal); + Assert.AreEqual(true, result.Equal); } [Test] public void SameResultForTwoInvocations() { TextReader reader = new StringReader("<empty/>"); DiffResult result1 = PerformDiff(reader, reader); DiffResult result2 = _xmlDiff.Compare(); - Assertion.AssertSame(result1, result2); + Assert.AreSame(result1, result2); } @@ -26,7 +26,7 @@ TextReader reader2 = new StringReader(input2); DiffResult result = PerformDiff(reader1, reader2); string msg = "comparing " + input1 + " to " + input2 + ": " + result.Difference; - Assertion.AssertEquals(msg, expected, result.Equal); + Assert.AreEqual(expected, result.Equal); } private void AssertExpectedResult(string[] inputs1, string[] inputs2, bool expected) { Modified: trunk/xmlunit/tests/csharp/XmlInputTests.cs =================================================================== --- trunk/xmlunit/tests/csharp/XmlInputTests.cs 2007-04-23 15:18:56 UTC (rev 199) +++ trunk/xmlunit/tests/csharp/XmlInputTests.cs 2007-04-23 15:47:38 UTC (rev 200) @@ -18,13 +18,13 @@ [Test] public void StringInputTranslatesToXmlReader() { XmlInput input = new XmlInput(INPUT); string actual = ReadOuterXml(input.CreateXmlReader()); - Assertion.AssertEquals(_expected, actual); + Assert.AreEqual(_expected, actual); } [Test] public void TextReaderInputTranslatesToXmlReader() { XmlInput input = new XmlInput(new StringReader(INPUT)); string actual = ReadOuterXml(input.CreateXmlReader()); - Assertion.AssertEquals(_expected, actual); + Assert.AreEqual(_expected, actual); } [Test] public void StreamInputTranslatesToXmlReader() { @@ -36,7 +36,7 @@ XmlInput input = new XmlInput(stream); string actual = ReadOuterXml(input.CreateXmlReader()); try { - Assertion.AssertEquals(_expected, actual); + Assert.AreEqual(_expected, actual); } finally { writer.Close(); } @@ -53,32 +53,32 @@ [Test] public void NotEqualsNull() { XmlInput input = new XmlInput(INPUT); - Assertion.AssertEquals(false, input.Equals(null)); + Assert.AreEqual(false, input.Equals(null)); } [Test] public void NotEqualsADifferentClass() { XmlInput input = new XmlInput(INPUT); - Assertion.AssertEquals(false, input.Equals(INPUT)); + Assert.AreEqual(false, input.Equals(INPUT)); } [Test] public void EqualsSelf() { XmlInput input = new XmlInput(INPUT); - Assertion.AssertEquals(input, input); + Assert.AreEqual(input, input); } [Test] public void EqualsCopyOfSelf() { XmlInput input = new XmlInput(INPUT); - Assertion.AssertEquals(new XmlInput(INPUT), input); + Assert.AreEqual(new XmlInput(INPUT), input); } [Test] public void HashCodeEqualsHashCodeOfInput() { XmlInput input = new XmlInput(INPUT); - Assertion.AssertEquals(INPUT.GetHashCode(), input.GetHashCode()); + Assert.AreEqual(INPUT.GetHashCode(), input.GetHashCode()); } [Test] public void HashCodeEqualsHashCodeOfCopy() { XmlInput input = new XmlInput(INPUT); - Assertion.AssertEquals(new XmlInput(INPUT).GetHashCode(), input.GetHashCode()); + Assert.AreEqual(new XmlInput(INPUT).GetHashCode(), input.GetHashCode()); } } Modified: trunk/xmlunit/tests/csharp/XsltTests.cs =================================================================== --- trunk/xmlunit/tests/csharp/XsltTests.cs 2007-04-23 15:18:56 UTC (rev 199) +++ trunk/xmlunit/tests/csharp/XsltTests.cs 2007-04-23 15:47:38 UTC (rev 200) @@ -27,8 +27,8 @@ Xslt xslt = new Xslt(IDENTITY_TRANSFORM); string input = "<qwerty>uiop</qwerty>"; string output = new string(input.ToCharArray()); - Assertion.AssertEquals(output, xslt.Transform(input).AsString()); - Assertion.AssertEquals(output, xslt.Transform(input).AsString()); + Assert.AreEqual(output, xslt.Transform(input).AsString()); + Assert.AreEqual(output, xslt.Transform(input).AsString()); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |