@@ -95,6 +95,42 @@ public void Apply_Filter_Single_Property_Add_Equals_Implicit_Cast()
95
95
Assert . All ( results , x => Assert . Equal ( 39.00M , ( ( dynamic ) x ) . Price ) ) ;
96
96
}
97
97
98
+ [ Fact ]
99
+ public void Apply_Filter_Single_Property_Concat ( )
100
+ {
101
+ TestHelper . EnsureEDM ( ) ;
102
+
103
+ var queryOptions = new ODataQueryOptions (
104
+ "?$filter=concat(concat(Forename, ', '), Surname) eq 'Jess, Smith'" ,
105
+ EntityDataModel . Current . EntitySets [ "Employees" ] ,
106
+ Mock . Of < IODataQueryOptionsValidator > ( ) ) ;
107
+
108
+ IList < ExpandoObject > results = _employees . AsQueryable ( ) . Apply ( queryOptions ) . ToList ( ) ;
109
+
110
+ Assert . Equal ( _employees . Where ( x => ( x . Forename + ", " + x . Surname ) == "Jess, Smith" ) . Count ( ) , results . Count ) ;
111
+
112
+ Assert . Single ( results ) ;
113
+
114
+ Assert . All ( results , x => Assert . True ( ( ( dynamic ) x ) . Forename == "Jess" && ( ( dynamic ) x ) . Surname == "Smith" ) ) ;
115
+ }
116
+
117
+ [ Fact ]
118
+ public void Apply_Filter_Single_Property_Contains ( )
119
+ {
120
+ TestHelper . EnsureEDM ( ) ;
121
+
122
+ var queryOptions = new ODataQueryOptions (
123
+ "?$filter=contains(Description, 'Case')" ,
124
+ EntityDataModel . Current . EntitySets [ "Products" ] ,
125
+ Mock . Of < IODataQueryOptionsValidator > ( ) ) ;
126
+
127
+ IList < ExpandoObject > results = _products . AsQueryable ( ) . Apply ( queryOptions ) . ToList ( ) ;
128
+
129
+ Assert . Equal ( _products . Where ( x => x . Description . Contains ( "Case" ) ) . Count ( ) , results . Count ) ;
130
+
131
+ Assert . All ( results , x => Assert . True ( ( ( dynamic ) x ) . Description . Contains ( "Case" ) ) ) ;
132
+ }
133
+
98
134
[ Fact ]
99
135
public void Apply_Filter_Single_Property_Divide_Equals ( )
100
136
{
@@ -129,6 +165,23 @@ public void Apply_Filter_Single_Property_Divide_Equals_Implicit_Cast()
129
165
Assert . All ( results , x => Assert . Equal ( 39.00M , ( ( dynamic ) x ) . Price ) ) ;
130
166
}
131
167
168
+ [ Fact ]
169
+ public void Apply_Filter_Single_Property_EndsWith ( )
170
+ {
171
+ TestHelper . EnsureEDM ( ) ;
172
+
173
+ var queryOptions = new ODataQueryOptions (
174
+ "?$filter=endswith(Description, 'Blue')" ,
175
+ EntityDataModel . Current . EntitySets [ "Products" ] ,
176
+ Mock . Of < IODataQueryOptionsValidator > ( ) ) ;
177
+
178
+ IList < ExpandoObject > results = _products . AsQueryable ( ) . Apply ( queryOptions ) . ToList ( ) ;
179
+
180
+ Assert . Equal ( _products . Where ( x => x . Description . EndsWith ( "Blue" ) ) . Count ( ) , results . Count ) ;
181
+
182
+ Assert . All ( results , x => Assert . True ( ( ( dynamic ) x ) . Description . EndsWith ( "Blue" ) ) ) ;
183
+ }
184
+
132
185
[ Fact ]
133
186
public void Apply_Filter_Single_Property_Equals_Enum ( )
134
187
{
@@ -280,6 +333,40 @@ public void Apply_Filter_Single_Property_Has_Enum()
280
333
Assert . All ( results , x => Assert . True ( ( ( dynamic ) x ) . AccessLevel . HasFlag ( AccessLevel . Read | AccessLevel . Write ) ) ) ;
281
334
}
282
335
336
+ [ Fact ]
337
+ public void Apply_Filter_Single_Property_IndexOf ( )
338
+ {
339
+ TestHelper . EnsureEDM ( ) ;
340
+
341
+ var queryOptions = new ODataQueryOptions (
342
+ "?$filter=indexof(Description, '64GB') eq 10" ,
343
+ EntityDataModel . Current . EntitySets [ "Products" ] ,
344
+ Mock . Of < IODataQueryOptionsValidator > ( ) ) ;
345
+
346
+ IList < ExpandoObject > results = _products . AsQueryable ( ) . Apply ( queryOptions ) . ToList ( ) ;
347
+
348
+ Assert . Equal ( _products . Where ( x => x . Description . IndexOf ( "64GB" ) == 10 ) . Count ( ) , results . Count ) ;
349
+
350
+ Assert . All ( results , x => Assert . True ( ( ( dynamic ) x ) . Description . Contains ( "64GB" ) ) ) ;
351
+ }
352
+
353
+ [ Fact ]
354
+ public void Apply_Filter_Single_Property_Length ( )
355
+ {
356
+ TestHelper . EnsureEDM ( ) ;
357
+
358
+ var queryOptions = new ODataQueryOptions (
359
+ "?$filter=length(Description) eq 19" ,
360
+ EntityDataModel . Current . EntitySets [ "Products" ] ,
361
+ Mock . Of < IODataQueryOptionsValidator > ( ) ) ;
362
+
363
+ IList < ExpandoObject > results = _products . AsQueryable ( ) . Apply ( queryOptions ) . ToList ( ) ;
364
+
365
+ Assert . Equal ( _products . Where ( x => x . Description . Length == 19 ) . Count ( ) , results . Count ) ;
366
+
367
+ Assert . All ( results , x => Assert . True ( ( ( dynamic ) x ) . Description . Length == 19 ) ) ;
368
+ }
369
+
283
370
[ Fact ]
284
371
public void Apply_Filter_Single_Property_LessThan_Decimal ( )
285
372
{
@@ -463,6 +550,40 @@ public void Apply_Filter_Single_Property_NotEquals_String()
463
550
Assert . All ( results , x => Assert . NotEqual ( "iPhone SE 64GB Blue" , ( ( dynamic ) x ) . Description ) ) ;
464
551
}
465
552
553
+ [ Fact ]
554
+ public void Apply_Filter_Single_Property_StartsWith ( )
555
+ {
556
+ TestHelper . EnsureEDM ( ) ;
557
+
558
+ var queryOptions = new ODataQueryOptions (
559
+ "?$filter=startswith(Description, 'iPhone SE 64GB')" ,
560
+ EntityDataModel . Current . EntitySets [ "Products" ] ,
561
+ Mock . Of < IODataQueryOptionsValidator > ( ) ) ;
562
+
563
+ IList < ExpandoObject > results = _products . AsQueryable ( ) . Apply ( queryOptions ) . ToList ( ) ;
564
+
565
+ Assert . Equal ( _products . Where ( x => x . Description . StartsWith ( "iPhone SE 64GB" ) ) . Count ( ) , results . Count ) ;
566
+
567
+ Assert . All ( results , x => Assert . True ( ( ( dynamic ) x ) . Description . StartsWith ( "iPhone SE 64GB" ) ) ) ;
568
+ }
569
+
570
+ [ Fact ]
571
+ public void Apply_Filter_Single_Property_Substring ( )
572
+ {
573
+ TestHelper . EnsureEDM ( ) ;
574
+
575
+ var queryOptions = new ODataQueryOptions (
576
+ "?$filter=substring(Description, 7) eq 'SE 64GB Blue'" ,
577
+ EntityDataModel . Current . EntitySets [ "Products" ] ,
578
+ Mock . Of < IODataQueryOptionsValidator > ( ) ) ;
579
+
580
+ IList < ExpandoObject > results = _products . AsQueryable ( ) . Apply ( queryOptions ) . ToList ( ) ;
581
+
582
+ Assert . Equal ( _products . Where ( x => x . Description . Substring ( 7 ) == "SE 64GB Blue" ) . Count ( ) , results . Count ) ;
583
+
584
+ Assert . All ( results , x => Assert . True ( ( ( dynamic ) x ) . Description == "iPhone SE 64GB Blue" ) ) ;
585
+ }
586
+
466
587
[ Fact ]
467
588
public void Apply_Filter_Single_Property_Subtract_Equals ( )
468
589
{
@@ -497,6 +618,63 @@ public void Apply_Filter_Single_Property_Subtract_Equals_Implicit_Cast()
497
618
Assert . All ( results , x => Assert . Equal ( 39M , ( ( dynamic ) x ) . Price ) ) ;
498
619
}
499
620
621
+ [ Fact ]
622
+ public void Apply_Filter_Single_Property_ToLower ( )
623
+ {
624
+ TestHelper . EnsureEDM ( ) ;
625
+
626
+ var queryOptions = new ODataQueryOptions (
627
+ "?$filter=tolower(Forename) eq 'jess'" ,
628
+ EntityDataModel . Current . EntitySets [ "Employees" ] ,
629
+ Mock . Of < IODataQueryOptionsValidator > ( ) ) ;
630
+
631
+ IList < ExpandoObject > results = _employees . AsQueryable ( ) . Apply ( queryOptions ) . ToList ( ) ;
632
+
633
+ Assert . Equal ( _employees . Where ( x => x . Forename . ToLower ( ) == "jess" ) . Count ( ) , results . Count ) ;
634
+
635
+ Assert . Single ( results ) ;
636
+
637
+ Assert . All ( results , x => Assert . True ( ( ( dynamic ) x ) . Forename == "Jess" ) ) ;
638
+ }
639
+
640
+ [ Fact ]
641
+ public void Apply_Filter_Single_Property_ToUpper ( )
642
+ {
643
+ TestHelper . EnsureEDM ( ) ;
644
+
645
+ var queryOptions = new ODataQueryOptions (
646
+ "?$filter=toupper(Forename) eq 'JESS'" ,
647
+ EntityDataModel . Current . EntitySets [ "Employees" ] ,
648
+ Mock . Of < IODataQueryOptionsValidator > ( ) ) ;
649
+
650
+ IList < ExpandoObject > results = _employees . AsQueryable ( ) . Apply ( queryOptions ) . ToList ( ) ;
651
+
652
+ Assert . Equal ( _employees . Where ( x => x . Forename . ToUpper ( ) == "JESS" ) . Count ( ) , results . Count ) ;
653
+
654
+ Assert . Single ( results ) ;
655
+
656
+ Assert . All ( results , x => Assert . True ( ( ( dynamic ) x ) . Forename == "Jess" ) ) ;
657
+ }
658
+
659
+ [ Fact ]
660
+ public void Apply_Filter_Single_Property_Trim ( )
661
+ {
662
+ TestHelper . EnsureEDM ( ) ;
663
+
664
+ var queryOptions = new ODataQueryOptions (
665
+ "?$filter=trim(Forename) eq 'Jess'" ,
666
+ EntityDataModel . Current . EntitySets [ "Employees" ] ,
667
+ Mock . Of < IODataQueryOptionsValidator > ( ) ) ;
668
+
669
+ IList < ExpandoObject > results = _employees . AsQueryable ( ) . Apply ( queryOptions ) . ToList ( ) ;
670
+
671
+ Assert . Equal ( _employees . Where ( x => x . Forename . Trim ( ) == "Jess" ) . Count ( ) , results . Count ) ;
672
+
673
+ Assert . Single ( results ) ;
674
+
675
+ Assert . All ( results , x => Assert . True ( ( ( dynamic ) x ) . Forename == "Jess" ) ) ;
676
+ }
677
+
500
678
[ Fact ]
501
679
public void Apply_Filter_Single_PropertyPath_Equals_String ( )
502
680
{
0 commit comments