Skip to content

Commit

Permalink
Merge pull request #2649 from FirelyTeam/bugfix/missing-another-return
Browse files Browse the repository at this point in the history
Missed another return in SourceNodeComparator
  • Loading branch information
mmsmits authored Jan 3, 2024
2 parents 486659c + 67f2078 commit 2fcb466
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Hl7.Fhir.Base/ElementModel/SourceNodeComparator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static TreeComparisonResult IsEqualTo(this ISourceNode expected, ISourceN
if (expected.Name != actual.Name)
return TreeComparisonResult.Fail(actual.Location, $"name: was '{actual.Name}', expected '{expected.Name}'");
if (expected.Text != actual.Text) return TreeComparisonResult.Fail(actual.Location, $"value: was '{actual.Text}', expected '{expected.Text}'");
if (expected.Location != actual.Location) TreeComparisonResult.Fail(actual.Location, $"Path: was '{actual.Location}', expected '{expected.Location}'");
if (expected.Location != actual.Location) return TreeComparisonResult.Fail(actual.Location, $"Path: was '{actual.Location}', expected '{expected.Location}'");

// Ignore ordering (only relevant to xml)
var childrenExp = expected.Children().OrderBy(e => e.Name);
Expand Down
23 changes: 23 additions & 0 deletions src/Hl7.Fhir.ElementModel.Shared.Tests/SourceNodeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,29 @@ public void CompareNodesTest()
result.Success.Should().BeFalse();
result.Details.Should().Be("number of children was different");


//change node location
node2 = SourceNode.Node("Patient",
SourceNode.Node("name",
SourceNode.Node("family", SourceNode.Valued("family", "van de Heuvel")),
SourceNode.Node("given", SourceNode.Valued("given", "Pieter"))
),
SourceNode.Node("name")
);

var enumerator1 = node1.Children().GetEnumerator();
var enumerator2 = node2.Children().GetEnumerator();

enumerator1.MoveNext();
var child1 = enumerator1.Current;
enumerator2.MoveNext();
enumerator2.MoveNext();
var child2 = enumerator2.Current;

result = child1.IsEqualTo(child2);
result.Success.Should().BeFalse();
result.Details.Should().Be("Path: was 'Patient.name[1]', expected 'Patient.name[0]'");

}

}
Expand Down

0 comments on commit 2fcb466

Please sign in to comment.