Skip to content

XDocument BeEquivalentTo assertion returns incorrect path to node #1166

@SebDani

Description

@SebDani

Description

XDocument BeEquivalentTo assertion returns incorrect path to node

Complete minimal example reproducing the issue

// Arrange
XDocument expected = XDocument.Parse("<?xml version=\"1.0\" encoding=\"utf-8\"?><root><a><aa><aaa attr=\"x\"/></aa></a><b><bb id=\"\"/></b></root>");
XDocument actual = XDocument.Parse("<?xml version=\"1.0\" encoding=\"utf-8\"?><root><a><aa><aaa attr=\"x\"/></aa></a><b><bb id=\"value\"/></b></root>");

// Assert
actual.Should().BeEquivalentTo(expected);

Expected behavior:

Assertion should fail with the following message:

Expected attribute "id" at "/root/b/bb" to have value "", but found "value".

Actual behavior:

Assertion fails with the following message:

Expected attribute "id" at "/root/a/b/bb" to have value "", but found "value".

The 'a' node is not in the correct path to the difference between the two xmls.

Versions

  • Version of Fluent Assertions: 5.9.0
  • .NET framework 4.7

Additional Information

If the attr attributes are removed, that is, the xml is modified to the following format:

XDocument expected = XDocument.Parse("<?xml version=\"1.0\" encoding=\"utf-8\"?><root><a><aa><aaa/></aa></a><b><bb id=\"\"/></b></root>");
XDocument actual = XDocument.Parse("<?xml version=\"1.0\" encoding=\"utf-8\"?><root><a><aa><aaa/></aa></a><b><bb id=\"value\"/></b></root>");

then the test behaves as expected, the message is:

Expected attribute "id" at "/root/b/bb" to have value "", but found "value".

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions