[Sys.Security] don't expect XmlNode.ChildNodes returns the same instance.
authorAtsushi Eno <atsushieno@gmail.com>
Wed, 4 Feb 2015 04:56:29 +0000 (12:56 +0800)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 20 Feb 2015 19:31:39 +0000 (03:31 +0800)
It did in mono implementation. It doesn't on referencesource.

mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXsltTransformTest.cs

index cc44b12d4c509032082f2cacd47028204553bb94..03b4f215b84c4530d73abb8f5d26f75ccfe2efb6 100644 (file)
@@ -10,6 +10,7 @@
 //
 
 using System;
+using System.Collections;
 using System.IO;
 using System.Security.Cryptography;
 using System.Security.Cryptography.Xml;
@@ -243,7 +244,19 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                        XmlDocument doc = GetXslDoc ();
                        transform.LoadInnerXml (doc.DocumentElement.ChildNodes);
                        XmlNodeList xnl = transform.UnprotectedGetInnerXml ();
-                       Assert.AreEqual (doc.DocumentElement.ChildNodes, xnl, "LoadInnerXml");
+                       AssertNodeListEqual (doc.DocumentElement.ChildNodes, xnl, "LoadInnerXml");
+               }
+               
+               void AssertNodeListEqual (XmlNodeList nl1, XmlNodeList nl2, string label)
+               {
+                       Assert.AreEqual (nl1.Count, nl2.Count, label + ": node count");
+                       IEnumerator e1, e2;
+                       int i;
+                       for (i = 0, e1 = nl1.GetEnumerator (), e2 = nl2.GetEnumerator (); e1.MoveNext (); i++) {
+                               Assert.IsTrue (e2.MoveNext (), label + " : nl2.MoveNext");
+                               Assert.AreEqual (e1.Current, e2.Current, label + " : node at " + i);
+                       }
+                       Assert.IsFalse (e2.MoveNext (), label + " : nl2 has extras");
                }
 
                [Test]