22using AutoMapper . AspNet . OData ;
33using ExpressionBuilder . Tests . Data ;
44using Microsoft . AspNetCore . Builder ;
5- using Microsoft . AspNetCore . OData ;
65using Microsoft . AspNetCore . Routing ;
76using Microsoft . Extensions . DependencyInjection ;
87using Microsoft . OData ;
@@ -1202,6 +1201,19 @@ public void DateFunctions_Nullable(string filterString, string expression)
12021201 AssertFilterStringIsCorrect ( filter , expression ) ;
12031202 }
12041203
1204+ [ Theory ]
1205+ [ InlineData ( "year(NullableDateOnlyProperty) eq 2015" , "$it => ($it.NullableDateOnlyProperty.Value.Year == 2015)" ) ]
1206+ [ InlineData ( "month(NullableDateOnlyProperty) eq 12" , "$it => ($it.NullableDateOnlyProperty.Value.Month == 12)" ) ]
1207+ [ InlineData ( "day(NullableDateOnlyProperty) eq 23" , "$it => ($it.NullableDateOnlyProperty.Value.Day == 23)" ) ]
1208+ public void DateOnlyFunctions_Nullable ( string filterString , string expression )
1209+ {
1210+ //act
1211+ var filter = GetFilter < Product > ( filterString ) ;
1212+
1213+ //assert
1214+ AssertFilterStringIsCorrect ( filter , expression ) ;
1215+ }
1216+
12051217 [ Theory ]
12061218 [ InlineData ( "year(DateProperty) eq 2015" , "$it => ($it.DateProperty.Year == 2015)" ) ]
12071219 [ InlineData ( "month(DateProperty) eq 12" , "$it => ($it.DateProperty.Month == 12)" ) ]
@@ -1215,6 +1227,19 @@ public void DateFunctions_NonNullable(string filterString, string expression)
12151227 AssertFilterStringIsCorrect ( filter , expression ) ;
12161228 }
12171229
1230+ [ Theory ]
1231+ [ InlineData ( "year(DateOnlyProperty) eq 2015" , "$it => ($it.DateOnlyProperty.Year == 2015)" ) ]
1232+ [ InlineData ( "month(DateOnlyProperty) eq 12" , "$it => ($it.DateOnlyProperty.Month == 12)" ) ]
1233+ [ InlineData ( "day(DateOnlyProperty) eq 23" , "$it => ($it.DateOnlyProperty.Day == 23)" ) ]
1234+ public void DateOnlyFunctions_NonNullable ( string filterString , string expression )
1235+ {
1236+ //act
1237+ var filter = GetFilter < Product > ( filterString ) ;
1238+
1239+ //assert
1240+ AssertFilterStringIsCorrect ( filter , expression ) ;
1241+ }
1242+
12181243 [ Theory ]
12191244 [ InlineData ( "hour(NullableTimeOfDayProperty) eq 10" , "$it => ($it.NullableTimeOfDayProperty.Value.Hours == 10)" ) ]
12201245 [ InlineData ( "minute(NullableTimeOfDayProperty) eq 20" , "$it => ($it.NullableTimeOfDayProperty.Value.Minutes == 20)" ) ]
@@ -1228,6 +1253,19 @@ public void TimeOfDayFunctions_Nullable(string filterString, string expression)
12281253 AssertFilterStringIsCorrect ( filter , expression ) ;
12291254 }
12301255
1256+ [ Theory ]
1257+ [ InlineData ( "hour(NullableTimeOnlyProperty) eq 10" , "$it => ($it.NullableTimeOnlyProperty.Value.Hour == 10)" ) ]
1258+ [ InlineData ( "minute(NullableTimeOnlyProperty) eq 20" , "$it => ($it.NullableTimeOnlyProperty.Value.Minute == 20)" ) ]
1259+ [ InlineData ( "second(NullableTimeOnlyProperty) eq 30" , "$it => ($it.NullableTimeOnlyProperty.Value.Second == 30)" ) ]
1260+ public void TimeOnlyFunctions_Nullable ( string filterString , string expression )
1261+ {
1262+ //act
1263+ var filter = GetFilter < Product > ( filterString ) ;
1264+
1265+ //assert
1266+ AssertFilterStringIsCorrect ( filter , expression ) ;
1267+ }
1268+
12311269 [ Theory ]
12321270 [ InlineData ( "hour(TimeOfDayProperty) eq 10" , "$it => ($it.TimeOfDayProperty.Hours == 10)" ) ]
12331271 [ InlineData ( "minute(TimeOfDayProperty) eq 20" , "$it => ($it.TimeOfDayProperty.Minutes == 20)" ) ]
@@ -1241,9 +1279,23 @@ public void TimeOfDayFunctions_NonNullable(string filterString, string expressio
12411279 AssertFilterStringIsCorrect ( filter , expression ) ;
12421280 }
12431281
1282+ [ Theory ]
1283+ [ InlineData ( "hour(TimeOnlyProperty) eq 10" , "$it => ($it.TimeOnlyProperty.Hour == 10)" ) ]
1284+ [ InlineData ( "minute(TimeOnlyProperty) eq 20" , "$it => ($it.TimeOnlyProperty.Minute == 20)" ) ]
1285+ [ InlineData ( "second(TimeOnlyProperty) eq 30" , "$it => ($it.TimeOnlyProperty.Second == 30)" ) ]
1286+ public void TimeOnlyFunctions_NonNullable ( string filterString , string expression )
1287+ {
1288+ //act
1289+ var filter = GetFilter < Product > ( filterString ) ;
1290+
1291+ //assert
1292+ AssertFilterStringIsCorrect ( filter , expression ) ;
1293+ }
1294+
12441295 [ Theory ]
12451296 [ InlineData ( "fractionalseconds(DiscontinuedDate) eq 0.2" , "$it => ((Convert($it.DiscontinuedDate.Value.Millisecond) / 1000) == 0.2)" ) ]
12461297 [ InlineData ( "fractionalseconds(NullableTimeOfDayProperty) eq 0.2" , "$it => ((Convert($it.NullableTimeOfDayProperty.Value.Milliseconds) / 1000) == 0.2)" ) ]
1298+ [ InlineData ( "fractionalseconds(NullableTimeOnlyProperty) eq 0.2" , "$it => ((Convert($it.NullableTimeOnlyProperty.Value.Millisecond) / 1000) == 0.2)" ) ]
12471299 public void FractionalsecondsFunction_Nullable ( string filterString , string expression )
12481300 {
12491301 //act
@@ -1256,6 +1308,7 @@ public void FractionalsecondsFunction_Nullable(string filterString, string expre
12561308 [ Theory ]
12571309 [ InlineData ( "fractionalseconds(NonNullableDiscontinuedDate) eq 0.2" , "$it => ((Convert($it.NonNullableDiscontinuedDate.Millisecond) / 1000) == 0.2)" ) ]
12581310 [ InlineData ( "fractionalseconds(TimeOfDayProperty) eq 0.2" , "$it => ((Convert($it.TimeOfDayProperty.Milliseconds) / 1000) == 0.2)" ) ]
1311+ [ InlineData ( "fractionalseconds(TimeOnlyProperty) eq 0.2" , "$it => ((Convert($it.TimeOnlyProperty.Millisecond) / 1000) == 0.2)" ) ]
12591312 public void FractionalsecondsFunction_NonNullable ( string filterString , string expression )
12601313 {
12611314 //act
0 commit comments