hardywang
hardywang

Reputation: 5162

How to test XElement's child element's attributes, values by using Fluent Assertions?

Let's say I have an XElement object, which represents Xml like

<modification name="givenName" operation="add" xmlns="urn:oasis:names:tc:DSML:2:0:core">
    <value>Changed name</value>
    <child id="abc">Some dummy value</child>
</modification>

How can I test The <value> element's value is "Changed name", and <child> element has attribute id "abc", and value "Some dummy value"?

Upvotes: 0

Views: 309

Answers (1)

Dennis Doomen
Dennis Doomen

Reputation: 8889

element.Should().HaveElement("value").Which.Should().HaveValue("Changed name");
element.Should().HaveElement("child").Which.Should().HaveAttribute("id", "abc").And.HaveValue("Some dummy value");

Upvotes: 1

Related Questions