Exemplo n.º 1
0
 public void QuotedWildcardPropertyWithRoot()
 {
     JPath path = new JPath("$.['*']");
     Assert.Equal(1, path.Filters.Count);
     Assert.Equal("*", ((FieldFilter)path.Filters[0]).Name);
 }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
 public void SingleQuotedPropertyWithBrackets()
 {
     JPath path = new JPath("['[*]']");
     Assert.Equal(1, path.Filters.Count);
     Assert.Equal("[*]", ((FieldFilter)path.Filters[0]).Name);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 6
0
 public void IndexerOnly()
 {
     JPath path = new JPath("[111119990]");
     Assert.Equal(1, path.Filters.Count);
     Assert.Equal(111119990, ((ArrayIndexFilter)path.Filters[0]).Index);
 }
Exemplo n.º 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]);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 13
0
 public void WildcardScanWithRootWithWhitespace()
 {
     JPath path = new JPath("$..* ");
     Assert.Equal(1, path.Filters.Count);
     Assert.Equal(null, ((ScanFilter)path.Filters[0]).Name);
 }
Exemplo n.º 14
0
 public void SingleScanWithRoot()
 {
     JPath path = new JPath("$..Blah");
     Assert.Equal(1, path.Filters.Count);
     Assert.Equal("Blah", ((ScanFilter)path.Filters[0]).Name);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 19
0
 public void IndexerOnlyWithWhitespace()
 {
     JPath path = new JPath("[  10  ]");
     Assert.Equal(1, path.Filters.Count);
     Assert.Equal(10, ((ArrayIndexFilter)path.Filters[0]).Index);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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]);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 29
0
 public void SinglePropertyWithRoot()
 {
     JPath path = new JPath("$.Blah");
     Assert.Equal(1, path.Filters.Count);
     Assert.Equal("Blah", ((FieldFilter)path.Filters[0]).Name);
 }
Exemplo n.º 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);
 }