@@ -12,7 +12,8 @@ public class DataSourceExpressionBuilderTests {
1212 public void Build_SkipTake ( ) {
1313 var builder = Compat . CreateDataSourceExpressionBuilder < int > ( new SampleLoadOptions {
1414 Skip = 111 ,
15- Take = 222
15+ Take = 222 ,
16+ GuardNulls = false
1617 } ) ;
1718
1819 var expr = builder . BuildLoadExpr ( ) ;
@@ -23,7 +24,8 @@ public void Build_SkipTake() {
2324 [ Fact ]
2425 public void Build_Filter ( ) {
2526 var builder = Compat . CreateDataSourceExpressionBuilder < int > ( new SampleLoadOptions {
26- Filter = new object [ ] { "this" , ">" , 123 }
27+ Filter = new object [ ] { "this" , ">" , 123 } ,
28+ GuardNulls = false
2729 } ) ;
2830
2931 var expr = builder . BuildLoadExpr ( ) ;
@@ -36,7 +38,8 @@ public void Build_FilterAsEmptyList() {
3638 // To mitigate cases like https://devexpress.com/issue=T483154
3739
3840 var builder = Compat . CreateDataSourceExpressionBuilder < int > ( new SampleLoadOptions {
39- Filter = new object [ 0 ]
41+ Filter = new object [ 0 ] ,
42+ GuardNulls = false
4043 } ) ;
4144
4245 Assert . DoesNotContain ( ".Where" , builder . BuildLoadExpr ( ) . ToString ( ) ) ;
@@ -51,6 +54,7 @@ public void Build_CountQuery() {
5154 Sort = new [ ] {
5255 new SortingInfo { Selector = "this" }
5356 } ,
57+ GuardNulls = false
5458 } ) ;
5559
5660 var expr = builder . BuildCountExpr ( ) ;
@@ -74,7 +78,8 @@ public void Build_Sorting() {
7478 Selector = "Item2" ,
7579 Desc = true
7680 }
77- }
81+ } ,
82+ GuardNulls = false
7883 } ) ;
7984
8085 var expr = builder . BuildLoadExpr ( ) ;
@@ -91,18 +96,19 @@ public void GroupingAddedToSorting() {
9196 Group = new [ ] {
9297 new GroupingInfo { Selector = "Item1" } ,
9398 new GroupingInfo { Selector = "Item2" , Desc = true } // this must win
94- }
99+ } ,
100+ GuardNulls = false
95101 } ;
96102
97- var builder = Compat . CreateDataSourceExpressionBuilder < Tuple < int , int , int > > ( loadOptions ) ;
103+ string BuildLoadExpr ( ) => Compat . CreateDataSourceExpressionBuilder < Tuple < int , int , int > > ( loadOptions ) . BuildLoadExpr ( ) . ToString ( ) ;
98104
99105 Assert . Equal (
100106 "data.OrderBy(obj => obj.Item1).ThenByDescending(obj => obj.Item2).ThenBy(obj => obj.Item3)" ,
101- builder . BuildLoadExpr ( ) . ToString ( )
107+ BuildLoadExpr ( )
102108 ) ;
103109
104110 loadOptions . Sort = null ;
105- Assert . Contains ( "OrderBy" , builder . BuildLoadExpr ( ) . ToString ( ) ) ;
111+ Assert . Contains ( "OrderBy" , BuildLoadExpr ( ) ) ;
106112 }
107113
108114 [ Fact ]
@@ -111,28 +117,15 @@ public void MultiIntervalGroupsSortedOnce() {
111117 Group = new [ ] {
112118 new GroupingInfo { Selector = "this" , GroupInterval = "a" } ,
113119 new GroupingInfo { Selector = "this" , GroupInterval = "b" }
114- }
120+ } ,
121+ GuardNulls = false
115122 } ) ;
116123
117124 Assert . Equal ( "data.OrderBy(obj => obj)" , builder . BuildLoadExpr ( ) . ToString ( ) ) ;
118125 }
119126
120127 [ Fact ]
121128 public void GuardNulls ( ) {
122- var builder = Compat . CreateDataSourceExpressionBuilder < Tuple < int ? , string , DateTime ? > > ( new SampleLoadOptions {
123- Filter = new [ ] {
124- new [ ] { "Item1" , ">" , "0" } ,
125- new [ ] { "Item2" , "contains" , "z" } ,
126- new [ ] { "Item2.Length" , ">" , "1" } ,
127- new [ ] { "Item3.Year" , ">" , "0" }
128- } ,
129- Sort = new [ ] {
130- new SortingInfo { Selector = "Item1" } ,
131- new SortingInfo { Selector = "Item2.Length" } ,
132- new SortingInfo { Selector = "Item3.Year" } ,
133- }
134- } , true ) ;
135-
136129 var data = new [ ] {
137130 // filtered out
138131 null ,
@@ -146,29 +139,45 @@ public void GuardNulls() {
146139 Tuple . Create < int ? , string , DateTime ? > ( 1 , "zz" , new DateTime ( 2000 , 1 , 1 ) )
147140 } . AsQueryable ( ) ;
148141
149- var expr = builder . BuildLoadExpr ( data . Expression ) ;
142+ var builder = Compat . CreateDataSourceExpressionBuilder ( data , new SampleLoadOptions {
143+ Filter = new [ ] {
144+ new [ ] { "Item1" , ">" , "0" } ,
145+ new [ ] { "Item2" , "contains" , "z" } ,
146+ new [ ] { "Item2.Length" , ">" , "1" } ,
147+ new [ ] { "Item3.Year" , ">" , "0" }
148+ } ,
149+ Sort = new [ ] {
150+ new SortingInfo { Selector = "Item1" } ,
151+ new SortingInfo { Selector = "Item2.Length" } ,
152+ new SortingInfo { Selector = "Item3.Year" } ,
153+ } ,
154+ GuardNulls = true
155+ } ) ;
156+
157+ var expr = builder . BuildLoadExpr ( ) ;
150158 var result = data . Provider . CreateQuery < object > ( expr ) . ToArray ( ) ;
151159 Assert . Equal ( 2 , result . Length ) ;
152160 }
153161
154162 [ Fact ]
155163 public void DefaultSort ( ) {
156164 var options = new SampleLoadOptions {
157- DefaultSort = "Item1"
165+ DefaultSort = "Item1" ,
166+ GuardNulls = false
158167 } ;
159168
160- var builder = Compat . CreateDataSourceExpressionBuilder < Tuple < int , int > > ( options , false ) ;
169+ string BuildLoadExpr ( ) => Compat . CreateDataSourceExpressionBuilder < Tuple < int , int > > ( options ) . BuildLoadExpr ( false ) . ToString ( ) ;
161170
162- Assert . Equal ( "data.OrderBy(obj => obj.Item1)" , builder . BuildLoadExpr ( false ) . ToString ( ) ) ;
171+ Assert . Equal ( "data.OrderBy(obj => obj.Item1)" , BuildLoadExpr ( ) ) ;
163172
164173 options . Sort = new [ ] {
165174 new SortingInfo { Selector = "Item2" }
166175 } ;
167176
168- Assert . Equal ( "data.OrderBy(obj => obj.Item2).ThenBy(obj => obj.Item1)" , builder . BuildLoadExpr ( false ) . ToString ( ) ) ;
177+ Assert . Equal ( "data.OrderBy(obj => obj.Item2).ThenBy(obj => obj.Item1)" , BuildLoadExpr ( ) ) ;
169178
170179 options . Sort [ 0 ] . Selector = "Item1" ;
171- Assert . Equal ( "data.OrderBy(obj => obj.Item1)" , builder . BuildLoadExpr ( false ) . ToString ( ) ) ;
180+ Assert . Equal ( "data.OrderBy(obj => obj.Item1)" , BuildLoadExpr ( ) ) ;
172181 }
173182
174183 [ Fact ]
@@ -180,10 +189,11 @@ public void NoUnnecessaryOrderingForRemoteGroups() {
180189 } ,
181190 Sort = new [ ] {
182191 new SortingInfo { Selector = "Item2" }
183- }
192+ } ,
193+ GuardNulls = false
184194 } ;
185195
186- var builder = Compat . CreateDataSourceExpressionBuilder < Tuple < int , int > > ( options , false ) ;
196+ var builder = Compat . CreateDataSourceExpressionBuilder < Tuple < int , int > > ( options ) ;
187197 var expr = builder . BuildLoadGroupsExpr ( ) . ToString ( ) ;
188198
189199 Assert . StartsWith ( "data.GroupBy" , expr ) ;
@@ -192,10 +202,11 @@ public void NoUnnecessaryOrderingForRemoteGroups() {
192202 [ Fact ]
193203 public void AlwaysOrderDataByPrimaryKey ( ) {
194204 var options = new SampleLoadOptions {
195- PrimaryKey = new [ ] { "Item2" , "Item1" }
205+ PrimaryKey = new [ ] { "Item2" , "Item1" } ,
206+ GuardNulls = false
196207 } ;
197208
198- var builder = Compat . CreateDataSourceExpressionBuilder < Tuple < int , int > > ( options , false ) ;
209+ var builder = Compat . CreateDataSourceExpressionBuilder < Tuple < int , int > > ( options ) ;
199210
200211 Assert . Equal (
201212 "data.OrderBy(obj => obj.Item2).ThenBy(obj => obj.Item1)" ,
@@ -208,11 +219,12 @@ public void DefaultSortAndPrimaryKey() {
208219 var options = new SampleLoadOptions {
209220 PrimaryKey = new [ ] { "Item1" } ,
210221 DefaultSort = "Item1" ,
211- Sort = new [ ] { new SortingInfo { Selector = "Item1" } }
222+ Sort = new [ ] { new SortingInfo { Selector = "Item1" } } ,
223+ GuardNulls = false
212224 } ;
213225
214226 {
215- var builder = Compat . CreateDataSourceExpressionBuilder < Tuple < int , int , int > > ( options , false ) ;
227+ var builder = Compat . CreateDataSourceExpressionBuilder < Tuple < int , int , int > > ( options ) ;
216228
217229 Assert . Equal (
218230 "data.OrderBy(obj => obj.Item1)" ,
@@ -224,7 +236,7 @@ public void DefaultSortAndPrimaryKey() {
224236 options . Sort [ 0 ] . Selector = "Item3" ;
225237
226238 {
227- var builder = Compat . CreateDataSourceExpressionBuilder < Tuple < int , int , int > > ( options , false ) ;
239+ var builder = Compat . CreateDataSourceExpressionBuilder < Tuple < int , int , int > > ( options ) ;
228240
229241 Assert . Equal (
230242 "data.OrderBy(obj => obj.Item3).ThenBy(obj => obj.Item2).ThenBy(obj => obj.Item1)" ,
@@ -241,10 +253,11 @@ public void PR202() {
241253 DefaultSort = "item1" ,
242254 Sort = new [ ] {
243255 new SortingInfo { Selector = "ITEM1" }
244- }
256+ } ,
257+ GuardNulls = false
245258 } ;
246259
247- var builder = Compat . CreateDataSourceExpressionBuilder < Tuple < int > > ( options , false ) ;
260+ var builder = Compat . CreateDataSourceExpressionBuilder < Tuple < int > > ( options ) ;
248261
249262 Assert . Equal (
250263 "data.OrderBy(obj => obj.Item1)" ,
@@ -256,12 +269,13 @@ public void PR202() {
256269 public void RemoteSelectFalse ( ) {
257270 var options = new SampleLoadOptions {
258271 Select = new [ ] { "abc" } ,
259- RemoteSelect = false
272+ RemoteSelect = false ,
273+ GuardNulls = false
260274 } ;
261275
262276 Assert . Equal (
263277 "data" ,
264- Compat . CreateDataSourceExpressionBuilder < object > ( options , false ) . BuildLoadExpr ( ) . ToString ( )
278+ Compat . CreateDataSourceExpressionBuilder < object > ( options ) . BuildLoadExpr ( ) . ToString ( )
265279 ) ;
266280 }
267281 }
0 commit comments