Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

??? #65

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

??? #65

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 26 additions & 20 deletions tests/XPath2.Tests/XPathNavigatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
[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]");
/// <summary>
///
///
/// </summary>
[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]
Expand Down