public void Matches(string pathInSet, string path, bool?expected) { var matchingNode = new JsonPathExpressionMatchingNode <JsonPathExpression>(0); matchingNode.Add(new JsonPathExpression(pathInSet)); bool?actual = matchingNode.Matches(new JsonPathExpression(path)); actual.Should().Be(expected); }
public void Matches_ReturnsMatched() { var matchingNode = new JsonPathExpressionMatchingNode <JsonPathExpression>(0); matchingNode.Add(new JsonPathExpression("$.a.*.c[*]")); matchingNode.Add(new JsonPathExpression("$.*.b.c[:]")); matchingNode.Add(new JsonPathExpression("$.*.b.c[7]")); matchingNode.Add(new JsonPathExpression("$['c','d'].b.c[*]")); var expected = new List <JsonPathExpression> { new JsonPathExpression("$.a.*.c[*]"), new JsonPathExpression("$.*.b.c[:]") }; var actual = new List <JsonPathExpression>(); bool matched = matchingNode.Matches(new JsonPathExpression("$.a.b.c[42]"), actual); matched.Should().BeTrue(); actual.Should().BeEquivalentTo(expected); }