I have some codes heavily uses XElement
class to build segments of Xml, for example code looks like
XNamespace ns = "ns";
XElement myXml = new XElement(
ns + "filter",
new XElement(
ns + "and",
new XElement(
ns + "equals",
new XAttribute("name", "uid"),
new XElement(ns + "value", "some text"))));
It eventually spits out some Xml code equivalent to
<ns:filter>
<ns:and>
<ns:equals name="uid">
<ns:value>some text</ns:value>
</ns:equals>
</ns:and>
</ns:filter>
Now I need to unit test the logic go going through xpath, getting attributes and so on. I can always write my Linq-Xml to check the data, but it is very tedious since I need to unit test quite lot of similar codes.
I looked into fluent assertions
, it is very close, but it does not seem to be able to validate nested element's value.
Any one has some good recommendation?
Aucun commentaire:
Enregistrer un commentaire