[System.Xml.Linq] Fix some bugs in the tests
authorAlan McGovern <alan@xamarin.com>
Thu, 19 Jul 2012 12:49:50 +0000 (13:49 +0100)
committerAlan McGovern <alan@xamarin.com>
Thu, 19 Jul 2012 13:01:32 +0000 (14:01 +0100)
Ensure we normalize both the expected and actual output
so they have the same line endings.

mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XElementTest.cs
mcs/class/System.Xml.Linq/Test/System.Xml.XPath/ExtensionsTest.cs
mcs/class/System.Xml.Linq/Test/System.Xml.XPath/ExtensionsTest2.cs

index 3a21ee2471893a4356ff6455c4e2156a71640f4f..14af85484afb82bfac4354ac29d54be0aa1afbaa 100644 (file)
@@ -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
index c86f06b13ef2b2b1e3a4e4cf345165a23b3181ed..cbe89abb77a0bff973ec918434df7043a78dbf2e 100644 (file)
@@ -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]
index f099ef433de8eb0ebbc59a0f404cd470f7404d84..72adeb74056601fd085b2df21108600b7ce2f9d0 100644 (file)
@@ -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