diff --git a/tests/XPath2.Tests/XPathNavigatorTests.cs b/tests/XPath2.Tests/XPathNavigatorTests.cs index 9c4d367..c68fbce 100644 --- a/tests/XPath2.Tests/XPathNavigatorTests.cs +++ b/tests/XPath2.Tests/XPathNavigatorTests.cs @@ -366,37 +366,43 @@ public void XPath2Evaluate_FullPathWithAttributeSelection() /// - https://learn.microsoft.com/en-us/dotnet/api/system.xml.xpath.xpathnodeiterator.count?view=net-7.0 /// - Count = Gets the index of the last node in the selected set of nodes. /// - [Fact] - public void Issue59_XDocumentParse_XPath2SelectNodes_Count_Returns_TheIndexOfTheLastNode() + [Theory] + [InlineData("/report/brand", 5, 4)] + [InlineData("/report/brand[units > 20000]", 2, 1)] + public void Issue59_XDocumentParse_XPath2SelectNodes_Count_And_Enumerator_Is_Correct(string xpath, int expectedItemCount, int expectedCount) { // Arrange var xml = GetXml(); var navigator = XDocument.Parse(xml).CreateNavigator(); - // Act 1 - var brandSet = navigator.XPath2SelectNodes("/report/brand"); - - // Assert 1 - brandSet.Count.Should().Be(4); - - // Act 2 - var brandCount = (int)navigator.XPath2Evaluate("count(/report/brand)"); + // Act + var nodes = navigator.XPath2SelectNodes(xpath); - // Assert 2 - brandCount.Should().Be(5); + // Assert + nodes.Should().HaveCount(expectedItemCount); + nodes.Count.Should().Be(expectedCount); + } - // Act 3 - var highVolumeBrandSet = navigator.XPath2SelectNodes("/report/brand[units > 20000]"); + /// + /// + /// + /// + [Fact] + [InlineData(new[] { "/report/brand" })] + public void Issue59_XDocumentParse_XPath2SelectNodes_Count_And_CurrentPosition_Is_Correct(string[] names) + { + // Arrange + var xml = GetXml(); - // Assert 3 - highVolumeBrandSet.Count.Should().Be(1); + var navigator = XDocument.Parse(xml).CreateNavigator(); - // Act 4 - var highVolumeBrandCount = (int)navigator.XPath2Evaluate("count(/report/brand[units > 20000])"); + // Act + var nodes = navigator.XPath2SelectNodes("/report/brand"); - // Assert 4 - highVolumeBrandCount.Should().Be(2); + // Assert + nodes.Should().HaveCount(expectedItemCount); + nodes.Count.Should().Be(expectedCount); } [Fact]