Пример #1
0
 public void QuotedWildcardPropertyWithRoot()
 {
     JPath path = new JPath("$.['*']");
     Assert.Equal(1, path.Filters.Count);
     Assert.Equal("*", ((FieldFilter)path.Filters[0]).Name);
 }
Пример #2
0
        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);
        }
Пример #3
0
 public void SingleQuotedPropertyWithBrackets()
 {
     JPath path = new JPath("['[*]']");
     Assert.Equal(1, path.Filters.Count);
     Assert.Equal("[*]", ((FieldFilter)path.Filters[0]).Name);
 }
Пример #4
0
 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);
 }
Пример #5
0
 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);
 }
Пример #6
0
 public void IndexerOnly()
 {
     JPath path = new JPath("[111119990]");
     Assert.Equal(1, path.Filters.Count);
     Assert.Equal(111119990, ((ArrayIndexFilter)path.Filters[0]).Index);
 }
Пример #7
0
 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]);
 }
Пример #8
0
 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);
 }
Пример #9
0
 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);
 }
Пример #10
0
 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);
 }
Пример #11
0
 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);
 }
Пример #12
0
 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);
 }
Пример #13
0
 public void WildcardScanWithRootWithWhitespace()
 {
     JPath path = new JPath("$..* ");
     Assert.Equal(1, path.Filters.Count);
     Assert.Equal(null, ((ScanFilter)path.Filters[0]).Name);
 }
Пример #14
0
 public void SingleScanWithRoot()
 {
     JPath path = new JPath("$..Blah");
     Assert.Equal(1, path.Filters.Count);
     Assert.Equal("Blah", ((ScanFilter)path.Filters[0]).Name);
 }
Пример #15
0
 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);
 }
Пример #16
0
 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);
 }
Пример #17
0
 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);
 }
Пример #18
0
 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);
 }
Пример #19
0
 public void IndexerOnlyWithWhitespace()
 {
     JPath path = new JPath("[  10  ]");
     Assert.Equal(1, path.Filters.Count);
     Assert.Equal(10, ((ArrayIndexFilter)path.Filters[0]).Index);
 }
Пример #20
0
 public void FilterWithLessThan()
 {
     JPath path = new JPath("[?(@.name<null)]");
     BooleanQueryExpression expressions = (BooleanQueryExpression)((QueryFilter)path.Filters[0]).Expression;
     Assert.Equal(QueryOperator.LessThan, expressions.Operator);
 }
Пример #21
0
 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]);
 }
Пример #22
0
 public void FilterWithGreaterThanOrEquals()
 {
     JPath path = new JPath("[?(@.name>=null)]");
     BooleanQueryExpression expressions = (BooleanQueryExpression)((QueryFilter)path.Filters[0]).Expression;
     Assert.Equal(QueryOperator.GreaterThanOrEquals, expressions.Operator);
 }
Пример #23
0
 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);
 }
Пример #24
0
 public void FilterWithNegativeInteger()
 {
     JPath path = new JPath("[?(@.name>=-12)]");
     BooleanQueryExpression expressions = (BooleanQueryExpression)((QueryFilter)path.Filters[0]).Expression;
     Assert.Equal(-12, (int)expressions.Value);
 }
Пример #25
0
 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);
 }
Пример #26
0
 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);
 }
Пример #27
0
 public void SingleQuotedPropertyWithDots()
 {
     JPath path = new JPath("['Blah.Ha']");
     Assert.Equal(1, path.Filters.Count);
     Assert.Equal("Blah.Ha", ((FieldFilter)path.Filters[0]).Name);
 }
Пример #28
0
        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);
        }
Пример #29
0
 public void SinglePropertyWithRoot()
 {
     JPath path = new JPath("$.Blah");
     Assert.Equal(1, path.Filters.Count);
     Assert.Equal("Blah", ((FieldFilter)path.Filters[0]).Name);
 }
Пример #30
0
 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);
 }