Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,13 @@ public bool MatchesFilter(string testNodeFullPath, PropertyBag filterablePropert
if (currentFragmentIndex >= _filters.Count)
{
// Note: The regex for ** is .*.*, so we match against such a value expression.
return currentFragmentIndex > 0 && _filters.Last() is ValueExpression { Value: ".*.*" };
FilterExpression lastFilter = _filters.Last();
if (lastFilter is ValueAndPropertyExpression valueAndPropertyExpression)
{
lastFilter = valueAndPropertyExpression.Value;
}

return currentFragmentIndex > 0 && lastFilter is ValueExpression { Value: ".*.*" };
}

if (!MatchFilterPattern(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,23 @@ public void PropertiesDoNotNeedUrlEncodingOfSlashes(string filter, string nodePa
Assert.IsFalse(filterInstance.MatchesFilter(nodePath, nodeProperties));
}
}

[TestMethod]
public void MatchAllFilterWithPropertyExpression()
{
TreeNodeFilter filter = new("/**[A=B]");
Assert.IsTrue(filter.MatchesFilter("/A/B/C/D", new PropertyBag(new KeyValuePairStringProperty("A", "B"))));
Assert.IsFalse(filter.MatchesFilter("/A/B/C/D", new PropertyBag(new KeyValuePairStringProperty("A", "C"))));
}

[TestMethod]
public void MatchAllFilterSubpathWithPropertyExpression()
{
TreeNodeFilter filter = new("/A/**[A=B]");
Assert.IsTrue(filter.MatchesFilter("/A/B/C/D", new PropertyBag(new KeyValuePairStringProperty("A", "B"))));
Assert.IsFalse(filter.MatchesFilter("/B/A/C/D", new PropertyBag(new KeyValuePairStringProperty("A", "B"))));
}

[TestMethod]
public void MatchAllFilterWithPropertyExpression_DoNotAllowInMiddleOfFilter() => Assert.ThrowsException<ArgumentException>(() => _ = new TreeNodeFilter("/**/Path[A=B]"));
}