Skip to content

Commit

Permalink
Small progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Feb 4, 2025
1 parent 3d28ac1 commit 286f9e0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@ public TreeNodeFilterExpression(TreeNodeFilter treeNodeFilter, IEnumerable<strin
public bool MatchTestCase(TestCase testCase, Func<string, object?> propertyValueProvider)
{
// TODO
var assemblyName = Path.GetFileNameWithoutExtension(testCase.Source);
var @namespace = ;
var className = ;
var methodName = ;
var propertyBag = ;
string assemblyName = Path.GetFileNameWithoutExtension(testCase.Source);
ReadOnlySpan<char> fullyQualifiedName = testCase.FullyQualifiedName.AsSpan();

return _treeNodeFilter.MatchesFilter($"/{assemblyName}/{@namespace}/{className}/{methodName}", propertyBag);
int lastDot = fullyQualifiedName.LastIndexOf('.');
ReadOnlySpan<char> methodName = fullyQualifiedName.Slice(lastDot + 1);
fullyQualifiedName = fullyQualifiedName.Slice(0, lastDot);

lastDot = fullyQualifiedName.LastIndexOf('.');
ReadOnlySpan<char> className = fullyQualifiedName.Slice(lastDot + 1);
fullyQualifiedName = fullyQualifiedName.Slice(0, lastDot);

ReadOnlySpan<char> @namespace = fullyQualifiedName;

// TODO: PropertyBag argument
return _treeNodeFilter.MatchesFilter($"/{assemblyName}/{@namespace.ToString()}/{className.ToString()}/{methodName.ToString()}", new());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,20 @@ public void MatchAllFilterSubpathWithPropertyExpression()
Assert.IsFalse(filter.MatchesFilter("/B/A/C/D", new PropertyBag(new KeyValuePairStringProperty("A", "B"))));
}

[TestMethod]
public void MatchEmptyNamespaceWithAsterisk()
{
TreeNodeFilter filter = new("/AssemblyName/*/ClassName/MethodName");
Assert.IsTrue(filter.MatchesFilter("/AssemblyName//ClassName/MethodName", new PropertyBag()));
}

[TestMethod]
public void MatchEmptyNamespaceWithEmpty()
{
TreeNodeFilter filter = new("/AssemblyName//ClassName/MethodName");
Assert.IsFalse(filter.MatchesFilter("/AssemblyName//ClassName/MethodName", new PropertyBag()));
}

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

0 comments on commit 286f9e0

Please sign in to comment.