joaquimcid / mb-unit

Automatically exported from code.google.com/p/mb-unit
0 stars 0 forks source link

Assert.Xml.AreEqual to support XML fragments with multiple root elements #823

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Assert.Xml.AreEqual("<a/><b/><c/>", "<a/><b/><c/>"); // No root element!

Cannot parse the actual XML fragment.

System.Xml.XmlException: There are multiple root elements. Line 1, position 6.
LineNumber: 1
LinePosition: 6
SourceUri:
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
Common\Xml\Parser.cs(68,0): at Gallio.Common.Xml.Parser.RunImpl(Options options)
Common\Xml\Parser.cs(45,0): at Gallio.Common.Xml.Parser.Run(String xml, Options 
options)

Original issue reported on code.google.com by Yann.Tre...@gmail.com on 27 Feb 2011 at 9:15

GoogleCodeExporter commented 8 years ago
New option "EncloseInRootElement" available.

[Test]
public void MyXmlTest()
{
    string expected = "<a/><b/><c/>"; // Multiple root elements!
    string actual = "<a/><b/><c/>";
    Assert.Xml.AreEqual(expected, actual, XmlOptions.Custom.EncloseInRootElement);
}

Original comment by Yann.Tre...@gmail.com on 28 Feb 2011 at 8:28