public void QuotedWildcardPropertyWithRoot() { JPath path = new JPath("$.['*']"); Assert.Equal(1, path.Filters.Count); Assert.Equal("*", ((FieldFilter)path.Filters[0]).Name); }
public void PropertyFollowingEscapedPropertyName() { JPath path = new JPath("frameworks.aspnetcore50.dependencies.['System.Xml.ReaderWriter'].source"); Assert.Equal(5, path.Filters.Count); Assert.Equal("frameworks", ((FieldFilter)path.Filters[0]).Name); Assert.Equal("aspnetcore50", ((FieldFilter)path.Filters[1]).Name); Assert.Equal("dependencies", ((FieldFilter)path.Filters[2]).Name); Assert.Equal("System.Xml.ReaderWriter", ((FieldFilter)path.Filters[3]).Name); Assert.Equal("source", ((FieldFilter)path.Filters[4]).Name); }
public void SingleQuotedPropertyWithBrackets() { JPath path = new JPath("['[*]']"); Assert.Equal(1, path.Filters.Count); Assert.Equal("[*]", ((FieldFilter)path.Filters[0]).Name); }
public void SlicingIndex() { JPath path = new JPath("[111119990:3]"); Assert.Equal(1, path.Filters.Count); Assert.Equal(111119990, ((ArraySliceFilter)path.Filters[0]).Start); Assert.Equal(3, ((ArraySliceFilter)path.Filters[0]).End); Assert.Equal(null, ((ArraySliceFilter)path.Filters[0]).Step); }
public void SlicingIndexWhitespace() { JPath path = new JPath("[ -111119990 : -3 : -2 ]"); Assert.Equal(1, path.Filters.Count); Assert.Equal(-111119990, ((ArraySliceFilter)path.Filters[0]).Start); Assert.Equal(-3, ((ArraySliceFilter)path.Filters[0]).End); Assert.Equal(-2, ((ArraySliceFilter)path.Filters[0]).Step); }
public void IndexerOnly() { JPath path = new JPath("[111119990]"); Assert.Equal(1, path.Filters.Count); Assert.Equal(111119990, ((ArrayIndexFilter)path.Filters[0]).Index); }
public void MultipleIndexesWithWhitespace() { JPath path = new JPath("[ 111119990 , 3 ]"); Assert.Equal(1, path.Filters.Count); Assert.Equal(2, ((ArrayMultipleIndexFilter)path.Filters[0]).Indexes.Count); Assert.Equal(111119990, ((ArrayMultipleIndexFilter)path.Filters[0]).Indexes[0]); Assert.Equal(3, ((ArrayMultipleIndexFilter)path.Filters[0]).Indexes[1]); }
public void SinglePropertyAndExistsQuery() { JPath path = new JPath("Blah[ ?( @..name ) ]"); Assert.Equal(2, path.Filters.Count); Assert.Equal("Blah", ((FieldFilter)path.Filters[0]).Name); BooleanQueryExpression expressions = (BooleanQueryExpression)((QueryFilter)path.Filters[1]).Expression; Assert.Equal(QueryOperator.Exists, expressions.Operator); Assert.Equal(1, expressions.Path.Count); Assert.Equal("name", ((ScanFilter)expressions.Path[0]).Name); }
public void SinglePropertyAndFilterWithDoubleEscape() { JPath path = new JPath(@"Blah[ ?( @.name=='h\\i' ) ]"); Assert.Equal(2, path.Filters.Count); Assert.Equal("Blah", ((FieldFilter)path.Filters[0]).Name); BooleanQueryExpression expressions = (BooleanQueryExpression)((QueryFilter)path.Filters[1]).Expression; Assert.Equal(QueryOperator.Equals, expressions.Operator); Assert.Equal("h\\i", (string)expressions.Value); }
public void OnePropertyOneScan() { JPath path = new JPath("Blah..Two"); Assert.Equal(2, path.Filters.Count); Assert.Equal("Blah", ((FieldFilter)path.Filters[0]).Name); Assert.Equal("Two", ((ScanFilter)path.Filters[1]).Name); }
public void SinglePropertyAndIndexer() { JPath path = new JPath("Blah[0]"); Assert.Equal(2, path.Filters.Count); Assert.Equal("Blah", ((FieldFilter)path.Filters[0]).Name); Assert.Equal(0, ((ArrayIndexFilter)path.Filters[1]).Index); }
public void TwoProperties() { JPath path = new JPath("Blah.Two"); Assert.Equal(2, path.Filters.Count); Assert.Equal("Blah", ((FieldFilter)path.Filters[0]).Name); Assert.Equal("Two", ((FieldFilter)path.Filters[1]).Name); }
public void WildcardScanWithRootWithWhitespace() { JPath path = new JPath("$..* "); Assert.Equal(1, path.Filters.Count); Assert.Equal(null, ((ScanFilter)path.Filters[0]).Name); }
public void SingleScanWithRoot() { JPath path = new JPath("$..Blah"); Assert.Equal(1, path.Filters.Count); Assert.Equal("Blah", ((ScanFilter)path.Filters[0]).Name); }
public void FilterWithFloatExp() { JPath path = new JPath("[?(@.name>=5.56789e+0)]"); BooleanQueryExpression expressions = (BooleanQueryExpression)((QueryFilter)path.Filters[0]).Expression; Assert.Equal(5.56789e+0, (double)expressions.Value); }
public void SinglePropertyAndFilterWithNull() { JPath path = new JPath("Blah[ ?( @.name==null ) ]"); Assert.Equal(2, path.Filters.Count); Assert.Equal("Blah", ((FieldFilter)path.Filters[0]).Name); BooleanQueryExpression expressions = (BooleanQueryExpression)((QueryFilter)path.Filters[1]).Expression; Assert.Equal(QueryOperator.Equals, expressions.Operator); Assert.Equal(null, expressions.Value.Value); }
public void MultiplePropertiesAndIndexers() { JPath path = new JPath("Blah[0]..Two.Three[1].Four"); Assert.Equal(6, path.Filters.Count); Assert.Equal("Blah", ((FieldFilter) path.Filters[0]).Name); Assert.Equal(0, ((ArrayIndexFilter) path.Filters[1]).Index); Assert.Equal("Two", ((ScanFilter)path.Filters[2]).Name); Assert.Equal("Three", ((FieldFilter)path.Filters[3]).Name); Assert.Equal(1, ((ArrayIndexFilter)path.Filters[4]).Index); Assert.Equal("Four", ((FieldFilter)path.Filters[5]).Name); }
public void FilterWithScan() { JPath path = new JPath("[?(@..name<>null)]"); BooleanQueryExpression expressions = (BooleanQueryExpression)((QueryFilter)path.Filters[0]).Expression; Assert.Equal("name", ((ScanFilter)expressions.Path[0]).Name); }
public void IndexerOnlyWithWhitespace() { JPath path = new JPath("[ 10 ]"); Assert.Equal(1, path.Filters.Count); Assert.Equal(10, ((ArrayIndexFilter)path.Filters[0]).Index); }
public void FilterWithLessThan() { JPath path = new JPath("[?(@.name<null)]"); BooleanQueryExpression expressions = (BooleanQueryExpression)((QueryFilter)path.Filters[0]).Expression; Assert.Equal(QueryOperator.LessThan, expressions.Operator); }
public void MultipleQuotedIndexesWithWhitespace() { JPath path = new JPath("[ '111119990' , '3' ]"); Assert.Equal(1, path.Filters.Count); Assert.Equal(2, ((FieldMultipleFilter)path.Filters[0]).Names.Count); Assert.Equal("111119990", ((FieldMultipleFilter)path.Filters[0]).Names[0]); Assert.Equal("3", ((FieldMultipleFilter)path.Filters[0]).Names[1]); }
public void FilterWithGreaterThanOrEquals() { JPath path = new JPath("[?(@.name>=null)]"); BooleanQueryExpression expressions = (BooleanQueryExpression)((QueryFilter)path.Filters[0]).Expression; Assert.Equal(QueryOperator.GreaterThanOrEquals, expressions.Operator); }
public void SlicingIndexEmptyStart() { JPath path = new JPath("[ : 1 : ]"); Assert.Equal(1, path.Filters.Count); Assert.Equal(null, ((ArraySliceFilter)path.Filters[0]).Start); Assert.Equal(1, ((ArraySliceFilter)path.Filters[0]).End); Assert.Equal(null, ((ArraySliceFilter)path.Filters[0]).Step); }
public void FilterWithNegativeInteger() { JPath path = new JPath("[?(@.name>=-12)]"); BooleanQueryExpression expressions = (BooleanQueryExpression)((QueryFilter)path.Filters[0]).Expression; Assert.Equal(-12, (int)expressions.Value); }
public void AdjacentIndexers() { JPath path = new JPath("[1][0][0][" + int.MaxValue + "]"); Assert.Equal(4, path.Filters.Count); Assert.Equal(1, ((ArrayIndexFilter)path.Filters[0]).Index); Assert.Equal(0, ((ArrayIndexFilter)path.Filters[1]).Index); Assert.Equal(0, ((ArrayIndexFilter)path.Filters[2]).Index); Assert.Equal(int.MaxValue, ((ArrayIndexFilter)path.Filters[3]).Index); }
public void FilterExistWithAnd() { JPath path = new JPath("[?(@.name&&@.title)]"); CompositeExpression expressions = (CompositeExpression)((QueryFilter)path.Filters[0]).Expression; Assert.Equal(QueryOperator.And, expressions.Operator); Assert.Equal(2, expressions.Expressions.Count); Assert.Equal("name", ((FieldFilter)((BooleanQueryExpression)expressions.Expressions[0]).Path[0]).Name); Assert.Equal(QueryOperator.Exists, expressions.Expressions[0].Operator); Assert.Equal("title", ((FieldFilter)((BooleanQueryExpression)expressions.Expressions[1]).Path[0]).Name); Assert.Equal(QueryOperator.Exists, expressions.Expressions[1].Operator); }
public void SingleQuotedPropertyWithDots() { JPath path = new JPath("['Blah.Ha']"); Assert.Equal(1, path.Filters.Count); Assert.Equal("Blah.Ha", ((FieldFilter)path.Filters[0]).Name); }
public void FilterExistWithAndOr() { JPath path = new JPath("[?(@.name&&@.title||@.pie)]"); CompositeExpression andExpression = (CompositeExpression)((QueryFilter)path.Filters[0]).Expression; Assert.Equal(QueryOperator.And, andExpression.Operator); Assert.Equal(2, andExpression.Expressions.Count); Assert.Equal("name", ((FieldFilter)((BooleanQueryExpression)andExpression.Expressions[0]).Path[0]).Name); Assert.Equal(QueryOperator.Exists, andExpression.Expressions[0].Operator); CompositeExpression orExpression = (CompositeExpression)andExpression.Expressions[1]; Assert.Equal(2, orExpression.Expressions.Count); Assert.Equal("title", ((FieldFilter)((BooleanQueryExpression)orExpression.Expressions[0]).Path[0]).Name); Assert.Equal(QueryOperator.Exists, orExpression.Expressions[0].Operator); Assert.Equal("pie", ((FieldFilter)((BooleanQueryExpression)orExpression.Expressions[1]).Path[0]).Name); Assert.Equal(QueryOperator.Exists, orExpression.Expressions[1].Operator); }
public void SinglePropertyWithRoot() { JPath path = new JPath("$.Blah"); Assert.Equal(1, path.Filters.Count); Assert.Equal("Blah", ((FieldFilter)path.Filters[0]).Name); }
public void WildcardArrayWithProperty() { JPath path = new JPath("[ * ].derp"); Assert.Equal(2, path.Filters.Count); Assert.Equal(null, ((ArrayIndexFilter)path.Filters[0]).Index); Assert.Equal("derp", ((FieldFilter)path.Filters[1]).Name); }