Procházet zdrojové kódy

[System.Xml.Linq] Fix some bugs in the tests

Ensure we normalize both the expected and actual output
so they have the same line endings.
Alan McGovern před 13 roky
rodič
revize
730ffb72c7

+ 1 - 1
mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XElementTest.cs

@@ -1601,7 +1601,7 @@ namespace MonoTests.System.Xml.Linq
   <A />
   <D />
 </rt>";
-			Assert.AreEqual (xml, root.ToString ().Replace ("\r\n", "\n"), "#1");
+			Assert.AreEqual (xml.NormalizeNewline (), root.ToString ().NormalizeNewline (), "#1");
 		}
 		
 		private class EventHandler

+ 9 - 1
mcs/class/System.Xml.Linq/Test/System.Xml.XPath/ExtensionsTest.cs

@@ -41,6 +41,14 @@ using System.Collections.Generic;
 
 namespace MonoTests.System.Xml
 {
+	public static class Helpers
+	{
+		public static string NormalizeNewline(this string str)
+		{
+			return str.Replace("\r\n", "\n");
+		}
+	}
+
 	[TestFixture]
 	public class ExtensionsTest
 	{
@@ -419,7 +427,7 @@ namespace MonoTests.System.Xml
 			string ret = @"<one>
   <two>Some data.</two>
 </one>";
-			Assert.AreEqual (ret, nav.OuterXml.Replace ("\r\n", "\n"), "#1");
+			Assert.AreEqual (ret.NormalizeNewline (), nav.OuterXml.NormalizeNewline (), "#1");
 		}
 
 		[Test]

+ 1 - 1
mcs/class/System.Xml.Linq/Test/System.Xml.XPath/ExtensionsTest2.cs

@@ -660,7 +660,7 @@ namespace MonoTests.System.Xml
 </child1>
 <child2 />
 <child3 />";
-			Assert.AreEqual (result, n.OuterXml.Replace ("\r\n", "\n"), "#1");
+			Assert.AreEqual (result.NormalizeNewline (), n.OuterXml.NormalizeNewline (), "#1");
 		}
 
 		[Test] // bug #376191