diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 1d4c6e0..d3abab5 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,3 +1,7 @@ +# 2.0.2 +- Support for datatypes DateOnly, TimeOnly and UInt128 +- Unit test code coverage at 95% + # 2.0.1 - Change ServiceQueryServiceFilter.FilterType enum to a string for easier serialization diff --git a/ServiceQueryV2.sln b/ServiceQueryV2.sln new file mode 100644 index 0000000..b6d24b2 --- /dev/null +++ b/ServiceQueryV2.sln @@ -0,0 +1,70 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32616.157 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceQuery", "src\ServiceQueryV2\ServiceQuery.csproj", "{C8EC306E-305E-4977-A8AD-324F28A18DB2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceQuery.AzureDataTables", "src\ServiceQuery.AzureDataTablesV2\ServiceQuery.AzureDataTables.csproj", "{38933403-A973-4B9F-AB6C-8A0B37D4DB0F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{CDCE8DCF-CCAE-4110-A51E-4DD07BF24885}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceQueryV2Net8.Integration.Xunit", "src\Tests\ServiceQueryV2Net8.Integration.Xunit\ServiceQueryV2Net8.Integration.Xunit.csproj", "{F13E1A15-CE47-4A04-A508-9AE0DDC0DFCE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceQueryV2Net8.Xunit", "src\Tests\ServiceQueryV2Net8.Xunit\ServiceQueryV2Net8.Xunit.csproj", "{9538825C-8868-45F5-B3F8-54C6000176C6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceQuery.AzureDataTablesV2Net8.Integration.Xunit", "src\Tests\ServiceQuery.AzureDataTablesV2Net8.Integration.Xunit\ServiceQuery.AzureDataTablesV2Net8.Integration.Xunit.csproj", "{90E31385-8FD8-4940-ADDC-D24FA284D44F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceQueryV2Net6.Xunit", "src\Tests\ServiceQueryV2Net6.Xunit\ServiceQueryV2Net6.Xunit.csproj", "{605277F0-8655-434E-B2FA-C86D3D62F4F7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceQueryV2Net7.Xunit", "src\Tests\ServiceQueryV2Net7.Xunit\ServiceQueryV2Net7.Xunit.csproj", "{32110F60-13E5-43A3-AA8D-A75F1AD24AA3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C8EC306E-305E-4977-A8AD-324F28A18DB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C8EC306E-305E-4977-A8AD-324F28A18DB2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C8EC306E-305E-4977-A8AD-324F28A18DB2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C8EC306E-305E-4977-A8AD-324F28A18DB2}.Release|Any CPU.Build.0 = Release|Any CPU + {38933403-A973-4B9F-AB6C-8A0B37D4DB0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {38933403-A973-4B9F-AB6C-8A0B37D4DB0F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {38933403-A973-4B9F-AB6C-8A0B37D4DB0F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {38933403-A973-4B9F-AB6C-8A0B37D4DB0F}.Release|Any CPU.Build.0 = Release|Any CPU + {F13E1A15-CE47-4A04-A508-9AE0DDC0DFCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F13E1A15-CE47-4A04-A508-9AE0DDC0DFCE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F13E1A15-CE47-4A04-A508-9AE0DDC0DFCE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F13E1A15-CE47-4A04-A508-9AE0DDC0DFCE}.Release|Any CPU.Build.0 = Release|Any CPU + {9538825C-8868-45F5-B3F8-54C6000176C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9538825C-8868-45F5-B3F8-54C6000176C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9538825C-8868-45F5-B3F8-54C6000176C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9538825C-8868-45F5-B3F8-54C6000176C6}.Release|Any CPU.Build.0 = Release|Any CPU + {90E31385-8FD8-4940-ADDC-D24FA284D44F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {90E31385-8FD8-4940-ADDC-D24FA284D44F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {90E31385-8FD8-4940-ADDC-D24FA284D44F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {90E31385-8FD8-4940-ADDC-D24FA284D44F}.Release|Any CPU.Build.0 = Release|Any CPU + {605277F0-8655-434E-B2FA-C86D3D62F4F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {605277F0-8655-434E-B2FA-C86D3D62F4F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {605277F0-8655-434E-B2FA-C86D3D62F4F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {605277F0-8655-434E-B2FA-C86D3D62F4F7}.Release|Any CPU.Build.0 = Release|Any CPU + {32110F60-13E5-43A3-AA8D-A75F1AD24AA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {32110F60-13E5-43A3-AA8D-A75F1AD24AA3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {32110F60-13E5-43A3-AA8D-A75F1AD24AA3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {32110F60-13E5-43A3-AA8D-A75F1AD24AA3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {F13E1A15-CE47-4A04-A508-9AE0DDC0DFCE} = {CDCE8DCF-CCAE-4110-A51E-4DD07BF24885} + {9538825C-8868-45F5-B3F8-54C6000176C6} = {CDCE8DCF-CCAE-4110-A51E-4DD07BF24885} + {90E31385-8FD8-4940-ADDC-D24FA284D44F} = {CDCE8DCF-CCAE-4110-A51E-4DD07BF24885} + {605277F0-8655-434E-B2FA-C86D3D62F4F7} = {CDCE8DCF-CCAE-4110-A51E-4DD07BF24885} + {32110F60-13E5-43A3-AA8D-A75F1AD24AA3} = {CDCE8DCF-CCAE-4110-A51E-4DD07BF24885} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F708D827-C6F0-4D56-A3C1-F45D8B98F897} + EndGlobalSection +EndGlobal diff --git a/src/ServiceQuery.AzureDataTablesV2/ServiceQuery.AzureDataTables.csproj b/src/ServiceQuery.AzureDataTablesV2/ServiceQuery.AzureDataTables.csproj index df0d799..0b615ad 100644 --- a/src/ServiceQuery.AzureDataTablesV2/ServiceQuery.AzureDataTables.csproj +++ b/src/ServiceQuery.AzureDataTablesV2/ServiceQuery.AzureDataTables.csproj @@ -1,7 +1,7 @@ - 2.0.1 + 2.1.0 ServiceQuery allows dynamic querying of data over service boundaries. Visit http://ServiceQuery.com to learn more. ServiceQuery.AzureDataTables holomodular @@ -32,7 +32,7 @@ 12.8.3 - + diff --git a/src/ServiceQueryV2/Extensions/ServiceQueryExtensions.cs b/src/ServiceQueryV2/Extensions/ServiceQueryExtensions.cs index 4518218..ef5a39f 100644 --- a/src/ServiceQueryV2/Extensions/ServiceQueryExtensions.cs +++ b/src/ServiceQueryV2/Extensions/ServiceQueryExtensions.cs @@ -22,9 +22,6 @@ public static partial class ServiceQueryExtensions /// public static IQueryable Apply(this IServiceQuery query, IQueryable queryable, ServiceQueryOptions serviceQueryOptions = null) { - //Get the filters back in grouped sets - ServiceQueryFilterSet filterSet = GetFilterSet(query); - //Get type and property info of the base type Type entityType = typeof(T); var properties = entityType.GetProperties(); @@ -42,6 +39,9 @@ public static IQueryable Apply(this IServiceQuery query, IQueryable que options.PropertyNameMappings = mappings; } + //Get the filters back in grouped sets + ServiceQueryFilterSet filterSet = GetFilterSet(query, options); + //Build "where" clause queryable = BuildWhere(queryable, filterSet, entityType, properties, options); @@ -71,26 +71,26 @@ private static IQueryable BuildWhere(this IQueryable queryable, Service /// public static Expression> BuildWhereExpression(this IServiceQuery query, ServiceQueryOptions serviceQueryOptions = null) { - //Get the filters back in grouped sets - ServiceQueryFilterSet filterSet = GetFilterSet(query); - //Get type and property info of the base type Type entityType = typeof(T); var properties = entityType.GetProperties(); - //Get column name mappings (in case storage object name is different than mapped object name) + //Get name mappings (in case storage object name is different than mapped object name) ServiceQueryOptions options = new ServiceQueryOptions(); if (serviceQueryOptions != null) options = serviceQueryOptions; Dictionary mappings = options.PropertyNameMappings; if (mappings == null || mappings.Count == 0) { - //Use same property name (will be case-insensitive) + // Use all existing property names mappings = new Dictionary(); properties.ToList().ForEach(x => mappings.Add(x.Name, x.Name)); options.PropertyNameMappings = mappings; } + //Get the filters back in grouped sets + ServiceQueryFilterSet filterSet = GetFilterSet(query, options); + //Build "where" clause return BuildWhereExpression(filterSet, entityType, properties, options); } @@ -179,9 +179,6 @@ private static Expression> BuildWhereExpression(this ServiceQue /// public static List GetSelectProperties(this IServiceQuery queryable, ServiceQueryOptions serviceQueryOptions = null) { - //Get the filters back in grouped sets - ServiceQueryFilterSet filterSet = GetFilterSet(queryable); - //Get type and property info of the base type Type entityType = typeof(T); var properties = entityType.GetProperties(); @@ -199,6 +196,9 @@ public static List GetSelectProperties(this IServiceQuery queryable, options.PropertyNameMappings = mappings; } + //Get the filters back in grouped sets + ServiceQueryFilterSet filterSet = GetFilterSet(queryable, options); + List selectFilters = new List(); if (filterSet.SelectFilters != null && filterSet.SelectFilters.Count > 0) { @@ -232,9 +232,6 @@ public static List GetSelectProperties(this IServiceQuery queryable, /// public static Expression> BuildSelectExpression(this IServiceQuery queryable, ServiceQueryOptions serviceQueryOptions = null) { - //Get the filters back in grouped sets - ServiceQueryFilterSet filterSet = GetFilterSet(queryable); - //Get type and property info of the base type Type entityType = typeof(T); var properties = entityType.GetProperties(); @@ -252,6 +249,9 @@ public static Expression> BuildSelectExpression(this IServiceQuery options.PropertyNameMappings = mappings; } + //Get the filters back in grouped sets + ServiceQueryFilterSet filterSet = GetFilterSet(queryable, options); + //Build "where" clause return BuildSelectExpressionEx(filterSet, entityType, properties, options); } @@ -361,30 +361,27 @@ private static Expression> BuildExpresion(this IServiceQueryFil { switch (filter.FilterType) { - case ServiceQueryFilterType.Aggregate: - break; //TODO + //case ServiceQueryFilterType.Aggregate: + // break; case ServiceQueryFilterType.Between: return GetBetweenExpression(filter, t, props, serviceQueryOptions); case ServiceQueryFilterType.Compare: return GetCompareExpression(filter, t, props, serviceQueryOptions); - - case ServiceQueryFilterType.Distinct: - break; //No expression (handled in buildselect) - case ServiceQueryFilterType.Expression: - break; //No expression (handled in buildwhere) + //case ServiceQueryFilterType.Distinct: + // break; //No expression (handled in buildselect) + //case ServiceQueryFilterType.Expression: + // break; //No expression (handled in buildwhere) case ServiceQueryFilterType.Null: return GetNullExpression(filter, t, props, serviceQueryOptions); - - case ServiceQueryFilterType.PropertyCompare: - break; //TODO - case ServiceQueryFilterType.Select: - break; //No expression (handled in buildselect) + //case ServiceQueryFilterType.PropertyCompare: + // break; + //case ServiceQueryFilterType.Select: + // break; //No expression (handled in buildselect) case ServiceQueryFilterType.Set: return GetSetExpression(filter, t, props, serviceQueryOptions); - - case ServiceQueryFilterType.Sort: - break; //No expression (handled by buildorderby) + //case ServiceQueryFilterType.Sort: + // break; //No expression (handled by buildorderby) } return null; } @@ -567,13 +564,7 @@ private static Expression> GetCompareExpression(IServiceQueryFi member = Expression.MakeMemberAccess(arg, p); BinaryExpression exp = Expression.NotEqual(member, Expression.Constant(null, p.PropertyType)); var first = Expression.Lambda>(exp, arg); - -#if NET35 - - return Expression.Lambda>(Expression.AndAlso(first.Body, second), first.Parameters); -#else return Expression.Lambda>(Expression.AndAlso(first.Body, new ExpressionParameterReplacer(second.Parameters, first.Parameters).Visit(second.Body)), first.Parameters); -#endif } return Expression.Lambda(startsWithCall, typeParam) as Expression>; @@ -594,12 +585,7 @@ private static Expression> GetCompareExpression(IServiceQueryFi member = Expression.MakeMemberAccess(arg, p); BinaryExpression exp = Expression.NotEqual(member, Expression.Constant(null, p.PropertyType)); var first = Expression.Lambda>(exp, arg); -#if NET35 - - return Expression.Lambda>(Expression.AndAlso(first.Body, second), first.Parameters); -#else return Expression.Lambda>(Expression.AndAlso(first.Body, new ExpressionParameterReplacer(second.Parameters, first.Parameters).Visit(second.Body)), first.Parameters); -#endif } return Expression.Lambda(containsCall, typeParam) as Expression>; @@ -703,9 +689,6 @@ private static Expression> GetCompareExpression(IServiceQueryFi /// public static Expression> BuildOrderByExpression(this IServiceQuery serviceQuery, IQueryable queryable, ServiceQueryOptions serviceQueryOptions = null) { - //Get the filters back in grouped sets - ServiceQueryFilterSet filterSet = GetFilterSet(serviceQuery); - //Get type and property info of the base type Type entityType = typeof(T); var properties = entityType.GetProperties(); @@ -723,6 +706,9 @@ public static Expression> BuildOrderByExpression(this IServic options.PropertyNameMappings = mappings; } + //Get the filters back in grouped sets + ServiceQueryFilterSet filterSet = GetFilterSet(serviceQuery, options); + //Build "where" clause return BuildOrderByExpression(filterSet, entityType, properties, options); } @@ -788,6 +774,15 @@ private static IQueryable BuildOrderBy(this IQueryable queryable, Servi else queryable = queryable.OrderByDescending(Expression.Lambda>(Expression.Property(param, p), param)); } +#if NET6_0_OR_GREATER + if (p.PropertyType == typeof(DateOnly)) + { + if (filterSet.SortFilters[i].SortType == ServiceQuerySortType.Ascending) + queryable = queryable.OrderBy(Expression.Lambda>(Expression.Property(param, p), param)); + else + queryable = queryable.OrderByDescending(Expression.Lambda>(Expression.Property(param, p), param)); + } +#endif if (p.PropertyType == typeof(DateTime)) { if (filterSet.SortFilters[i].SortType == ServiceQuerySortType.Ascending) @@ -865,6 +860,15 @@ private static IQueryable BuildOrderBy(this IQueryable queryable, Servi else queryable = queryable.OrderByDescending(Expression.Lambda>(Expression.Property(param, p), param)); } +#if NET6_0_OR_GREATER + if (p.PropertyType == typeof(TimeOnly)) + { + if (filterSet.SortFilters[i].SortType == ServiceQuerySortType.Ascending) + queryable = queryable.OrderBy(Expression.Lambda>(Expression.Property(param, p), param)); + else + queryable = queryable.OrderByDescending(Expression.Lambda>(Expression.Property(param, p), param)); + } +#endif if (p.PropertyType == typeof(TimeSpan)) { if (filterSet.SortFilters[i].SortType == ServiceQuerySortType.Ascending) @@ -893,6 +897,15 @@ private static IQueryable BuildOrderBy(this IQueryable queryable, Servi else queryable = queryable.OrderByDescending(Expression.Lambda>(Expression.Property(param, p), param)); } +#if NET7_0_OR_GREATER + if (p.PropertyType == typeof(UInt128)) + { + if (filterSet.SortFilters[i].SortType == ServiceQuerySortType.Ascending) + queryable = queryable.OrderBy(Expression.Lambda>(Expression.Property(param, p), param)); + else + queryable = queryable.OrderByDescending(Expression.Lambda>(Expression.Property(param, p), param)); + } +#endif } } return queryable; @@ -903,8 +916,11 @@ private static IQueryable BuildOrderBy(this IQueryable queryable, Servi } } - private static ServiceQueryFilterSet GetFilterSet(this IServiceQuery query) + private static ServiceQueryFilterSet GetFilterSet(this IServiceQuery query, ServiceQueryOptions options) { + if (query.Filters != null && options != null && !options.AllowMissingExpressions) + ValidateQuery(query); + ServiceQueryFilterSet filterSet = new ServiceQueryFilterSet(); List currentWhereFilters = new List(); bool nestedExpression = false; @@ -965,9 +981,9 @@ private static ServiceQueryFilterSet GetFilterSet(this IServiceQuery query) currentWhereFilters.Add(filter); break; - case ServiceQueryFilterType.PropertyCompare: - currentWhereFilters.Add(filter); - break; + //case ServiceQueryFilterType.PropertyCompare: + // currentWhereFilters.Add(filter); + // break; case ServiceQueryFilterType.Select: filterSet.SelectFilters.Add(filter); @@ -988,6 +1004,91 @@ private static ServiceQueryFilterSet GetFilterSet(this IServiceQuery query) return filterSet; } + private static void ValidateQuery(IServiceQuery query) + { + var beginCount = query.Filters.Where(x => x.ExpressionType == ServiceQueryExpressionType.Begin).Count(); + var endCount = query.Filters.Where(x => x.ExpressionType == ServiceQueryExpressionType.End).Count(); + if (beginCount != endCount) + throw new ServiceQueryException("Begin and End expression counts do not match"); + + // Make sure all filters have an associated expression (if needed) + bool anyWhereExpressionFound = false; + bool isAndOrExpressionNeeded = false; + Stack beginendstack = new Stack(); + foreach (var item in query.Filters) + { + switch (item.FilterType) + { + case ServiceQueryFilterType.Between: + if (isAndOrExpressionNeeded) + throw new ServiceQueryException("Expression is needed before Between filter"); + isAndOrExpressionNeeded = true; + anyWhereExpressionFound = true; + continue; + + case ServiceQueryFilterType.Compare: + if (isAndOrExpressionNeeded) + throw new ServiceQueryException("Expression is needed before Compare filter"); + isAndOrExpressionNeeded = true; + anyWhereExpressionFound = true; + continue; + + case ServiceQueryFilterType.Null: + if (isAndOrExpressionNeeded) + throw new ServiceQueryException("Expression is needed before Compare filter"); + isAndOrExpressionNeeded = true; + anyWhereExpressionFound = true; + continue; + + case ServiceQueryFilterType.Set: + if (isAndOrExpressionNeeded) + throw new ServiceQueryException("Expression is needed before Compare filter"); + isAndOrExpressionNeeded = true; + anyWhereExpressionFound = true; + continue; + + case ServiceQueryFilterType.Expression: + switch (item.ExpressionType) + { + case ServiceQueryExpressionType.Begin: + beginendstack.Push(ServiceQueryExpressionType.Begin); + if (isAndOrExpressionNeeded) + isAndOrExpressionNeeded = false; + continue; + + case ServiceQueryExpressionType.End: + if (beginendstack.Count == 0) + throw new ServiceQueryException("End Expression is before Begin"); + beginendstack.Pop(); + if (isAndOrExpressionNeeded) + isAndOrExpressionNeeded = false; + isAndOrExpressionNeeded = true; + continue; + + case ServiceQueryExpressionType.And: + if (isAndOrExpressionNeeded) + isAndOrExpressionNeeded = false; + else + throw new ServiceQueryException("And Expression is not needed"); + continue; + + case ServiceQueryExpressionType.Or: + if (isAndOrExpressionNeeded) + isAndOrExpressionNeeded = false; + else + throw new ServiceQueryException("Or Expression is not needed"); + continue; + } + continue; + // ALl others don't matter + } + } + if (anyWhereExpressionFound && !isAndOrExpressionNeeded) + throw new Exception("Ending expression is missing"); + if (beginendstack.Count > 0) + throw new ServiceQueryException("Begin and End expression counts do not match"); + } + private static object GetParsedPropertyType(PropertyInfo prop, string value) { if (prop.PropertyType == typeof(bool)) @@ -1021,6 +1122,16 @@ private static object GetParsedPropertyType(PropertyInfo prop, string value) return new char?(); return new char?(char.Parse(value)); } +#if NET6_0_OR_GREATER + if (prop.PropertyType == typeof(DateOnly)) + return DateOnly.Parse(value); + if (prop.PropertyType == typeof(DateOnly?)) + { + if (string.IsNullOrEmpty(value)) + return new DateOnly?(); + return new DateOnly?(DateOnly.Parse(value)); + } +#endif if (prop.PropertyType == typeof(DateTime)) return DateTime.Parse(value, null, System.Globalization.DateTimeStyles.RoundtripKind); if (prop.PropertyType == typeof(DateTime?)) @@ -1105,6 +1216,16 @@ private static object GetParsedPropertyType(PropertyInfo prop, string value) } if (prop.PropertyType == typeof(string)) return value; +#if NET6_0_OR_GREATER + if (prop.PropertyType == typeof(TimeOnly)) + return TimeOnly.Parse(value); + if (prop.PropertyType == typeof(TimeOnly?)) + { + if (string.IsNullOrEmpty(value)) + return new TimeOnly?(); + return new TimeOnly?(TimeOnly.Parse(value)); + } +#endif if (prop.PropertyType == typeof(TimeSpan)) return TimeSpan.Parse(value); if (prop.PropertyType == typeof(TimeSpan?)) @@ -1239,9 +1360,6 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery if (filter == null) return null; - //Get the filters back in grouped sets - ServiceQueryFilterSet filterSet = GetFilterSet(serviceQuery); - //Get type and property info of the base type Type entityType = typeof(T); var properties = entityType.GetProperties(); @@ -1263,6 +1381,9 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery if (filter.AggregateType == ServiceQueryAggregateType.Count) return query.Count(); + //Get the filters back in grouped sets + ServiceQueryFilterSet filterSet = GetFilterSet(serviceQuery, options); + var param = Expression.Parameter(entityType, "x"); PropertyInfo prop = null; if (filter.Properties == null || filter.Properties.Count == 0) @@ -1285,6 +1406,13 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery throw new ServiceQueryException("aggregate functions not supported on char"); if (prop.PropertyType == typeof(char?)) throw new ServiceQueryException("aggregate functions not supported on char?"); +#if NET6_0_OR_GREATER + if (prop.PropertyType == typeof(DateOnly)) + throw new ServiceQueryException("aggregate functions not supported on DateOnly"); + if (prop.PropertyType == typeof(DateOnly?)) + throw new ServiceQueryException("aggregate functions not supported on DateOnly?"); +#endif + if (prop.PropertyType == typeof(DateTime)) throw new ServiceQueryException("aggregate functions not supported on DateTime"); if (prop.PropertyType == typeof(DateTime?)) @@ -1293,6 +1421,12 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery throw new ServiceQueryException("aggregate functions not supported on DateTimeOffset"); if (prop.PropertyType == typeof(DateTimeOffset?)) throw new ServiceQueryException("aggregate functions not supported on DateTimeOffset?"); +#if NET6_0_OR_GREATER + if (prop.PropertyType == typeof(TimeOnly)) + throw new ServiceQueryException("aggregate functions not supported on TimeOnly"); + if (prop.PropertyType == typeof(TimeOnly?)) + throw new ServiceQueryException("aggregate functions not supported on TimeOnly?"); +#endif if (prop.PropertyType == typeof(TimeSpan)) throw new ServiceQueryException("aggregate functions not supported on TimeSpan"); if (prop.PropertyType == typeof(TimeSpan?)) @@ -1313,9 +1447,6 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery case ServiceQueryAggregateType.Sum: return Convert.ToDouble(query.Sum(decimalSelector)); - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(decimal?)) @@ -1346,9 +1477,6 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery if (sval.HasValue) return Convert.ToDouble(sval.Value); return null; - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(double)) @@ -1367,9 +1495,6 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery case ServiceQueryAggregateType.Sum: return query.Sum(doubleSelector); - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(double?)) @@ -1388,9 +1513,6 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery case ServiceQueryAggregateType.Sum: return query.Sum(doubleNSelector); - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(Guid)) @@ -1413,9 +1535,6 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery case ServiceQueryAggregateType.Sum: throw new ServiceQueryException("sum not supported on short"); - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(short?)) @@ -1434,9 +1553,6 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery case ServiceQueryAggregateType.Sum: throw new ServiceQueryException("sum not supported on short?"); - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(int)) @@ -1455,9 +1571,6 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery case ServiceQueryAggregateType.Sum: return query.Sum(intSelector); - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(int?)) @@ -1476,9 +1589,6 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery case ServiceQueryAggregateType.Sum: return query.Sum(intNSelector); - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(long)) @@ -1497,9 +1607,6 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery case ServiceQueryAggregateType.Sum: return query.Sum(longSelector); - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(long?)) @@ -1518,9 +1625,6 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery case ServiceQueryAggregateType.Sum: return query.Sum(longNSelector); - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(sbyte)) @@ -1539,9 +1643,6 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery case ServiceQueryAggregateType.Sum: throw new ServiceQueryException("sum not supported on sbyte"); - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(sbyte?)) @@ -1560,9 +1661,6 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery case ServiceQueryAggregateType.Sum: throw new ServiceQueryException("sum not supported on sbyte?"); - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(Single)) @@ -1581,9 +1679,6 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery case ServiceQueryAggregateType.Sum: return query.Sum(singleSelector); - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(Single?)) @@ -1602,24 +1697,17 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery case ServiceQueryAggregateType.Sum: return query.Sum(singleNSelector); - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(string)) throw new ServiceQueryException("aggregate functions not supported on string"); - if (prop.PropertyType == typeof(TimeSpan)) - throw new ServiceQueryException("aggregate functions not supported on TimeSpan"); - if (prop.PropertyType == typeof(TimeSpan?)) - throw new ServiceQueryException("aggregate functions not supported on TimeSpan?"); if (prop.PropertyType == typeof(UInt16)) { var uint16Selector = Expression.Lambda>(Expression.Property(param, prop), param); switch (filter.AggregateType) { case ServiceQueryAggregateType.Average: - throw new ServiceQueryException("average not supported on UInt32"); + throw new ServiceQueryException("average not supported on UInt16"); case ServiceQueryAggregateType.Maximum: return query.Max(uint16Selector); @@ -1628,10 +1716,7 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery return query.Min(uint16Selector); case ServiceQueryAggregateType.Sum: - throw new ServiceQueryException("sum not supported on UInt32"); - - default: - throw new ServiceQueryException("aggregate not defined"); + throw new ServiceQueryException("sum not supported on UInt16"); } } if (prop.PropertyType == typeof(UInt16?)) @@ -1640,7 +1725,7 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery switch (filter.AggregateType) { case ServiceQueryAggregateType.Average: - throw new ServiceQueryException("average not supported on UInt32?"); + throw new ServiceQueryException("average not supported on UInt16?"); case ServiceQueryAggregateType.Maximum: return query.Max(uint16NSelector); @@ -1649,10 +1734,7 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery return query.Min(uint16NSelector); case ServiceQueryAggregateType.Sum: - throw new ServiceQueryException("sum not supported on UInt32?"); - - default: - throw new ServiceQueryException("aggregate not defined"); + throw new ServiceQueryException("sum not supported on UInt16?"); } } if (prop.PropertyType == typeof(UInt32)) @@ -1671,9 +1753,6 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery case ServiceQueryAggregateType.Sum: throw new ServiceQueryException("sum not supported on UInt32"); - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(UInt32?)) @@ -1692,9 +1771,6 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery case ServiceQueryAggregateType.Sum: throw new ServiceQueryException("sum not supported on UInt32?"); - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(UInt64)) @@ -1724,7 +1800,7 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery switch (filter.AggregateType) { case ServiceQueryAggregateType.Average: - throw new ServiceQueryException("average not supported on UInt32?"); + throw new ServiceQueryException("average not supported on UInt64?"); case ServiceQueryAggregateType.Maximum: return query.Max(uint64NSelector); @@ -1733,10 +1809,7 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery return query.Min(uint64NSelector); case ServiceQueryAggregateType.Sum: - throw new ServiceQueryException("sum not supported on UInt32?"); - - default: - throw new ServiceQueryException("aggregate not defined"); + throw new ServiceQueryException("sum not supported on UInt64?"); } } #if NET7_0_OR_GREATER @@ -1749,43 +1822,37 @@ public static ServiceQueryResponse Execute(this IServiceQuery serviceQuery throw new ServiceQueryException("average not supported on UInt128"); case ServiceQueryAggregateType.Maximum: - return Convert.ToDouble(query.Max(uint128Selector)); + return (double)query.Max(uint128Selector); case ServiceQueryAggregateType.Minimum: - return Convert.ToDouble(query.Min(uint128Selector)); + return (double)query.Min(uint128Selector); case ServiceQueryAggregateType.Sum: throw new ServiceQueryException("sum not supported on UInt128"); - - default: - throw new ServiceQueryException("aggregate not defined"); } } if (prop.PropertyType == typeof(UInt128?)) { - var uint128NSelector = Expression.Lambda>(Expression.Property(param, prop), param); + var uint128NSelector = Expression.Lambda>(Expression.Property(param, prop), param); switch (filter.AggregateType) { case ServiceQueryAggregateType.Average: throw new ServiceQueryException("average not supported on UInt128?"); case ServiceQueryAggregateType.Maximum: - var mauint128Nval = query.Max(uint128NSelector); - if (mauint128Nval.HasValue) - return Convert.ToDouble(mauint128Nval.Value); + var val = query.Max(uint128NSelector); + if (val.HasValue) + return (double)val.Value; return null; case ServiceQueryAggregateType.Minimum: - var miuint128Nval = query.Min(uint128NSelector); - if (miuint128Nval.HasValue) - return Convert.ToDouble(miuint128Nval.Value); + var val2 = query.Min(uint128NSelector); + if (val2.HasValue) + return (double)val2.Value; return null; case ServiceQueryAggregateType.Sum: throw new ServiceQueryException("sum not supported on UInt128?"); - - default: - throw new ServiceQueryException("aggregate not defined"); } } #endif diff --git a/src/ServiceQueryV2/Extensions/ServiceQueryRequestExtensions.cs b/src/ServiceQueryV2/Extensions/ServiceQueryRequestExtensions.cs index 3f07416..91c7479 100644 --- a/src/ServiceQueryV2/Extensions/ServiceQueryRequestExtensions.cs +++ b/src/ServiceQueryV2/Extensions/ServiceQueryRequestExtensions.cs @@ -1,4 +1,5 @@ -using System.Dynamic; +using System; +using System.Dynamic; using System.Linq; using System.Threading.Tasks; @@ -226,6 +227,7 @@ public static ServiceQuery GetServiceQuery(this IServiceQueryRequest request) builder.Sum(filter.Properties?.FirstOrDefault()); continue; } + throw new ServiceQueryException($"filterType {filter.FilterType} not found"); } return builder.Build(); diff --git a/src/ServiceQueryV2/Model/ServiceQueryOptions.cs b/src/ServiceQueryV2/Model/ServiceQueryOptions.cs index 25d3d0a..da9f853 100644 --- a/src/ServiceQueryV2/Model/ServiceQueryOptions.cs +++ b/src/ServiceQueryV2/Model/ServiceQueryOptions.cs @@ -19,5 +19,11 @@ public class ServiceQueryOptions /// Default is false. /// public bool PropertyNameCaseSensitive { get; set; } + + /// + /// Determine if missing BEGIN/END/AND/OR expressions throw an exception + /// or try to add them missing ones automatiically. + /// + public bool AllowMissingExpressions { get; set; } } } \ No newline at end of file diff --git a/src/ServiceQueryV2/ServiceQuery.csproj b/src/ServiceQueryV2/ServiceQuery.csproj index ba0adba..f2065cc 100644 --- a/src/ServiceQueryV2/ServiceQuery.csproj +++ b/src/ServiceQueryV2/ServiceQuery.csproj @@ -1,7 +1,7 @@  - 2.0.1 + 2.1.0 ServiceQuery allows dynamic querying of data over service boundaries. Visit http://ServiceQuery.com to learn more. ServiceQuery holomodular diff --git a/src/Tests/ServiceQueryV2Net6.Xunit/ServiceQueryV2Net6.Xunit.csproj b/src/Tests/ServiceQueryV2Net6.Xunit/ServiceQueryV2Net6.Xunit.csproj index 4cb08f4..be9735a 100644 --- a/src/Tests/ServiceQueryV2Net6.Xunit/ServiceQueryV2Net6.Xunit.csproj +++ b/src/Tests/ServiceQueryV2Net6.Xunit/ServiceQueryV2Net6.Xunit.csproj @@ -12,36 +12,38 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Tests/ServiceQueryV2Net7.Xunit/ServiceQueryV2Net7.Xunit.csproj b/src/Tests/ServiceQueryV2Net7.Xunit/ServiceQueryV2Net7.Xunit.csproj index b10f515..e091a99 100644 --- a/src/Tests/ServiceQueryV2Net7.Xunit/ServiceQueryV2Net7.Xunit.csproj +++ b/src/Tests/ServiceQueryV2Net7.Xunit/ServiceQueryV2Net7.Xunit.csproj @@ -13,35 +13,38 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Tests/ServiceQueryV2Net8.Xunit/ServiceQueryV2Net8.Xunit.csproj b/src/Tests/ServiceQueryV2Net8.Xunit/ServiceQueryV2Net8.Xunit.csproj index faa802f..0208006 100644 --- a/src/Tests/ServiceQueryV2Net8.Xunit/ServiceQueryV2Net8.Xunit.csproj +++ b/src/Tests/ServiceQueryV2Net8.Xunit/ServiceQueryV2Net8.Xunit.csproj @@ -10,37 +10,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Tests/TestFiles/V2/AggregateAverageTests.cs b/src/Tests/TestFiles/V2/AggregateAverageTests.cs new file mode 100644 index 0000000..79210c4 --- /dev/null +++ b/src/Tests/TestFiles/V2/AggregateAverageTests.cs @@ -0,0 +1,933 @@ +namespace ServiceQuery.Xunit +{ + public class AggregateAverageTests : AggregateAverageTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class AggregateAverageTests : BaseTest where T : class + { + public bool ValidateNullLong = true; + + public bool CosmosIntLongRounding = false; + + [Fact] + public void AverageStandardTest() + { + var sourceQueryable = GetTestList(); + IServiceQuery serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.BoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.ByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.ByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.CharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.DateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.DateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.DateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.DecimalVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == (double)6 / 4); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == (double)6 / 4); + } + + // Double + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.DoubleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == (double)6 / 4); + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.DoubleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == (double)6 / 4); + + // Float + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.FloatVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == (double)6 / 4); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == (double)6 / 4); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.GuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + if (CosmosIntLongRounding) + { + // Int + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.IntVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == Math.Round((double)6 / 4)); + + // Long + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.LongVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == Math.Round((double)6 / 4)); + } + else + { + // Int + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.IntVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == (double)6 / 4); + + // Long + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.LongVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == (double)6 / 4); + } + + // SByte + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.SByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.ShortVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.SingleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == (double)6 / 4); + + // String + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.StringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.TimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.TimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.UInt128Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } +#endif + + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.UInt64Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.UInt32Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.UInt16Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + + [Fact] + public void AverageRequestTest() + { + var sourceQueryable = GetTestList(); + IServiceQueryRequest serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.BoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.ByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.ByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.CharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.DateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + + // DateOnly + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.DateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.DateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.DecimalVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == (double)6 / 4); + } + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.DoubleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == (double)6 / 4); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == (double)6 / 4); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.FloatVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == (double)6 / 4); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.GuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + if (CosmosIntLongRounding) + { + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.IntVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == Math.Round((double)6 / 4)); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.LongVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == Math.Round((double)6 / 4)); + } + else + { + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.IntVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == (double)6 / 4); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.LongVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == (double)6 / 4); + } + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.SByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.ShortVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.SingleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == (double)6 / 4); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.StringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + + // TimeOnly + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.TimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.TimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.UInt128Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } +#endif + + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.UInt64Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.UInt32Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.UInt16Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + + [Fact] + public void NullAverageStandardTest() + { + var sourceQueryable = GetTestList(); + IServiceQuery serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullBoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullCharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullDateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullDateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullDecimalVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } + + // Double + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullDoubleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Float + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullFloatVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullGuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullIntVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Long + if (ValidateNullLong) + { + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullLongVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } + + // SByte + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullSByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullShortVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullSingleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // String + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullStringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullTimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullTimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullUInt128Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } +#endif + + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullUInt64Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullUInt32Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Average(nameof(TestClass.NullUInt16Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + + [Fact] + public void NullAverageRequestTest() + { + var sourceQueryable = GetTestList(); + IServiceQueryRequest serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullBoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullCharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullDateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullDateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullDecimalVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullDoubleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullFloatVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullGuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullIntVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Long + if (ValidateNullLong) + { + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullLongVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullSByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullShortVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullSingleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullStringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullTimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullTimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullUInt128Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } +#endif + + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullUInt64Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullUInt32Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Average(nameof(TestClass.NullUInt16Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/AggregateCountTests.cs b/src/Tests/TestFiles/V2/AggregateCountTests.cs new file mode 100644 index 0000000..0b8c56a --- /dev/null +++ b/src/Tests/TestFiles/V2/AggregateCountTests.cs @@ -0,0 +1,61 @@ +namespace ServiceQuery.Xunit +{ + public class AggregateCountTests : AggregateCountTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class AggregateCountTests : BaseTest where T : class + { + [Fact] + public void CountStandardTest() + { + var sourceQueryable = GetTestList(); + IServiceQuery serviceQuery; + double? result; + + serviceQuery = ServiceQueryBuilder.New().Count().Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 4); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 4); + + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Count().Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 1); + } + + [Fact] + public void CountRequestTest() + { + var sourceQueryable = GetTestList(); + IServiceQueryRequest serviceQuery; + double? result; + + serviceQuery = ServiceQueryRequestBuilder.New().Count().Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 4); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 4); + + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Count().Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 1); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/AggregateMaximumTests.cs b/src/Tests/TestFiles/V2/AggregateMaximumTests.cs new file mode 100644 index 0000000..3d8311b --- /dev/null +++ b/src/Tests/TestFiles/V2/AggregateMaximumTests.cs @@ -0,0 +1,1061 @@ +namespace ServiceQuery.Xunit +{ + public class AggregateMaximumTests : AggregateMaximumTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class AggregateMaximumTests : BaseTest where T : class + { + [Fact] + public void MaximumStandardTest() + { + var sourceQueryable = GetTestList(); + IServiceQuery serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.BoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.ByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.ByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.CharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.DateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + + // DateOnly + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.DateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.DateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.DecimalVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + } + + // Double + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.DoubleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Float + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.FloatVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.GuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.IntVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Long + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.LongVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.SByteVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Short + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.ShortVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Single + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.SingleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // String + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.StringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + + // TimeOnly + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.TimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.TimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.UInt128Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + } +#endif + + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.UInt64Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.UInt32Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.UInt16Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + } + + [Fact] + public void MaximumRequestTest() + { + var sourceQueryable = GetTestList(); + IServiceQueryRequest serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.BoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.ByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.ByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.CharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.DateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.DateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.DateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.DecimalVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + } + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.DoubleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.FloatVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.GuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.IntVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.LongVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.SByteVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.ShortVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.SingleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.StringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.TimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.TimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.UInt128Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + } +#endif + + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.UInt64Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.UInt32Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.UInt16Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + } + + [Fact] + public void NullMaximumStandardTest() + { + var sourceQueryable = GetTestList(); + IServiceQuery serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullBoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullCharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullDateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullDateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullDecimalVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } + + // Double + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullDoubleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Float + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullFloatVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullGuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullIntVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Long + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullLongVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullSByteVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Short + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullShortVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Single + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullSingleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // String + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullStringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullTimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullTimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullUInt128Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } +#endif + + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullUInt64Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullUInt32Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullUInt16Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } + + [Fact] + public void NullMaximumRequestTest() + { + var sourceQueryable = GetTestList(); + IServiceQueryRequest serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullBoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullCharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullDateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullDateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullDecimalVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullDoubleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullFloatVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullGuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullIntVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullLongVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullSByteVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullShortVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullSingleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullStringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullTimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullTimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullUInt128Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } +#endif + + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullUInt64Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullUInt32Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullUInt16Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } + + [Fact] + public void NullCopyMaximumStandardTest() + { + var sourceQueryable = GetTestNullCopyList(); + IServiceQuery serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullBoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullCharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullDateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullDateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullDecimalVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + } + + // Double + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullDoubleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Float + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullFloatVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullGuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullIntVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Long + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullLongVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullSByteVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Short + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullShortVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Single + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullSingleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // String + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullStringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullTimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullTimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullUInt128Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + } +#endif + + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullUInt64Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullUInt32Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Maximum(nameof(TestClass.NullUInt16Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + } + + [Fact] + public void NullCopyMaximumRequestTest() + { + var sourceQueryable = GetTestNullCopyList(); + IServiceQueryRequest serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullBoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullCharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullDateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullDateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullDecimalVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + } + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullDoubleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullFloatVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullGuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullIntVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullLongVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullSByteVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullShortVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullSingleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullStringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullTimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullTimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullUInt128Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + } +#endif + + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullUInt64Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullUInt32Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.NullUInt16Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 3); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/AggregateMinimumTests.cs b/src/Tests/TestFiles/V2/AggregateMinimumTests.cs new file mode 100644 index 0000000..830dff3 --- /dev/null +++ b/src/Tests/TestFiles/V2/AggregateMinimumTests.cs @@ -0,0 +1,1052 @@ +namespace ServiceQuery.Xunit +{ + public class AggregateMinimumTests : AggregateMinimumTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class AggregateMinimumTests : BaseTest where T : class + { + [Fact] + public void MinimumStandardTest() + { + var sourceQueryable = GetTestList(); + IServiceQuery serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.BoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.ByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.ByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.CharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.DateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.DateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.DateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.DecimalVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + } + + // Double + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.DoubleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Float + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.FloatVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.GuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.IntVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Long + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.LongVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.SByteVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Short + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.ShortVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Single + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.SingleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // String + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.StringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.TimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.TimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.UInt128Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + } +#endif + + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.UInt64Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.UInt32Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.UInt16Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + } + + [Fact] + public void MinimumRequestTest() + { + var sourceQueryable = GetTestList(); + IServiceQueryRequest serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.BoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.ByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.ByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.CharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.DateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.DateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.DateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.DecimalVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + } + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.DoubleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.FloatVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.GuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.IntVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.LongVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.SByteVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.ShortVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.SingleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.StringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.TimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.TimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.UInt128Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.UInt64Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.UInt32Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.UInt16Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + } + + [Fact] + public void NullMinimumStandardTest() + { + var sourceQueryable = GetTestList(); + IServiceQuery serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullBoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullCharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullDateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullDateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullDecimalVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } + + // Double + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullDoubleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Float + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullFloatVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullGuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullIntVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Long + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullLongVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullSByteVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Short + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullShortVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Single + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullSingleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // String + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullStringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullTimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullTimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullUInt128Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullUInt64Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullUInt32Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullUInt16Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } + + [Fact] + public void NullMinimumRequestTest() + { + var sourceQueryable = GetTestList(); + IServiceQueryRequest serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullBoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullCharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullDateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullDateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullDecimalVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullDoubleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullFloatVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullGuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullIntVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullLongVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullSByteVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullShortVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullSingleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullStringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullTimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullTimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullUInt128Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } +#endif + + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullUInt64Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullUInt32Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullUInt16Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == null); + } + + [Fact] + public void NullCopyMinimumStandardTest() + { + var sourceQueryable = GetTestNullCopyList(); + IServiceQuery serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullBoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullCharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullDateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullDateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullDecimalVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + } + + // Double + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullDoubleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Float + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullFloatVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullGuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullIntVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Long + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullLongVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullSByteVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Short + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullShortVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Single + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullSingleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // String + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullStringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullTimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullTimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullUInt128Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullUInt64Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullUInt32Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Minimum(nameof(TestClass.NullUInt16Val)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + } + + [Fact] + public void NullCopyMinimumRequestTest() + { + var sourceQueryable = GetTestNullCopyList(); + IServiceQueryRequest serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullBoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullCharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullDateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullDateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullDecimalVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + } + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullDoubleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullFloatVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullGuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullIntVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullLongVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullSByteVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullShortVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullSingleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullStringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullTimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullTimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullUInt128Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + } +#endif + + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullUInt64Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullUInt32Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Minimum(nameof(TestClass.NullUInt16Val)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 0); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/AggregateSumTests.cs b/src/Tests/TestFiles/V2/AggregateSumTests.cs new file mode 100644 index 0000000..73f327b --- /dev/null +++ b/src/Tests/TestFiles/V2/AggregateSumTests.cs @@ -0,0 +1,797 @@ +namespace ServiceQuery.Xunit +{ + public class AggregateSumTests : AggregateSumTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class AggregateSumTests : BaseTest where T : class + { + public bool NullSumIsNull = false; + + [Fact] + public void SumStandardTest() + { + var sourceQueryable = GetTestList(); + IServiceQuery serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.BoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.ByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.ByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.CharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.DateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.DateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.DateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.DecimalVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 6); + } + + // Double + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.DoubleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 6); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 6); + + // Float + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.FloatVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 6); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.GuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.IntVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 6); + + // Long + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.LongVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 6); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.SByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.ShortVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.SingleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + Assert.True(result == 6); + + // String + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.StringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.TimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.TimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.UInt128Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.UInt64Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.UInt32Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.UInt16Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + + [Fact] + public void SumRequestTest() + { + var sourceQueryable = GetTestList(); + IServiceQueryRequest serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.BoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.ByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.ByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.CharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.DateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.DateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.DateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.DecimalVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 6); + } + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.DoubleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 6); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 6); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.FloatVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 6); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.GuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.IntVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 6); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.LongVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 6); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.SByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.ShortVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.SingleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + Assert.True(result == 6); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.StringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.TimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.TimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.UInt128Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.UInt64Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.UInt32Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.UInt16Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + + [Fact] + public void NullSumStandardTest() + { + var sourceQueryable = GetTestList(); + IServiceQuery serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullBoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullCharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullDateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullDateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullDecimalVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + if (NullSumIsNull) + Assert.True(result == null); + else + Assert.True(result == 0); + } + + // Double + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullDoubleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + if (NullSumIsNull) + Assert.True(result == null); + else + Assert.True(result == 0); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + if (NullSumIsNull) + Assert.True(result == null); + else + Assert.True(result == 0); + + // Float + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullFloatVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + if (NullSumIsNull) + Assert.True(result == null); + else + Assert.True(result == 0); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullGuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullIntVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + if (NullSumIsNull) + Assert.True(result == null); + else + Assert.True(result == 0); + + // Long + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullLongVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + if (NullSumIsNull) + Assert.True(result == null); + else + Assert.True(result == 0); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullSByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullShortVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullSingleVal)).Build(); + result = serviceQuery.ExecuteAggregate(sourceQueryable); + if (NullSumIsNull) + Assert.True(result == null); + else + Assert.True(result == 0); + + // String + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullStringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullTimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullTimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullUInt128Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullUInt64Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullUInt32Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Sum(nameof(TestClass.NullUInt16Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.ExecuteAggregate(sourceQueryable); + }); + } + + [Fact] + public void NullSumRequestTest() + { + var sourceQueryable = GetTestList(); + IServiceQueryRequest serviceQuery; + double? result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullBoolVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullByteArrayVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullCharVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullDateOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + // DateTime + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullDateTimeVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullDecimalVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + if (NullSumIsNull) + Assert.True(result == null); + else + Assert.True(result == 0); + } + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullDoubleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + if (NullSumIsNull) + Assert.True(result == null); + else + Assert.True(result == 0); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + if (NullSumIsNull) + Assert.True(result == null); + else + Assert.True(result == 0); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullFloatVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + if (NullSumIsNull) + Assert.True(result == null); + else + Assert.True(result == 0); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullGuidVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullIntVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + if (NullSumIsNull) + Assert.True(result == null); + else + Assert.True(result == 0); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullLongVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + if (NullSumIsNull) + Assert.True(result == null); + else + Assert.True(result == 0); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullSByteVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullShortVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullSingleVal)).Build(); + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + if (NullSumIsNull) + Assert.True(result == null); + else + Assert.True(result == 0); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullStringVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullTimeOnlyVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullTimeSpanVal)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullUInt128Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullUInt64Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullUInt32Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Sum(nameof(TestClass.NullUInt16Val)).Build(); + Assert.Throws(() => + { + result = serviceQuery.GetServiceQuery().ExecuteAggregate(sourceQueryable); + }); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/BaseTest.cs b/src/Tests/TestFiles/V2/BaseTest.cs new file mode 100644 index 0000000..1ffee04 --- /dev/null +++ b/src/Tests/TestFiles/V2/BaseTest.cs @@ -0,0 +1,34 @@ +namespace ServiceQuery.Xunit +{ + public abstract class BaseTest where T : class + { + public abstract IQueryable GetTestList(); + + public abstract IQueryable GetTestNullCopyList(); + + public bool ValidateUInt128 = true; + public bool ValidateUInt64 = true; + public bool ValidateDateTimeOffset = true; + public bool ValidateTimeSpan = true; + public bool ValidateDecimal = true; + } + + public class BaseTest : BaseTest + { + public BaseTest() + { } + + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ComparisonBetweenTests.cs b/src/Tests/TestFiles/V2/ComparisonBetweenTests.cs new file mode 100644 index 0000000..826fbce --- /dev/null +++ b/src/Tests/TestFiles/V2/ComparisonBetweenTests.cs @@ -0,0 +1,1603 @@ +namespace ServiceQuery.Xunit +{ + public class ComparisonBetweenTests : ComparisonBetweenTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class ComparisonBetweenTests : BaseTest where T : class, ITestClass, new() + { + [Fact] + public void SyncBetweenStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.BoolVal), "false", "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result =testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.ByteVal), "0", "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Char + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.CharVal), "a", "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly1 = new T().GetDefault0Record().DateOnlyVal; + var tempDateOnly2 = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.DateOnlyVal), tempDateOnly1.ToString("o"), tempDateOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset1 = new T().GetDefault0Record().DateTimeOffsetVal; + var tempDateTimeOffset2 = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset1.ToString("o"), tempDateTimeOffset2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // DateTime + var tempDateTime1 = new T().GetDefault0Record().DateTimeVal; + var tempDateTime2 = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.DateTimeVal), tempDateTime1.ToString("o"), tempDateTime2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.DecimalVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Double + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.DoubleVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Float + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.FloatVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Guid +#if NET6_0 + var tempg = new T().GetDefault1Record(); + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.GuidVal), Guid.Empty.ToString(), tempg.GuidVal.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif +#if NET7_0_OR_GREATER + var tempg = new T().GetDefault1Record(); + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.GuidVal), Guid.Empty.ToString(), tempg.GuidVal.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // Int + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.IntVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Long + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.LongVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.SByteVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Short + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.ShortVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Single + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.SingleVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // String + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.StringVal), "a", "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly1 = new T().GetDefault0Record().TimeOnlyVal; + var tempTimeOnly2 = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.TimeOnlyVal), tempTimeOnly1.ToString("o"), tempTimeOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString(), TimeSpan.FromMilliseconds(2).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.UInt64Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.UInt32Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.UInt16Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncBetweenRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.BoolVal), "false", "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result =testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.ByteVal), "0", "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.CharVal), "a", "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset1 = new T().GetDefault0Record().DateTimeOffsetVal; + var tempDateTimeOffset2 = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset1.ToString("o"), tempDateTimeOffset2.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly1 = new T().GetDefault0Record().DateOnlyVal; + var tempDateOnly2 = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.DateOnlyVal), tempDateOnly1.ToString("o"), tempDateOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // DateTime + var tempDateTime1 = new T().GetDefault0Record().DateTimeVal; + var tempDateTime2 = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.DateTimeVal), tempDateTime1.ToString("o"), tempDateTime2.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.DecimalVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.DoubleVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.FloatVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Guid +#if NET6_0 + var tempg = new T().GetDefault1Record(); + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.GuidVal), Guid.Empty.ToString(), tempg.GuidVal.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif +#if NET7_0_OR_GREATER + var tempg = new T().GetDefault1Record(); + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.GuidVal), Guid.Empty.ToString(), tempg.GuidVal.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.IntVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.LongVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.SByteVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.ShortVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.SingleVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.StringVal), "a", "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly1 = new T().GetDefault0Record().TimeOnlyVal; + var tempTimeOnly2 = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.TimeOnlyVal), tempTimeOnly1.ToString("o"), tempTimeOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString(), TimeSpan.FromMilliseconds(2).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.UInt64Val), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.UInt32Val), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.UInt16Val), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncNullBetweenStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullBoolVal), "false", "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result =testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullByteVal), "0", "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullCharVal), "a", "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly1 = new T().GetDefault0Record().DateOnlyVal; + var tempDateOnly2 = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullDateOnlyVal), tempDateOnly1.ToString("o"), tempDateOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset1 = new T().GetDefault0Record().DateTimeOffsetVal; + var tempDateTimeOffset2 = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset1.ToString("o"), tempDateTimeOffset2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // DateTime + var tempDateTime1 = new T().GetDefault0Record().DateTimeVal; + var tempDateTime2 = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullDateTimeVal), tempDateTime1.ToString("o"), tempDateTime2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullDecimalVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullDoubleVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullFloatVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Guid +#if NET6_0 + var tempg = new T().GetDefault1Record(); + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullGuidVal), Guid.Empty.ToString(), tempg.GuidVal.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif +#if NET7_0_OR_GREATER + var tempg = new T().GetDefault1Record(); + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullGuidVal), Guid.Empty.ToString(), tempg.GuidVal.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // Int + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullIntVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullLongVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullSByteVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullShortVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullSingleVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullStringVal), "a", "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly1 = new T().GetDefault0Record().TimeOnlyVal; + var tempTimeOnly2 = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly1.ToString("o"), tempTimeOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString(), TimeSpan.FromMilliseconds(2).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullUInt64Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullUInt32Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullUInt16Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullBetweenRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullBoolVal), "false", "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result =testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullByteVal), "0", "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullCharVal), "a", "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // DateOnly + var tempDateOnly1 = new T().GetDefault0Record().DateOnlyVal; + var tempDateOnly2 = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullDateOnlyVal), tempDateOnly1.ToString("o"), tempDateOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset1 = new T().GetDefault0Record().DateTimeOffsetVal; + var tempDateTimeOffset2 = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset1.ToString("o"), tempDateTimeOffset2.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // DateTime + var tempDateTime1 = new T().GetDefault0Record().DateTimeVal; + var tempDateTime2 = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullDateTimeVal), tempDateTime1.ToString("o"), tempDateTime2.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullDecimalVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullDoubleVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullFloatVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Guid +#if NET6_0 + var tempg = new T().GetDefault1Record(); + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullGuidVal), Guid.Empty.ToString(), tempg.GuidVal.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif +#if NET7_0_OR_GREATER + var tempg = new T().GetDefault1Record(); + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullGuidVal), Guid.Empty.ToString(), tempg.GuidVal.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullIntVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullLongVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullSByteVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullShortVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullSingleVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullStringVal), "a", "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString(), TimeSpan.FromMilliseconds(2).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullUInt128Val), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullUInt64Val), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullUInt32Val), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullUInt16Val), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullCopyBetweenStandardTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullBoolVal), "false", "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result =testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullByteVal), "0", "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Char + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullCharVal), "a", "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly1 = new T().GetDefault0Record().DateOnlyVal; + var tempDateOnly2 = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullDateOnlyVal), tempDateOnly1.ToString("o"), tempDateOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset1 = new T().GetDefault0Record().DateTimeOffsetVal; + var tempDateTimeOffset2 = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset1.ToString("o"), tempDateTimeOffset2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // DateTime + var tempDateTime1 = new T().GetDefault0Record().DateTimeVal; + var tempDateTime2 = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullDateTimeVal), tempDateTime1.ToString("o"), tempDateTime2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullDecimalVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Double + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullDoubleVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Float + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullFloatVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Guid +#if NET6_0 + var tempg = new T().GetDefault1Record(); + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullGuidVal), Guid.Empty.ToString(), tempg.GuidVal.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif +#if NET7_0_OR_GREATER + var tempg = new T().GetDefault1Record(); + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullGuidVal), Guid.Empty.ToString(), tempg.GuidVal.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // Int + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullIntVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Long + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullLongVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullSByteVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Short + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullShortVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Single + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullSingleVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // String + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullStringVal), "a", "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly1 = new T().GetDefault0Record().TimeOnlyVal; + var tempTimeOnly2 = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly1.ToString("o"), tempTimeOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString(), TimeSpan.FromMilliseconds(2).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullUInt128Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullUInt64Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullUInt32Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Between(nameof(TestClass.NullUInt16Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncNullCopyBetweenRequestTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullBoolVal), "false", "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result =testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullByteVal), "0", "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullCharVal), "a", "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // DateOnly + var tempDateOnly1 = new T().GetDefault0Record().DateOnlyVal; + var tempDateOnly2 = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullDateOnlyVal), tempDateOnly1.ToString("o"), tempDateOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset1 = new T().GetDefault0Record().DateTimeOffsetVal; + var tempDateTimeOffset2 = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset1.ToString("o"), tempDateTimeOffset2.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // DateTime + var tempDateTime1 = new T().GetDefault0Record().DateTimeVal; + var tempDateTime2 = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullDateTimeVal), tempDateTime1.ToString("o"), tempDateTime2.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullDecimalVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullDoubleVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullFloatVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Guid +#if NET6_0 + var tempg = new T().GetDefault1Record(); + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullGuidVal), Guid.Empty.ToString(), tempg.GuidVal.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif +#if NET7_0_OR_GREATER + var tempg = new T().GetDefault1Record(); + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullGuidVal), Guid.Empty.ToString(), tempg.GuidVal.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullIntVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullLongVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullSByteVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullShortVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullSingleVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullStringVal), "a", "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString(), TimeSpan.FromMilliseconds(2).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullUInt128Val), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullUInt64Val), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullUInt32Val), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Between(nameof(TestClass.NullUInt16Val), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ComparisonContainsTests.cs b/src/Tests/TestFiles/V2/ComparisonContainsTests.cs new file mode 100644 index 0000000..51b5c91 --- /dev/null +++ b/src/Tests/TestFiles/V2/ComparisonContainsTests.cs @@ -0,0 +1,1188 @@ +namespace ServiceQuery.Xunit +{ + public class ComparisonContainsTests : ComparisonContainsTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class ComparisonContainsTests : BaseTest where T : class, ITestClass, new() + { + [Fact] + public void SyncContainsStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.BoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.ByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.CharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.DecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.DoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.FloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.IntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.LongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.SByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.ShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.SingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.StringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.UInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.UInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.UInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.UInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncContainsRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.BoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.ByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.CharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.DecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.DoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.FloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.IntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.LongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.SByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.ShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.SingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.StringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.UInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.UInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.UInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.UInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncNullContainsStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullCharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullDecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullDoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullFloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullIntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullLongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullSByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullSingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullUInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullUInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullUInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullUInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncNullContainsRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullCharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullDecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullDoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullFloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullIntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullLongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullSByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullSingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullUInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullUInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullUInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullUInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncNullCopyContainsStandardTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullCharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullDecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullDoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullFloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullIntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullLongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullSByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullSingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullUInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullUInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullUInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Contains(nameof(TestClass.NullUInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncNullCopyContainsRequestTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullCharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullDecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullDoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullFloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullIntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullLongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullSByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullSingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullUInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullUInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullUInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Contains(nameof(TestClass.NullUInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ComparisonEndsWithTests.cs b/src/Tests/TestFiles/V2/ComparisonEndsWithTests.cs new file mode 100644 index 0000000..234c3d6 --- /dev/null +++ b/src/Tests/TestFiles/V2/ComparisonEndsWithTests.cs @@ -0,0 +1,1190 @@ +namespace ServiceQuery.Xunit +{ + public class ComparisonEndsWithTests : ComparisonEndsWithTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class ComparisonEndsWithTests : BaseTest where T : class, ITestClass, new() + { + [Fact] + public void SyncEndsWithStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.BoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.ByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.CharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.DecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.DoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.FloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.IntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.LongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.SByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.ShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.SingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.StringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.UInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.UInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.UInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.UInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncEndsWithRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.BoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.ByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.CharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.DecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.DoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.FloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.IntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.LongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.SByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.ShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.SingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.StringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.UInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.UInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.UInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.UInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncNullEndsWithStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullCharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullDecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullDoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullFloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullIntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullLongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullSByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullSingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullUInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullUInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullUInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullUInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncNullEndsWithRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullCharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullDecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullDoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullFloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullIntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullLongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullSByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullSingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullUInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullUInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullUInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullUInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncNullCopyEndsWithStandardTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullCharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullDecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullDoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullFloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullIntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullLongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullSByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullSingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullUInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullUInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullUInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().EndsWith(nameof(TestClass.NullUInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncNullCopyEndsWithRequestTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullCharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullDecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullDoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullFloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullIntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullLongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullSByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullSingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullUInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullUInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullUInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().EndsWith(nameof(TestClass.NullUInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ComparisonIsEqualTests.cs b/src/Tests/TestFiles/V2/ComparisonIsEqualTests.cs new file mode 100644 index 0000000..cb5d3ad --- /dev/null +++ b/src/Tests/TestFiles/V2/ComparisonIsEqualTests.cs @@ -0,0 +1,1841 @@ +namespace ServiceQuery.Xunit +{ + public class ComparisonIsEqualTests : ComparisonIsEqualTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class ComparisonIsEqualTests : BaseTest where T : class, ITestClass, new() + { + [Fact] + public void SyncIsEqualStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.BoolVal), "true").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.ByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.CharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.DecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.DoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.FloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.IntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.LongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.SByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.ShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.SingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // String + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.StringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.UInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.UInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.UInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + [Fact] + public void SyncIsEqualRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.BoolVal), "true").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.ByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.CharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.DecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.DoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.FloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.IntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.LongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.SByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.ShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.SingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.StringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.UInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.UInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.UInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + [Fact] + public void SyncNullIsEqualStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullBoolVal), "true").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullIsEqualRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullBoolVal), "true").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void FoundNullIsEqualRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullBoolVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullCharVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDateTimeOffsetVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDateOnlyVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDateTimeVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDecimalVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDoubleVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullFloatVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullGuidVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullIntVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullLongVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullSByteVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullShortVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullSingleVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullStringVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullTimeOnlyVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullTimeSpanVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullUInt128Val), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullUInt64Val), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullUInt32Val), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullUInt16Val), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + [Fact] + public void SyncNullCopyIsEqualStandardTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullBoolVal), "true").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // String + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + [Fact] + public void SyncNullCopyIsEqualRequestTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullBoolVal), "true").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ComparisonIsGreaterThanOrEqualTests.cs b/src/Tests/TestFiles/V2/ComparisonIsGreaterThanOrEqualTests.cs new file mode 100644 index 0000000..604e2f9 --- /dev/null +++ b/src/Tests/TestFiles/V2/ComparisonIsGreaterThanOrEqualTests.cs @@ -0,0 +1,1581 @@ +namespace ServiceQuery.Xunit +{ + public class ComparisonIsGreaterThanOrEqualTests : ComparisonIsGreaterThanOrEqualTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class ComparisonIsGreaterThanOrEqualTests : BaseTest where T : class, ITestClass, new() + { + [Fact] + public void SyncIsGreaterThanOrEqualOrEqualStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.BoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.ByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.CharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.DecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.DoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.FloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + +#if NET6_0 + // Guid + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + // Int + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.IntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.LongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.SByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.ShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.SingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // String + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.StringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.UInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.UInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.UInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + [Fact] + public void SyncIsGreaterThanOrEqualOrEqualRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.BoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.ByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.CharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.DecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.DoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.FloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + +#if NET6_0 + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.IntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.LongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.SByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.ShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.SingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.StringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.UInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.UInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.UInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + [Fact] + public void SyncNullIsGreaterThanOrEqualOrEqualStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0 + // Guid + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + // Int + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullStringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullIsGreaterThanOrEqualOrEqualRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0 + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullStringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullCopyIsGreaterThanOrEqualOrEqualStandardTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + +#if NET6_0 + // Guid + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + // Int + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // String + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullStringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + [Fact] + public void SyncNullCopyIsGreaterThanOrEqualOrEqualRequestTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + +#if NET6_0 + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullStringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThanOrEqual(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ComparisonIsGreaterThanTests.cs b/src/Tests/TestFiles/V2/ComparisonIsGreaterThanTests.cs new file mode 100644 index 0000000..47208fd --- /dev/null +++ b/src/Tests/TestFiles/V2/ComparisonIsGreaterThanTests.cs @@ -0,0 +1,1535 @@ +namespace ServiceQuery.Xunit +{ + public class ComparisonIsGreaterThanTests : ComparisonIsGreaterThanTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class ComparisonIsGreaterThanTests : BaseTest where T : class, ITestClass, new() + { + [Fact] + public void SyncIsGreaterThanStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.BoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.ByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.CharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.DecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.DoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.FloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + // Int + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.IntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.LongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.SByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.ShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.SingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // String + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.StringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.UInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.UInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.UInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void IsGreaterThanRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.BoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.ByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.CharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + +#if NET6_0_OR_GREATER + + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.DecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.DoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.FloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.IntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.LongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.SByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.ShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.SingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.StringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.UInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.UInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.UInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncNullIsGreaterThanStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + // Int + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullStringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullIsGreaterThanRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullStringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullCopyIsGreaterThanStandardTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + // Int + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // String + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullStringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsGreaterThan(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncNullCopyIsGreaterThanRequestTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullStringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsGreaterThan(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ComparisonIsInSetTests.cs b/src/Tests/TestFiles/V2/ComparisonIsInSetTests.cs new file mode 100644 index 0000000..e8530af --- /dev/null +++ b/src/Tests/TestFiles/V2/ComparisonIsInSetTests.cs @@ -0,0 +1,2373 @@ +namespace ServiceQuery.Xunit +{ + public class ComparisonIsInSetTests : ComparisonIsInSetTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class ComparisonIsInSetTests : BaseTest where T : class, ITestClass, new() + { + [Fact] + public void SyncIsInSetStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.BoolVal), "true").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.ByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.CharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.DecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.DoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.FloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.IntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.LongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.SByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.ShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.SingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // String + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.StringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.UInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.UInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.UInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + [Fact] + public void SyncIsInSetTwo() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.BoolVal), "true", "false").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.ByteVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.CharVal), "a", "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset1 = new T().GetDefault1Record().DateTimeOffsetVal; + var tempDateTimeOffset2 = new T().GetDefault2Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset1.ToString("o"), tempDateTimeOffset2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly1 = new T().GetDefault1Record().DateOnlyVal; + var tempDateOnly2 = new T().GetDefault2Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.DateOnlyVal), tempDateOnly1.ToString("o"), tempDateOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // DateTime + var tempDateTime1 = new T().GetDefault1Record().DateTimeVal; + var tempDateTime2 = new T().GetDefault2Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.DateTimeVal), tempDateTime1.ToString("o"), tempDateTime2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.DecimalVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.DoubleVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.FloatVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Guid + var tempGuid = new T().GetDefault1Record().GuidVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.GuidVal), Guid.Empty.ToString(), tempGuid.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.IntVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.LongVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.SByteVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.ShortVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.SingleVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // String + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.StringVal), "a", "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly1 = new T().GetDefault1Record().TimeOnlyVal; + var tempTimeOnly2 = new T().GetDefault2Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.TimeOnlyVal), tempTimeOnly1.ToString("o"), tempTimeOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString(), TimeSpan.FromMilliseconds(2).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.UInt128Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.UInt64Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.UInt32Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.UInt16Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncIsInSetRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.BoolVal), "true").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.ByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.CharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.DecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.DoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.FloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.IntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.LongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.SByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.ShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.SingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.StringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.UInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.UInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.UInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + [Fact] + public void SyncIsInSetTwoRequest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.BoolVal), "true", "false").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.ByteVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.CharVal), "a", "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset1 = new T().GetDefault1Record().DateTimeOffsetVal; + var tempDateTimeOffset2 = new T().GetDefault2Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset1.ToString("o"), tempDateTimeOffset2.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly1 = new T().GetDefault1Record().DateOnlyVal; + var tempDateOnly2 = new T().GetDefault2Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.DateOnlyVal), tempDateOnly1.ToString("o"), tempDateOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // DateTime + var tempDateTime1 = new T().GetDefault1Record().DateTimeVal; + var tempDateTime2 = new T().GetDefault2Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.DateTimeVal), tempDateTime1.ToString("o"), tempDateTime2.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.DecimalVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.DoubleVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.FloatVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Guid + var tempGuid = new T().GetDefault1Record().GuidVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.GuidVal), Guid.Empty.ToString(), tempGuid.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.IntVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.LongVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.SByteVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.ShortVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.SingleVal), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.StringVal), "a", "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly1 = new T().GetDefault1Record().TimeOnlyVal; + var tempTimeOnly2 = new T().GetDefault2Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.TimeOnlyVal), tempTimeOnly1.ToString("o"), tempTimeOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString(), TimeSpan.FromMilliseconds(2).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.UInt128Val), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.UInt64Val), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.UInt32Val), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.UInt16Val), "1", "2").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncNullIsInSetStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullBoolVal), "true").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullIsInSetRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullBoolVal), "true").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullIsInSetRequestAllTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullBoolVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullByteVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullCharVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullDateTimeOffsetVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullDateOnlyVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullDateTimeVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullDecimalVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullDoubleVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullFloatVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullGuidVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullIntVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullLongVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullSByteVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullShortVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullSingleVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullStringVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullTimeOnlyVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullTimeSpanVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullUInt128Val), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullUInt64Val), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullUInt32Val), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullUInt16Val), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + [Fact] + public void SyncNullCopyIsInSetStandardTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullBoolVal), "true").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // String + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsInSet(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + [Fact] + public void SyncNullCopyIsInSetRequestTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullBoolVal), "true").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsInSet(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ComparisonIsLessThanOrEqualTests.cs b/src/Tests/TestFiles/V2/ComparisonIsLessThanOrEqualTests.cs new file mode 100644 index 0000000..ad67e0b --- /dev/null +++ b/src/Tests/TestFiles/V2/ComparisonIsLessThanOrEqualTests.cs @@ -0,0 +1,1533 @@ +namespace ServiceQuery.Xunit +{ + public class ComparisonIsLessThanOrEqualTests : ComparisonIsLessThanOrEqualTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class ComparisonIsLessThanOrEqualTests : BaseTest where T : class, ITestClass, new() + { + [Fact] + public void SyncIsLessThanOrEqualStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.BoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.ByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.CharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.DecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.DoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.FloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.GuidVal), "11111111-1111-1111-1111-111111111111").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + // Int + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.IntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.LongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.SByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.ShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.SingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // String + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.StringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.UInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.UInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.UInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncIsLessThanOrEqualRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.BoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.ByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.CharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.DecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.DoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.FloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.GuidVal), "11111111-1111-1111-1111-111111111111").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.IntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.LongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.SByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.ShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.SingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.StringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.UInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.UInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.UInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncNullIsLessThanOrEqualStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullGuidVal), "11111111-1111-1111-1111-111111111111").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + // Int + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullStringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullIsLessThanOrEqualRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullGuidVal), "11111111-1111-1111-1111-111111111111").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullStringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullCopyIsLessThanOrEqualStandardTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullGuidVal), "11111111-1111-1111-1111-111111111111").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + // Int + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // String + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullStringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncNullCopyIsLessThanOrEqualRequestTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + +#if NET7_0_OR_GREATER + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullGuidVal), "11111111-1111-1111-1111-111111111111").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullStringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThanOrEqual(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ComparisonIsLessThanTests.cs b/src/Tests/TestFiles/V2/ComparisonIsLessThanTests.cs new file mode 100644 index 0000000..b42bbc0 --- /dev/null +++ b/src/Tests/TestFiles/V2/ComparisonIsLessThanTests.cs @@ -0,0 +1,1533 @@ +namespace ServiceQuery.Xunit +{ + public class ComparisonIsLessThanTests : ComparisonIsLessThanTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class ComparisonIsLessThanTests : BaseTest where T : class, ITestClass, new() + { + [Fact] + public void SyncIsLessThanStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.BoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.ByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.CharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.DecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.DoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.FloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#if NET7_0_OR_GREATER + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.GuidVal), "11111111-1111-1111-1111-111111111111").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + // Int + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.IntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.LongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.SByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.ShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.SingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // String + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.StringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.UInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.UInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.UInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + [Fact] + public void SyncIsLessThanRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.BoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.ByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.CharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.DecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.DoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.FloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#if NET7_0_OR_GREATER + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.GuidVal), "11111111-1111-1111-1111-111111111111").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.IntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.LongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.SByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.ShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.SingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.StringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.UInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.UInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.UInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + [Fact] + public void SyncNullIsLessThanStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#if NET7_0_OR_GREATER + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullGuidVal), "11111111-1111-1111-1111-111111111111").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + // Int + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullStringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullIsLessThanRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#if NET7_0_OR_GREATER + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullGuidVal), "11111111-1111-1111-1111-111111111111").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullStringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullCopyIsLessThanStandardTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#if NET7_0_OR_GREATER + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullGuidVal), "11111111-1111-1111-1111-111111111111").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + // Int + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // String + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullStringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsLessThan(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + [Fact] + public void SyncNullCopyIsLessThanRequestTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + byte[] tempbyte = new byte[] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyte)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#if NET7_0_OR_GREATER + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullGuidVal), "11111111-1111-1111-1111-111111111111").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullStringVal), "a").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsLessThan(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ComparisonIsNotEqualTests.cs b/src/Tests/TestFiles/V2/ComparisonIsNotEqualTests.cs new file mode 100644 index 0000000..3c18d6d --- /dev/null +++ b/src/Tests/TestFiles/V2/ComparisonIsNotEqualTests.cs @@ -0,0 +1,1587 @@ +namespace ServiceQuery.Xunit +{ + public class ComparisonIsNotEqualTests : ComparisonIsNotEqualTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class ComparisonIsNotEqualTests : BaseTest where T : class, ITestClass, new() + { + [Fact] + public void SyncIsNotEqualStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.BoolVal), "true").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.ByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.CharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.DecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.DoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.FloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.IntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.LongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.SByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.ShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.SingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // String + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.StringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.UInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.UInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.UInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + [Fact] + public void SyncIsNotEqualRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.BoolVal), "true").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.ByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.CharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.DecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.DoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.FloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.IntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.LongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.SByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.ShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.SingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.StringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.UInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.UInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.UInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + [Fact] + public void SyncNullIsNotEqualStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullBoolVal), "true").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // String + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + [Fact] + public void SyncNullIsNotEqualRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullBoolVal), "true").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + [Fact] + public void SyncNullCopyIsNotEqualStandardTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullBoolVal), "true").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 3); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 3); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // String + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsNotEqual(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + [Fact] + public void SyncNullCopyIsNotEqualRequestTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullBoolVal), "true").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotEqual(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ComparisonIsNotInSetTests.cs b/src/Tests/TestFiles/V2/ComparisonIsNotInSetTests.cs new file mode 100644 index 0000000..adc29bb --- /dev/null +++ b/src/Tests/TestFiles/V2/ComparisonIsNotInSetTests.cs @@ -0,0 +1,2371 @@ +namespace ServiceQuery.Xunit +{ + public class ComparisonIsNotInSetTests : ComparisonIsNotInSetTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class ComparisonIsNotInSetTests : BaseTest where T : class, ITestClass, new() + { + [Fact] + public void SyncIsNotInSetStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.BoolVal), "true").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 3); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 3); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.ByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.CharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.DecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.DoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.FloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.IntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.LongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.SByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.ShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.SingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // String + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.StringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.UInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.UInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.UInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + [Fact] + public void SyncIsNotInSetTwo() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.BoolVal), "true", "false").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 3); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 3); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.ByteVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.CharVal), "a", "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset1 = new T().GetDefault1Record().DateTimeOffsetVal; + var tempDateTimeOffset2 = new T().GetDefault2Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset1.ToString("o"), tempDateTimeOffset2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly1 = new T().GetDefault1Record().DateOnlyVal; + var tempDateOnly2 = new T().GetDefault2Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.DateOnlyVal), tempDateOnly1.ToString("o"), tempDateOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // DateTime + var tempDateTime1 = new T().GetDefault1Record().DateTimeVal; + var tempDateTime2 = new T().GetDefault2Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.DateTimeVal), tempDateTime1.ToString("o"), tempDateTime2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.DecimalVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.DoubleVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.FloatVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Guid + var tempGuid = new T().GetDefault1Record().GuidVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.GuidVal), Guid.Empty.ToString(), tempGuid.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.IntVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.LongVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.SByteVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.ShortVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.SingleVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // String + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.StringVal), "a", "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly1 = new T().GetDefault1Record().TimeOnlyVal; + var tempTimeOnly2 = new T().GetDefault2Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.TimeOnlyVal), tempTimeOnly1.ToString("o"), tempTimeOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString(), TimeSpan.FromMilliseconds(2).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.UInt128Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.UInt64Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.UInt32Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.UInt16Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncIsNotInSetRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.BoolVal), "true").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 3); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 3); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.ByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.CharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.DecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.DoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.FloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.IntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.LongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.SByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.ShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.SingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.StringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.UInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.UInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.UInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.UInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + [Fact] + public void SyncIsNotInSetTwoRequestTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.BoolVal), "true", "false").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 3); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 3); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.ByteVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.CharVal), "a", "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset1 = new T().GetDefault1Record().DateTimeOffsetVal; + var tempDateTimeOffset2 = new T().GetDefault2Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset1.ToString("o"), tempDateTimeOffset2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly1 = new T().GetDefault1Record().DateOnlyVal; + var tempDateOnly2 = new T().GetDefault2Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.DateOnlyVal), tempDateOnly1.ToString("o"), tempDateOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + // DateTime + var tempDateTime1 = new T().GetDefault1Record().DateTimeVal; + var tempDateTime2 = new T().GetDefault2Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.DateTimeVal), tempDateTime1.ToString("o"), tempDateTime2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.DecimalVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.DoubleVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.FloatVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Guid + var tempGuid = new T().GetDefault1Record().GuidVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.GuidVal), Guid.Empty.ToString(), tempGuid.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.IntVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.LongVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.SByteVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.ShortVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.SingleVal), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // String + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.StringVal), "a", "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly1 = new T().GetDefault1Record().TimeOnlyVal; + var tempTimeOnly2 = new T().GetDefault2Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.TimeOnlyVal), tempTimeOnly1.ToString("o"), tempTimeOnly2.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString(), TimeSpan.FromMilliseconds(2).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.UInt128Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.UInt64Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.UInt32Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.UInt16Val), "1", "2").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncNullIsNotInSetStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullBoolVal), "true").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // String + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + [Fact] + public void SyncNullIsNotInSetRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullBoolVal), "true").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + [Fact] + public void SyncNullIsNotInSetRequestNoneTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullBoolVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullByteVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullCharVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullDateTimeOffsetVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullDateOnlyVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullDateTimeVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullDecimalVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullDoubleVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullFloatVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullGuidVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullIntVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullLongVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullSByteVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullShortVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullSingleVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullStringVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullTimeOnlyVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullTimeSpanVal), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullUInt128Val), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullUInt64Val), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullUInt32Val), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullUInt16Val), null).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullCopyIsNotInSetStandardTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullBoolVal), "true").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 3); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 3); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // String + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsNotInSet(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + [Fact] + public void SyncNullCopyIsNotInSetRequestTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullBoolVal), "true").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 3); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 3); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullCharVal), "b").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullDecimalVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullDoubleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullFloatVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullIntVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullLongVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullSByteVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullShortVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullSingleVal), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullUInt128Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullUInt64Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullUInt32Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotInSet(nameof(TestClass.NullUInt16Val), "1").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ComparisonIsNotNullTests.cs b/src/Tests/TestFiles/V2/ComparisonIsNotNullTests.cs new file mode 100644 index 0000000..fd5eb61 --- /dev/null +++ b/src/Tests/TestFiles/V2/ComparisonIsNotNullTests.cs @@ -0,0 +1,1726 @@ +namespace ServiceQuery.Xunit +{ + public class ComparisonIsNotNullTests : ComparisonIsNotNullTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class ComparisonIsNotNullTests : BaseTest where T : class, ITestClass, new() + { + [Fact] + public void SyncIsNotNullStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.BoolVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.ByteVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.CharVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.DateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.DateOnlyVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.DateTimeVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.DecimalVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.DoubleVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.FloatVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.GuidVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.IntVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.LongVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.SByteVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.ShortVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.SingleVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.StringVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // String? + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullStringVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.TimeOnlyVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.TimeSpanVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.UInt128Val)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + +#endif + + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.UInt64Val)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.UInt32Val)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.UInt16Val)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncIsNotNullRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.BoolVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.ByteVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.CharVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.DateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.DateOnlyVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.DateTimeVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.DecimalVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.DoubleVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.FloatVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.GuidVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.IntVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.LongVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.SByteVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.ShortVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.SingleVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.StringVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.TimeOnlyVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.TimeSpanVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.UInt128Val)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.UInt64Val)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.UInt32Val)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.UInt16Val)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncNullIsNotNullStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullBoolVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullByteVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullCharVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullDateOnlyVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullDateTimeVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullDecimalVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullDoubleVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullFloatVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullGuidVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullIntVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullLongVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullSByteVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullShortVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullSingleVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullStringVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullTimeOnlyVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullTimeSpanVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullUInt128Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullUInt64Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullUInt32Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullUInt16Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullIsNotNullRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullBoolVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullByteVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullCharVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullDateOnlyVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullDateTimeVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullDecimalVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullDoubleVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullFloatVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullGuidVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullIntVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullLongVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullSByteVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullShortVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullSingleVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullStringVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullTimeOnlyVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullTimeSpanVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullUInt128Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullUInt64Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullUInt32Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullUInt16Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncFoundNullIsNotNullRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullBoolVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullByteVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullCharVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullDateOnlyVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullDateTimeVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullDecimalVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullDoubleVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullFloatVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullGuidVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullIntVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullLongVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullSByteVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullShortVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullSingleVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullStringVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullTimeOnlyVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullTimeSpanVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullUInt128Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullUInt64Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullUInt32Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullUInt16Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullCopyIsNotNullStandardTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullBoolVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullByteVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullCharVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullDateOnlyVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullDateTimeVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullDecimalVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullDoubleVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullFloatVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullGuidVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullIntVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullLongVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullSByteVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullShortVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullSingleVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // String + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullStringVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullTimeOnlyVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullTimeSpanVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullUInt128Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullUInt64Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullUInt32Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsNotNull(nameof(TestClass.NullUInt16Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + [Fact] + public void SyncNullCopyIsNotNullRequestTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullBoolVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullByteVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullCharVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullDateOnlyVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullDateTimeVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullDecimalVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullDoubleVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullFloatVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullGuidVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullIntVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullLongVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullSByteVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullShortVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullSingleVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullStringVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullTimeOnlyVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullTimeSpanVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullUInt128Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullUInt64Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullUInt32Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsNotNull(nameof(TestClass.NullUInt16Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ComparisonIsNullTests.cs b/src/Tests/TestFiles/V2/ComparisonIsNullTests.cs new file mode 100644 index 0000000..11eb2ba --- /dev/null +++ b/src/Tests/TestFiles/V2/ComparisonIsNullTests.cs @@ -0,0 +1,1715 @@ +namespace ServiceQuery.Xunit +{ + public class ComparisonIsNullTests : ComparisonIsNullTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class ComparisonIsNullTests : BaseTest where T : class, ITestClass, new() + { + [Fact] + public void SyncIsNullStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.BoolVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.ByteVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.CharVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.DateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.DateOnlyVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.DateTimeVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.DecimalVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.DoubleVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.FloatVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.GuidVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.IntVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.LongVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.SByteVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.ShortVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.SingleVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.StringVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.TimeOnlyVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.TimeSpanVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.UInt128Val)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#endif + + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.UInt64Val)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.UInt32Val)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.UInt16Val)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncIsNullRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.BoolVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.ByteVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.CharVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.DateTimeOffsetVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.DateOnlyVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.DateTimeVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.DecimalVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.DoubleVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.FloatVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.GuidVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.IntVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.LongVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.SByteVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.ShortVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.SingleVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.StringVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.TimeOnlyVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.TimeSpanVal)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.UInt128Val)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.UInt64Val)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.UInt32Val)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.UInt16Val)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncNullIsNullStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullBoolVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullByteVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullCharVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullDateOnlyVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullDateTimeVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullDecimalVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullDoubleVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullFloatVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullGuidVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullIntVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullLongVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullSByteVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullShortVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullSingleVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // String + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullStringVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullTimeOnlyVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullTimeSpanVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullUInt128Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullUInt64Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullUInt32Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullUInt16Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + [Fact] + public void SyncNullIsNullRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullBoolVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullByteVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullCharVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullDateOnlyVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullDateTimeVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullDecimalVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullDoubleVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullFloatVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullGuidVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullIntVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullLongVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullSByteVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullShortVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullSingleVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullStringVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullTimeOnlyVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullTimeSpanVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullUInt128Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullUInt64Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullUInt32Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullUInt16Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + [Fact] + public void SyncFoundNullIsEqualRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullBoolVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 4); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullByteVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullCharVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullDateOnlyVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullDateTimeVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullDecimalVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullDoubleVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullFloatVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullGuidVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullIntVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullLongVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullSByteVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullShortVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullSingleVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullStringVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullTimeOnlyVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullTimeSpanVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullUInt128Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullUInt64Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullUInt32Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullUInt16Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + [Fact] + public void SyncNullCopyIsNullStandardTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullBoolVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullByteVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullCharVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullDateOnlyVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullDateTimeVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullDecimalVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullDoubleVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullFloatVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullGuidVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullIntVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullLongVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullSByteVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullShortVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullSingleVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullStringVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullTimeOnlyVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullTimeSpanVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullUInt128Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullUInt64Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullUInt32Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsNull(nameof(TestClass.NullUInt16Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + [Fact] + public void SyncNullCopyIsNullRequestTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullBoolVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullByteVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullCharVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullDateOnlyVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullDateTimeVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullDecimalVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullDoubleVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullFloatVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullGuidVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullIntVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullLongVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullSByteVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullShortVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullSingleVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullStringVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullTimeOnlyVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullTimeSpanVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullUInt128Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullUInt64Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullUInt32Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsNull(nameof(TestClass.NullUInt16Val)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ComparisonStartsWithTests.cs b/src/Tests/TestFiles/V2/ComparisonStartsWithTests.cs new file mode 100644 index 0000000..748f1ef --- /dev/null +++ b/src/Tests/TestFiles/V2/ComparisonStartsWithTests.cs @@ -0,0 +1,1191 @@ +namespace ServiceQuery.Xunit +{ + public class ComparisonStartsWithTests : ComparisonStartsWithTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class ComparisonStartsWithTests : BaseTest where T : class, ITestClass, new() + { + [Fact] + public void SyncStartsWithStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.BoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.ByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.CharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.DecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.DoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.FloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.IntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.LongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.SByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.ShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.SingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.StringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.UInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.UInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.UInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.UInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncStartsWithRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.BoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.ByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.CharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.DateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.DateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.DateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.DecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.DoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.FloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.GuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.IntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.LongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.SByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.ShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.SingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.StringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.TimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.TimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.UInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.UInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.UInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.UInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncNullStartsWithStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullCharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullDecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullDoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullFloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullIntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullLongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullSByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullSingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullUInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullUInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullUInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullUInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncNullStartsWithRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullCharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullDecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullDoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullFloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullIntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullLongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullSByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullSingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 0); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullUInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullUInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullUInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullUInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncNullCopyStartsWithStandardTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullCharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullDecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullDoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullFloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullIntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullLongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullSByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullSingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullUInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullUInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullUInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().StartsWith(nameof(TestClass.NullUInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncNullCopyStartsWithRequestTest() + { + var sourceQueryable = GetTestNullCopyList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullBoolVal), "true").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + var tempbyteArray = new byte[1] { 1 }; + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullCharVal), "b").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullDateTimeOffsetVal), tempDateTimeOffset.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullDateOnlyVal), tempDateOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullDateTimeVal), tempDateTime.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullDecimalVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullDoubleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullFloatVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullGuidVal), Guid.Empty.ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullIntVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullLongVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullSByteVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullShortVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullSingleVal), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullStringVal), "a").Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullTimeOnlyVal), tempTimeOnly.ToString("o")).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullTimeSpanVal), TimeSpan.FromMilliseconds(1).ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullUInt128Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullUInt64Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullUInt32Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().StartsWith(nameof(TestClass.NullUInt16Val), "1").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/DistinctTests.cs b/src/Tests/TestFiles/V2/DistinctTests.cs new file mode 100644 index 0000000..862a9b8 --- /dev/null +++ b/src/Tests/TestFiles/V2/DistinctTests.cs @@ -0,0 +1,97 @@ +namespace ServiceQuery.Xunit +{ + public class DistinctTests : DistinctTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + + [Fact] + public override void SyncDistinctStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // No Equals() and GetHashcode() overrides on class + serviceQuery = ServiceQueryBuilder.New().Select(nameof(TestClass.SharedParentKey)).Distinct().Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + [Fact] + public override void SyncDistinctRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // No Equals() and GetHashcode() overrides on class + serviceQuery = ServiceQueryRequestBuilder.New().Select(nameof(TestClass.SharedParentKey)).Distinct().Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + } + + public abstract class DistinctTests : BaseTest where T : class + { + [Fact] + public virtual void SyncDistinctStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // No Equals() and GetHashcode() overrides on class + serviceQuery = ServiceQueryBuilder.New().Select(nameof(TestClass.SharedParentKey)).Distinct().Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + [Fact] + public virtual void SyncDistinctRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // No Equals() and GetHashcode() overrides on class + serviceQuery = ServiceQueryRequestBuilder.New().Select(nameof(TestClass.SharedParentKey)).Distinct().Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ExpressionTests.cs b/src/Tests/TestFiles/V2/ExpressionTests.cs new file mode 100644 index 0000000..b963b15 --- /dev/null +++ b/src/Tests/TestFiles/V2/ExpressionTests.cs @@ -0,0 +1,1378 @@ +namespace ServiceQuery.Xunit +{ + public class ExpressionTests : ExpressionTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class ExpressionTests : BaseTest where T : class + { + [Fact] + public void SyncExpressionsStandardTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // No filters (match all) + serviceQuery = ServiceQueryBuilder.New() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Begin and End (match all) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + private static ServiceQueryOptions optionAllowMissingExpressions = new ServiceQueryOptions { AllowMissingExpressions = true }; + + [Fact] + public void ExpressionsAndTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Begin and End (match one record) + serviceQuery = ServiceQueryBuilder.New() + .Begin() + .IsEqual(nameof(TestClass.IntVal), "1") + .Build(); + + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + testQueryable = serviceQuery.Apply(sourceQueryable, optionAllowMissingExpressions); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And (match more than one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.BoolVal), "true") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // And (match one record) + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And (match more than one record) + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.BoolVal), "true") + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And Begin and End (match one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And Begin and End (match more than one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.BoolVal), "true") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Implicit And (match one record) + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .IsEqual(nameof(TestClass.StringVal), "a") + .Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + testQueryable = serviceQuery.Apply(sourceQueryable, optionAllowMissingExpressions); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Implicit And (match more than one record) + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .IsEqual(nameof(TestClass.BoolVal), "true") + .Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + testQueryable = serviceQuery.Apply(sourceQueryable, optionAllowMissingExpressions); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And Begin and End Implicit (match one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + testQueryable = serviceQuery.Apply(sourceQueryable, optionAllowMissingExpressions); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And Begin and End Implicit (match more than one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .IsEqual(nameof(TestClass.BoolVal), "true") + .EndExpression() + .Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + testQueryable = serviceQuery.Apply(sourceQueryable, optionAllowMissingExpressions); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + [Fact] + public void SyncExpressionsOrTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // And (match one record) + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Or() + .IsEqual(nameof(TestClass.StringVal), "a") + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And (match more than one record) + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Or() + .IsEqual(nameof(TestClass.BoolVal), "true") + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // And Begin and End (match one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .Or() + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And Begin and End (match more than one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .Or() + .IsEqual(nameof(TestClass.BoolVal), "true") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncExpressionsAndOrTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // And (match one record) + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .Or() + .IsEqual(nameof(TestClass.LongVal), "1") + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And (match one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .Or() + .IsEqual(nameof(TestClass.LongVal), "1") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And (match more than one record) + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.BoolVal), "true") + .Or() + .IsEqual(nameof(TestClass.StringVal), " ") + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // And Begin and End (match one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .Or() + .IsEqual(nameof(TestClass.BoolVal), "true") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // And Begin and End (match more than one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.BoolVal), "true") + .Or() + .IsEqual(nameof(TestClass.StringVal), " ") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncExpressionsAndOrGroupingTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Begin End All + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Or() + .IsEqual(nameof(TestClass.LongVal), "2") + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Group before + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Or() + .IsEqual(nameof(TestClass.LongVal), "2") + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Group after (one) + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .BeginExpression() + .IsEqual(nameof(TestClass.StringVal), "a") + .Or() + .IsEqual(nameof(TestClass.LongVal), "2") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Group after (multiple) + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "0") + .Or() + .BeginExpression() + .IsEqual(nameof(TestClass.StringVal), "a") + .Or() + .IsEqual(nameof(TestClass.LongVal), "2") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Multiple Groups + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Or() + .BeginExpression() + .IsEqual(nameof(TestClass.LongVal), "2") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Multiple Groups with Begin and End + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Or() + .BeginExpression() + .IsEqual(nameof(TestClass.LongVal), "2") + .EndExpression() + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncExpressionsRequestTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // No filters (match all) + serviceQuery = ServiceQueryRequestBuilder.New() + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Begin and End (match all) + serviceQuery = ServiceQueryRequestBuilder.New() + .BeginExpression() + .EndExpression() + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + [Fact] + public void SyncExpressionsAndRequestTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Begin and End (match one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .EndExpression() + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And (match more than one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.BoolVal), "true") + .EndExpression() + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // And (match one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And (match more than one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.BoolVal), "true") + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And Begin and End (match one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And Begin and End (match more than one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.BoolVal), "true") + .EndExpression() + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Implicit And (match one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .IsEqual(nameof(TestClass.StringVal), "a") + .Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable, optionAllowMissingExpressions); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Implicit And (match more than one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .IsEqual(nameof(TestClass.BoolVal), "true") + .Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable, optionAllowMissingExpressions); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And Begin and End Implicit (match one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable, optionAllowMissingExpressions); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And Begin and End Implicit (match more than one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .IsEqual(nameof(TestClass.BoolVal), "true") + .EndExpression() + .Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable, optionAllowMissingExpressions); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + } + + [Fact] + public void SyncExpressionsOrRequestTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // And (match one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Or() + .IsEqual(nameof(TestClass.StringVal), "a") + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And (match more than one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Or() + .IsEqual(nameof(TestClass.BoolVal), "true") + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // And Begin and End (match one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .Or() + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And Begin and End (match more than one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .Or() + .IsEqual(nameof(TestClass.BoolVal), "true") + .EndExpression() + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncExpressionsAndOrRequestTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // And (match one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .Or() + .IsEqual(nameof(TestClass.LongVal), "1") + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And (match one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .Or() + .IsEqual(nameof(TestClass.LongVal), "1") + .EndExpression() + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And (match more than one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.BoolVal), "true") + .Or() + .IsEqual(nameof(TestClass.StringVal), " ") + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // And Begin and End (match one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .Or() + .IsEqual(nameof(TestClass.BoolVal), "true") + .EndExpression() + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // And Begin and End (match more than one record) + serviceQuery = ServiceQueryRequestBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.BoolVal), "true") + .Or() + .IsEqual(nameof(TestClass.StringVal), " ") + .EndExpression() + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncExpressionsAndOrGroupingRequestTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Begin End All + serviceQuery = ServiceQueryRequestBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Or() + .IsEqual(nameof(TestClass.LongVal), "2") + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Group before + serviceQuery = ServiceQueryRequestBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Or() + .IsEqual(nameof(TestClass.LongVal), "2") + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Group after (one) + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .BeginExpression() + .IsEqual(nameof(TestClass.StringVal), "a") + .Or() + .IsEqual(nameof(TestClass.LongVal), "2") + .EndExpression() + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Group after (multiple) + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "0") + .Or() + .BeginExpression() + .IsEqual(nameof(TestClass.StringVal), "a") + .Or() + .IsEqual(nameof(TestClass.LongVal), "2") + .EndExpression() + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + + // Multiple Groups + serviceQuery = ServiceQueryRequestBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Or() + .BeginExpression() + .IsEqual(nameof(TestClass.LongVal), "2") + .EndExpression() + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Multiple Groups with Begin and End + serviceQuery = ServiceQueryRequestBuilder.New() + .BeginExpression() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Or() + .BeginExpression() + .IsEqual(nameof(TestClass.LongVal), "2") + .EndExpression() + .EndExpression() + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + + [Fact] + public void SyncNullExpressionsAndTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // And (match more than one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.NullBoolVal), null) + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // And (match more than one record) + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.NullBoolVal), null) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And Begin and End (match more than one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.NullStringVal), null) + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // Implicit And (match one record) + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.NullIntVal), null) + .IsEqual(nameof(TestClass.NullStringVal), null) + .Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + testQueryable = serviceQuery.Apply(sourceQueryable, optionAllowMissingExpressions); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // And Begin and End Implicit (match more than one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.NullIntVal), null) + .IsEqual(nameof(TestClass.NullStringVal), null) + .EndExpression() + .Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + testQueryable = serviceQuery.Apply(sourceQueryable, optionAllowMissingExpressions); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + [Fact] + public void SyncNullExpressionsOrTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Or + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Or() + .IsEqual(nameof(TestClass.NullBoolVal), null) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // And Begin and End (match one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .Or() + .IsEqual(nameof(TestClass.NullStringVal), null) + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // And Begin and End (match more than one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.IntVal), "1") + .Or() + .IsEqual(nameof(TestClass.NullBoolVal), null) + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + } + + [Fact] + public void SyncNullExpressionsAndOrTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // And (match one record) + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .Or() + .IsEqual(nameof(TestClass.NullLongVal), null) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // And (match one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.NullIntVal), null) + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .Or() + .IsEqual(nameof(TestClass.LongVal), "1") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // And (match more than one record) + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .IsEqual(nameof(TestClass.NullBoolVal), null) + .Or() + .IsEqual(nameof(TestClass.StringVal), " ") + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // And Begin and End (match one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.NullIntVal), null) + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .Or() + .IsEqual(nameof(TestClass.BoolVal), "true") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // And Begin and End (match more than one record) + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.NullIntVal), null) + .And() + .IsEqual(nameof(TestClass.BoolVal), "true") + .Or() + .IsEqual(nameof(TestClass.StringVal), " ") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 3); + } + + [Fact] + public void SyncNullExpressionsAndOrGroupingTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Begin End All + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.NullIntVal), null) + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Or() + .IsEqual(nameof(TestClass.LongVal), "2") + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Group before + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.NullIntVal), null) + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Or() + .IsEqual(nameof(TestClass.LongVal), "2") + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Group after (one) + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.NullIntVal), null) + .And() + .BeginExpression() + .IsEqual(nameof(TestClass.StringVal), "a") + .Or() + .IsEqual(nameof(TestClass.LongVal), "2") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Group after (multiple) + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.NullIntVal), null) + .Or() + .BeginExpression() + .IsEqual(nameof(TestClass.StringVal), "a") + .Or() + .IsEqual(nameof(TestClass.LongVal), "2") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // Multiple Groups + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .IsEqual(nameof(TestClass.NullIntVal), null) + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Or() + .BeginExpression() + .IsEqual(nameof(TestClass.LongVal), "2") + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + + // Multiple Groups with Begin and End + serviceQuery = ServiceQueryBuilder.New() + .BeginExpression() + .BeginExpression() + .IsEqual(nameof(TestClass.NullIntVal), null) + .And() + .IsEqual(nameof(TestClass.StringVal), "a") + .EndExpression() + .Or() + .BeginExpression() + .IsEqual(nameof(TestClass.LongVal), "2") + .EndExpression() + .EndExpression() + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 2); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ExternalInterfaceTests.cs b/src/Tests/TestFiles/V2/ExternalInterfaceTests.cs new file mode 100644 index 0000000..1df9749 --- /dev/null +++ b/src/Tests/TestFiles/V2/ExternalInterfaceTests.cs @@ -0,0 +1,515 @@ +namespace ServiceQuery.Xunit +{ + public class ExternalInterfaceTests : BaseTest + { + protected void ValidateSort(List sortedList, bool asc) + { + Assert.NotNull(sortedList); + Assert.True(sortedList.Count == 4); + if (asc) + { + Assert.True(sortedList[0].IntVal == 0); + Assert.True(sortedList[1].IntVal == 1); + Assert.True(sortedList[2].IntVal == 2); + Assert.True(sortedList[3].IntVal == 3); + } + else + { + Assert.True(sortedList[0].IntVal == 3); + Assert.True(sortedList[1].IntVal == 2); + Assert.True(sortedList[2].IntVal == 1); + Assert.True(sortedList[3].IntVal == 0); + } + } + + [Fact] + public void ExternalInterfaceStandardTest() + { + var sourceQueryable = GetTestList(); + + IServiceQuery serviceQuery; + List result; + TestClass retRecord; + ITestClass oneRecord; + + // select + serviceQuery = ServiceQueryBuilder.New().Build(); + var selectExp = serviceQuery.BuildSelectExpression(); + Assert.Null(selectExp); + + var ps = serviceQuery.GetSelectProperties(); + Assert.Null(selectExp); + + // where + serviceQuery = ServiceQueryBuilder.New().Build(); + var whereExp = serviceQuery.BuildWhereExpression(); + Assert.Null(whereExp); + + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Build(); + whereExp = serviceQuery.BuildWhereExpression(); + Assert.NotNull(whereExp); + result = sourceQueryable.Where(whereExp).ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + Assert.True(result[0].LongVal == 1); + result = sourceQueryable.Where(whereExp).ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // select, where, order + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Sort(nameof(TestClass.BoolVal), true) + .Build(); + ps = serviceQuery.GetSelectProperties(); + Assert.NotNull(ps); + Assert.True(ps.Count == 1); + + selectExp = serviceQuery.BuildSelectExpression(); + Assert.NotNull(selectExp); + whereExp = serviceQuery.BuildWhereExpression(); + result = sourceQueryable.Where(whereExp).Select(selectExp).ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = sourceQueryable.Where(whereExp).Select(selectExp).ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new TestClass().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal != oneRecord.ByteArrayVal); + Assert.True(retRecord.ByteVal != oneRecord.ByteVal); + Assert.True(retRecord.CharVal != oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal != oneRecord.DateTimeOffsetVal); + Assert.True(retRecord.DateTimeVal != oneRecord.DateTimeVal); + Assert.True(retRecord.DecimalVal != oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // Sort + serviceQuery = ServiceQueryBuilder.New().Build(); + var sortExp = serviceQuery.BuildOrderByExpression(sourceQueryable); + Assert.Null(sortExp); + + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.IntVal), true).Build(); + sortExp = serviceQuery.BuildOrderByExpression(sourceQueryable); + Assert.NotNull(sortExp); + result = sourceQueryable.OrderBy(sortExp).ToList(); + ValidateSort(result, true); + } + + [Fact] + public void NullExternalInterfaceStandardTest() + { + var sourceQueryable = GetTestList(); + + IServiceQuery serviceQuery; + List result; + TestClass retRecord; + ITestClass oneRecord; + + // select + serviceQuery = ServiceQueryBuilder.New().Build(); + var selectExp = serviceQuery.BuildSelectExpression(); + Assert.Null(selectExp); + + var ps = serviceQuery.GetSelectProperties(); + Assert.Null(selectExp); + + // where + serviceQuery = ServiceQueryBuilder.New().Build(); + var whereExp = serviceQuery.BuildWhereExpression(); + Assert.Null(whereExp); + + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.NullIntVal), null) + .Build(); + whereExp = serviceQuery.BuildWhereExpression(); + Assert.NotNull(whereExp); + result = sourceQueryable.Where(whereExp).ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + //Assert.True(result[0].LongVal == 1); + result = sourceQueryable.Where(whereExp).ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.NullIntVal), null) + .Select(nameof(TestClass.NullBoolVal)) + .Build(); + ps = serviceQuery.GetSelectProperties(); + Assert.NotNull(ps); + Assert.True(ps.Count == 1); + + selectExp = serviceQuery.BuildSelectExpression(); + Assert.NotNull(selectExp); + whereExp = serviceQuery.BuildWhereExpression(); + result = sourceQueryable.Where(whereExp).Select(selectExp).OrderByDescending(x => x.IntVal).ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = sourceQueryable.Where(whereExp).Select(selectExp).ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + retRecord = result[0]; + oneRecord = new TestClass().GetDefault3Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.BoolVal != oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal != oneRecord.ByteArrayVal); + Assert.True(retRecord.ByteVal != oneRecord.ByteVal); + Assert.True(retRecord.CharVal != oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal != oneRecord.DateTimeOffsetVal); + Assert.True(retRecord.DateTimeVal != oneRecord.DateTimeVal); + Assert.True(retRecord.DecimalVal != oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // Sort + serviceQuery = ServiceQueryBuilder.New().Build(); + var sortExp = serviceQuery.BuildOrderByExpression(sourceQueryable); + Assert.Null(sortExp); + + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.IntVal), true).Build(); + sortExp = serviceQuery.BuildOrderByExpression(sourceQueryable); + Assert.NotNull(sortExp); + result = sourceQueryable.OrderBy(sortExp).ToList(); + ValidateSort(result, true); + } + + [Fact] + public void ExternalInterfaceRequestTest() + { + var sourceQueryable = GetTestList(); + + IServiceQueryRequest serviceQuery; + List result; + TestClass retRecord; + ITestClass oneRecord; + + // select + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + var selectExp = serviceQuery.GetServiceQuery().BuildSelectExpression(); + Assert.Null(selectExp); + + var ps = serviceQuery.GetServiceQuery().GetSelectProperties(); + Assert.Null(selectExp); + + // where + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + var whereExp = serviceQuery.GetServiceQuery().BuildWhereExpression(); + Assert.Null(whereExp); + + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Build(); + whereExp = serviceQuery.GetServiceQuery().BuildWhereExpression(); + Assert.NotNull(whereExp); + result = sourceQueryable.Where(whereExp).ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + Assert.True(result[0].LongVal == 1); + result = sourceQueryable.Where(whereExp).ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + + // select, where, order + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Sort(nameof(TestClass.BoolVal), true) + .Build(); + ps = serviceQuery.GetServiceQuery().GetSelectProperties(); + Assert.NotNull(ps); + Assert.True(ps.Count == 1); + + selectExp = serviceQuery.GetServiceQuery().BuildSelectExpression(); + Assert.NotNull(selectExp); + whereExp = serviceQuery.GetServiceQuery().BuildWhereExpression(); + result = sourceQueryable.Where(whereExp).Select(selectExp).ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = sourceQueryable.Where(whereExp).Select(selectExp).ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new TestClass().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal != oneRecord.ByteArrayVal); + Assert.True(retRecord.ByteVal != oneRecord.ByteVal); + Assert.True(retRecord.CharVal != oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal != oneRecord.DateTimeOffsetVal); + Assert.True(retRecord.DateTimeVal != oneRecord.DateTimeVal); + Assert.True(retRecord.DecimalVal != oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // Sort + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + var sortExp = serviceQuery.GetServiceQuery().BuildOrderByExpression(sourceQueryable); + Assert.Null(sortExp); + + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.IntVal), true).Build(); + sortExp = serviceQuery.GetServiceQuery().BuildOrderByExpression(sourceQueryable); + Assert.NotNull(sortExp); + result = sourceQueryable.OrderBy(sortExp).ToList(); + ValidateSort(result, true); + } + + [Fact] + public void NullExternalInterfaceRequestTest() + { + var sourceQueryable = GetTestList(); + + IServiceQueryRequest serviceQuery; + List result; + TestClass retRecord; + ITestClass oneRecord; + + // select + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + var selectExp = serviceQuery.GetServiceQuery().BuildSelectExpression(); + Assert.Null(selectExp); + + var ps = serviceQuery.GetServiceQuery().GetSelectProperties(); + Assert.Null(selectExp); + + // where + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + var whereExp = serviceQuery.GetServiceQuery().BuildWhereExpression(); + Assert.Null(whereExp); + + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.NullIntVal), null) + .Build(); + whereExp = serviceQuery.GetServiceQuery().BuildWhereExpression(); + Assert.NotNull(whereExp); + result = sourceQueryable.Where(whereExp).ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + //Assert.True(result[0].LongVal == 1); + result = sourceQueryable.Where(whereExp).ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + + // select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.NullIntVal), null) + .Select(nameof(TestClass.NullBoolVal)) + .Build(); + ps = serviceQuery.GetServiceQuery().GetSelectProperties(); + Assert.NotNull(ps); + Assert.True(ps.Count == 1); + + selectExp = serviceQuery.GetServiceQuery().BuildSelectExpression(); + Assert.NotNull(selectExp); + whereExp = serviceQuery.GetServiceQuery().BuildWhereExpression(); + result = sourceQueryable.Where(whereExp).Select(selectExp).OrderByDescending(x => x.IntVal).ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + result = sourceQueryable.Where(whereExp).Select(selectExp).ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 4); + retRecord = result[0]; + oneRecord = new TestClass().GetDefault3Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.BoolVal != oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal != oneRecord.ByteArrayVal); + Assert.True(retRecord.ByteVal != oneRecord.ByteVal); + Assert.True(retRecord.CharVal != oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal != oneRecord.DateTimeOffsetVal); + Assert.True(retRecord.DateTimeVal != oneRecord.DateTimeVal); + Assert.True(retRecord.DecimalVal != oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // Sort + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + var sortExp = serviceQuery.GetServiceQuery().BuildOrderByExpression(sourceQueryable); + Assert.Null(sortExp); + + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.IntVal), true).Build(); + sortExp = serviceQuery.GetServiceQuery().BuildOrderByExpression(sourceQueryable); + Assert.NotNull(sortExp); + result = sourceQueryable.OrderBy(sortExp).ToList(); + ValidateSort(result, true); + } + + [Fact] + public void ExternalInterfaceRequestExecuteTest() + { + var sourceQueryable = GetTestList(); + + IServiceQueryRequest serviceQuery; + ServiceQueryResponse result; + + IQueryable nullquery = null; + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + result = serviceQuery.Execute(nullquery); + Assert.Null(result); + result = serviceQuery.Execute(nullquery); + Assert.Null(result); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.Null(result.Aggregate); + Assert.True(result.Count == 0); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 4); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.Null(result.Aggregate); + Assert.True(result.Count == 0); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 4); + + serviceQuery = ServiceQueryRequestBuilder.New().Paging(1, 1000, true).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.Null(result.Aggregate); + Assert.True(result.Count == 4); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 4); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.Null(result.Aggregate); + Assert.True(result.Count == 4); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 4); + + serviceQuery = ServiceQueryRequestBuilder.New() + .IncludeCount() + .Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.Null(result.Aggregate); + Assert.True(result.Count == 4); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 4); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.Null(result.Aggregate); + Assert.True(result.Count == 4); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 4); + + // select, where, order + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.SharedParentKey), "1") + .Select(nameof(TestClass.BoolVal)) + .SortAsc(nameof(TestClass.BoolVal)) + .IncludeCount() + .Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.Null(result.Aggregate); + Assert.True(result.Count == 4); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 4); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.Null(result.Aggregate); + Assert.True(result.Count == 4); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 4); + + // Sort + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.IntVal), true).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.Null(result.Aggregate); + Assert.True(result.Count == 0); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 4); + ValidateSort(result.List, true); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.Null(result.Aggregate); + Assert.True(result.Count == 0); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 4); + + // Aggregate + serviceQuery = ServiceQueryRequestBuilder.New().Maximum(nameof(TestClass.IntVal)).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.NotNull(result.Aggregate); + Assert.True(result.Aggregate.Value == 3); + Assert.True(result.Count == null); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 0); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.NotNull(result.Aggregate); + Assert.True(result.Aggregate.Value == 3); + Assert.True(result.Count == null); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 0); + + // Aggregate includecount + serviceQuery = ServiceQueryRequestBuilder.New().Count().IncludeCount().Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.NotNull(result.Aggregate); + Assert.True(result.Aggregate.Value == 4); + Assert.True(result.Count == 4); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 0); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.NotNull(result.Aggregate); + Assert.True(result.Aggregate.Value == 4); + Assert.True(result.Count == 4); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 0); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/ITestClass.cs b/src/Tests/TestFiles/V2/ITestClass.cs new file mode 100644 index 0000000..82ef170 --- /dev/null +++ b/src/Tests/TestFiles/V2/ITestClass.cs @@ -0,0 +1,71 @@ +namespace ServiceQuery.Xunit +{ + public interface ITestClass + { + bool BoolVal { get; set; } + bool? NullBoolVal { get; set; } + byte[] ByteArrayVal { get; set; } + byte?[] NullByteArrayVal { get; set; } + byte ByteVal { get; set; } + byte? NullByteVal { get; set; } + char CharVal { get; set; } + char? NullCharVal { get; set; } +#if NET6_0_OR_GREATER + DateOnly DateOnlyVal { get; set; } + DateOnly? NullDateOnlyVal { get; set; } + + TimeOnly TimeOnlyVal { get; set; } + TimeOnly? NullTimeOnlyVal { get; set; } +#endif + DateTimeOffset DateTimeOffsetVal { get; set; } + DateTimeOffset? NullDateTimeOffsetVal { get; set; } + DateTime DateTimeVal { get; set; } + DateTime? NullDateTimeVal { get; set; } + decimal DecimalVal { get; set; } + decimal? NullDecimalVal { get; set; } + double DoubleVal { get; set; } + double? NullDoubleVal { get; set; } + float FloatVal { get; set; } + float? NullFloatVal { get; set; } + Guid GuidVal { get; set; } + Guid? NullGuidVal { get; set; } + int IntVal { get; set; } + int? NullIntVal { get; set; } + long LongVal { get; set; } + long? NullLongVal { get; set; } + + sbyte SByteVal { get; set; } + sbyte? NullSByteVal { get; set; } + int SharedParentKey { get; set; } + short ShortVal { get; set; } + short? NullShortVal { get; set; } + float SingleVal { get; set; } + float? NullSingleVal { get; set; } + string StringVal { get; set; } + string NullStringVal { get; set; } + TimeSpan TimeSpanVal { get; set; } + TimeSpan? NullTimeSpanVal { get; set; } + UInt16 UInt16Val { get; set; } + UInt16? NullUInt16Val { get; set; } + UInt32 UInt32Val { get; set; } + UInt32? NullUInt32Val { get; set; } + UInt64 UInt64Val { get; set; } + UInt64? NullUInt64Val { get; set; } +#if NET7_0_OR_GREATER + UInt128 UInt128Val { get; set; } + UInt128? NullUInt128Val { get; set; } +#endif + + void CopyToNullVals(); + + ITestClass GetDefault0Record(); + + ITestClass GetDefault1Record(); + + ITestClass GetDefault2Record(); + + ITestClass GetDefault3Record(); + + List GetDefaultList(); + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/NegativeTests.cs b/src/Tests/TestFiles/V2/NegativeTests.cs new file mode 100644 index 0000000..6c9dac3 --- /dev/null +++ b/src/Tests/TestFiles/V2/NegativeTests.cs @@ -0,0 +1,1488 @@ +namespace ServiceQuery.Xunit +{ + public class NegativeTests : NegativeTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class NegativeTests : BaseTest where T : class, ITestClass, new() + { + [Fact] + public void EndBeforeBegin() + { + var sourceQueryable = GetTestList(); + var sq = ServiceQueryRequestBuilder.New() + .End() + .IsEqual(nameof(TestClass.IntVal), "1") + .Begin() + .Build().GetServiceQuery(); + Assert.Throws(() => + { + var err = sq.Execute(sourceQueryable); + }); + + sq = ServiceQueryRequestBuilder.New() + .End() + .IsEqual(nameof(TestClass.IntVal), "1") + .Begin() + .Build().GetServiceQuery(); + Assert.Throws(() => + { + var err = sq.Execute(sourceQueryable); + }); + } + + [Fact] + public void MissingEnd() + { + var sourceQueryable = GetTestList(); + var sq = ServiceQueryRequestBuilder.New() + .Begin() + .IsEqual(nameof(TestClass.IntVal), "1") + .Build().GetServiceQuery(); + Assert.Throws(() => + { + var err = sq.Execute(sourceQueryable); + }); + } + + [Fact] + public void MultipleAndOr() + { + var sourceQueryable = GetTestList(); + var sq = ServiceQueryRequestBuilder.New() + .And().Build().GetServiceQuery(); + Assert.Throws(() => + { + var err = sq.Execute(sourceQueryable); + }); + + sq = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .And() + .And().Build().GetServiceQuery(); + Assert.Throws(() => + { + var err = sq.Execute(sourceQueryable); + }); + + sq = ServiceQueryRequestBuilder.New() + .Or().Build().GetServiceQuery(); + Assert.Throws(() => + { + var err = sq.Execute(sourceQueryable); + }); + + sq = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Or() + .Or().Build().GetServiceQuery(); + Assert.Throws(() => + { + var err = sq.Execute(sourceQueryable); + }); + } + + [Fact] + public void PropertyNotFound() + { + var sourceQueryable = GetTestList(); + var sq = ServiceQueryRequestBuilder.New() + .Select("zzzzz") + .Build().GetServiceQuery(); + Assert.Throws(() => + { + var err = sq.Execute(sourceQueryable); + }); + + var options = new ServiceQueryOptions() { PropertyNameCaseSensitive = true }; + + sq = ServiceQueryRequestBuilder.New() + .Select("INTVAL") + .Build().GetServiceQuery(); + + Assert.Throws(() => + { + var err = sq.Execute(sourceQueryable, options); + }); + + sq = ServiceQueryRequestBuilder.New() + .Select("zzz") + .Build().GetServiceQuery(); + + Assert.Throws(() => + { + var err = sq.Execute(sourceQueryable, options); + }); + } + + [Fact] + public void PageSizeNotANumber() + { + var sourceQueryable = GetTestList(); + //IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + //List result; + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "pagesize", + Properties = new List() { nameof(TestClass.IntVal) }, + Values = new List() { "abc" } + }); + Assert.Throws(() => + { + var err = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "pagesize", + Properties = new List() { nameof(TestClass.IntVal) }, + Values = new List() { "" } + }); + Assert.Throws(() => + { + var err = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "pagenumber", + Properties = new List() { nameof(TestClass.IntVal) }, + Values = new List() { "" } + }); + Assert.Throws(() => + { + var err = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "includecount", + Properties = new List() { nameof(TestClass.IntVal) }, + Values = new List() { "asd" } + }); + Assert.Throws(() => + { + var err = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "includecount", + Properties = new List() { nameof(TestClass.IntVal) }, + Values = new List() { "" } + }); + var templist = serviceQuery.Execute(sourceQueryable); + } + + [Fact] + public void RequestBeginEnd() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + //List result; + + serviceQuery = ServiceQueryRequestBuilder.New() + .Begin() + .IsEqual(nameof(TestClass.IntVal), "1") + .End() + .Build(); + + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + var list = testQueryable.ToList(); + } + + [Fact] + public void IncludeCountTwice() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + //List result; + + serviceQuery = ServiceQueryRequestBuilder.New() + .IncludeCount() + .IncludeCount() + .Build(); + + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + var list = testQueryable.ToList(); + + serviceQuery = ServiceQueryRequestBuilder.New() + .IncludeCount() + .Paging(1, 1000, true) + .Build(); + + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + list = testQueryable.ToList(); + } + + [Fact] + public void IsAggregateNullCheck() + { + IServiceQueryRequest serviceQuery; + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + + var sq = serviceQuery.GetServiceQuery(); + sq.Filters = null; + Assert.True(sq.IsAggregate() == false); + } + + [Fact] + public void FilterTypeNotDefined() + { + IServiceQueryRequest serviceQuery; + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "", + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery(); + }); + } + + [Fact] + public void MissingProperty() + { + var sourceQueryable = GetTestList(); + IServiceQueryRequest serviceQuery; + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "select", + Properties = new List() { } + }); + + //Assert.Throws(() => + //{ + // var sq = serviceQuery.GetServiceQuery(); + //}); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "greaterthan", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + Assert.Throws(() => + { + var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + sq.Filters.Add(new ServiceQueryFilter() + { + FilterType = ServiceQueryFilterType.Compare, + CompareType = ServiceQueryCompareType.GreaterThan, + Properties = new List() { } + }); + var respsq = sq.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "greaterthanorequal", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + Assert.Throws(() => + { + var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + sq.Filters.Add(new ServiceQueryFilter() + { + FilterType = ServiceQueryFilterType.Compare, + CompareType = ServiceQueryCompareType.GreaterThanEqual, + Properties = new List() { } + }); + var respsq = sq.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "lessthan", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + Assert.Throws(() => + { + var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + sq.Filters.Add(new ServiceQueryFilter() + { + FilterType = ServiceQueryFilterType.Compare, + CompareType = ServiceQueryCompareType.LessThan, + Properties = new List() { } + }); + var respsq = sq.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "lessthanorequal", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + Assert.Throws(() => + { + var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + sq.Filters.Add(new ServiceQueryFilter() + { + FilterType = ServiceQueryFilterType.Compare, + CompareType = ServiceQueryCompareType.LessThanEqual, + Properties = new List() { } + }); + var respsq = sq.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "equal", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + Assert.Throws(() => + { + var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + sq.Filters.Add(new ServiceQueryFilter() + { + FilterType = ServiceQueryFilterType.Compare, + CompareType = ServiceQueryCompareType.Equal, + Properties = new List() { } + }); + var respsq = sq.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "notequal", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + Assert.Throws(() => + { + var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + sq.Filters.Add(new ServiceQueryFilter() + { + FilterType = ServiceQueryFilterType.Compare, + CompareType = ServiceQueryCompareType.NotEqual, + Properties = new List() { } + }); + var respsq = sq.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "inset", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + Assert.Throws(() => + { + var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + sq.Filters.Add(new ServiceQueryFilter() + { + FilterType = ServiceQueryFilterType.Set, + IncludeType = ServiceQueryIncludeType.Include, + Properties = new List() { } + }); + var respsq = sq.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "notinset", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + Assert.Throws(() => + { + var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + sq.Filters.Add(new ServiceQueryFilter() + { + FilterType = ServiceQueryFilterType.Set, + IncludeType = ServiceQueryIncludeType.NotInclude, + Properties = new List() { } + }); + var respsq = sq.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "isnull", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + Assert.Throws(() => + { + var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + sq.Filters.Add(new ServiceQueryFilter() + { + FilterType = ServiceQueryFilterType.Null, + IncludeType = ServiceQueryIncludeType.Include, + Properties = new List() { } + }); + var respsq = sq.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "isnotnull", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + Assert.Throws(() => + { + var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + sq.Filters.Add(new ServiceQueryFilter() + { + FilterType = ServiceQueryFilterType.Null, + IncludeType = ServiceQueryIncludeType.NotInclude, + Properties = new List() { } + }); + var respsq = sq.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "minimum", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + Assert.Throws(() => + { + var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + sq.Filters.Add(new ServiceQueryFilter() + { + FilterType = ServiceQueryFilterType.Aggregate, + AggregateType = ServiceQueryAggregateType.Minimum, + Properties = new List() { } + }); + var respsq = sq.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "maximum", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + Assert.Throws(() => + { + var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + sq.Filters.Add(new ServiceQueryFilter() + { + FilterType = ServiceQueryFilterType.Aggregate, + AggregateType = ServiceQueryAggregateType.Maximum, + Properties = new List() { } + }); + var respsq = sq.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "startswith", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + Assert.Throws(() => + { + var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + sq.Filters.Add(new ServiceQueryFilter() + { + FilterType = ServiceQueryFilterType.Compare, + CompareType = ServiceQueryCompareType.StartsWith, + Properties = new List() { } + }); + var respsq = sq.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "endswith", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + Assert.Throws(() => + { + var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + sq.Filters.Add(new ServiceQueryFilter() + { + FilterType = ServiceQueryFilterType.Compare, + CompareType = ServiceQueryCompareType.EndsWith, + Properties = new List() { } + }); + var respsq = sq.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "contains", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + Assert.Throws(() => + { + var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + sq.Filters.Add(new ServiceQueryFilter() + { + FilterType = ServiceQueryFilterType.Compare, + CompareType = ServiceQueryCompareType.Contains, + Properties = new List() { } + }); + var respsq = sq.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "sum", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + Assert.Throws(() => + { + var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + sq.Filters.Add(new ServiceQueryFilter() + { + FilterType = ServiceQueryFilterType.Aggregate, + AggregateType = ServiceQueryAggregateType.Sum, + Properties = new List() { } + }); + var respsq = sq.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "sortasc", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + //Assert.Throws(() => + //{ + // var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + // sq.Filters.Add(new ServiceQueryFilter() + // { + // FilterType = ServiceQueryFilterType.Sort, + // SortType = ServiceQuerySortType.Ascending, + // Properties = new List() { } + // }); + // var respsq = sq.Execute(sourceQueryable); + //}); + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + serviceQuery.Filters.Add(new ServiceQueryServiceFilter() + { + FilterType = "sortdesc", + Properties = new List() { } + }); + + Assert.Throws(() => + { + var sq = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + }); + //Assert.Throws(() => + //{ + // var sq = ServiceQueryRequestBuilder.New().Build().GetServiceQuery(); + // sq.Filters.Add(new ServiceQueryFilter() + // { + // FilterType = ServiceQueryFilterType.Sort, + // SortType = ServiceQuerySortType.Descending, + // Properties = new List() { } + // }); + // var respsq = sq.Execute(sourceQueryable); + //}); + } + + [Fact] + public void ExecuteNull() + { + IServiceQueryRequest serviceQuery; + + serviceQuery = ServiceQueryRequestBuilder.New().Build(); + + var result = serviceQuery.GetServiceQuery().Execute(null); + Assert.True(result == null); + } + + [Fact] + public void SyncNegativeIsEqualStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + //List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.BoolVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.ByteVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.CharVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.DateTimeOffsetVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.DateOnlyVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.DateTimeVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.DecimalVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.DoubleVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.FloatVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.GuidVal), "zzzzz").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.IntVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.LongVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.SByteVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.ShortVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.SingleVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // String + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.StringVal), null).Build(); + //Assert.Throws(() => + //{ + // testQueryable = serviceQuery.Apply(sourceQueryable); + //}); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.TimeOnlyVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.TimeSpanVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.UInt128Val), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.UInt64Val), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.UInt32Val), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.UInt16Val), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncIsEqualRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + //List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.BoolVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.ByteVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.CharVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.DateTimeOffsetVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.DateOnlyVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.DateTimeVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.DecimalVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.DoubleVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.FloatVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.GuidVal), "zzzzz").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.IntVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.LongVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.SByteVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.ShortVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.SingleVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // String + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.StringVal), null).Build(); + //Assert.Throws(() => + //{ + // testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + //}); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.TimeOnlyVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.TimeSpanVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.UInt128Val), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.UInt64Val), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.UInt32Val), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.UInt16Val), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncNullIsEqualStandardTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + //List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullBoolVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + + // Byte + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullByteVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullCharVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullDateTimeOffsetVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullDateOnlyVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullDateTimeVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullDecimalVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullDoubleVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullFloatVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullGuidVal), "zzzzz").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullIntVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullLongVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullSByteVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullShortVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullSingleVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // String + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullStringVal), null).Build(); + //Assert.Throws(() => + //{ + // testQueryable = serviceQuery.Apply(sourceQueryable); + //}); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullTimeOnlyVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullTimeSpanVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullUInt128Val), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullUInt64Val), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullUInt32Val), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullUInt16Val), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.Apply(sourceQueryable); + }); + } + + [Fact] + public void SyncNullIsEqualRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + //List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullBoolVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 0); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullCharVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDateTimeOffsetVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDateOnlyVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDateTimeVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Decimal + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDecimalVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullDoubleVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullFloatVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullGuidVal), "zzzz").Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullIntVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullLongVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullSByteVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullShortVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullSingleVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // String + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullStringVal), Guid.NewGuid().ToString()).Build(); + //Assert.Throws(() => + //{ + // testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + //}); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullTimeOnlyVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullTimeSpanVal), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullUInt128Val), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullUInt64Val), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullUInt32Val), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullUInt16Val), Guid.NewGuid().ToString()).Build(); + Assert.Throws(() => + { + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + }); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/OptionTests.cs b/src/Tests/TestFiles/V2/OptionTests.cs new file mode 100644 index 0000000..9452cde --- /dev/null +++ b/src/Tests/TestFiles/V2/OptionTests.cs @@ -0,0 +1,66 @@ +namespace ServiceQuery.Xunit +{ + public class OptionTests : NegativeTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class OptionTests : BaseTest where T : class, ITestClass, new() + { + [Fact] + public void PropertyNameSensitivity() + { + var sourceQueryable = GetTestList(); + + var req = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.IntVal), "1").Build(); + var resp = req.Execute(sourceQueryable); + Assert.True(resp.List.Count == 1); + + req = ServiceQueryRequestBuilder.New().IsEqual("intval", "1").Build(); + + Assert.Throws(() => + { + resp = req.Execute(sourceQueryable); + }); + } + + [Fact] + public void NullOptions() + { + var sourceQueryable = GetTestList(); + + var req = ServiceQueryRequestBuilder.New().Select(nameof(TestClass.IntVal)).IsEqual(nameof(TestClass.IntVal), "1").Build(); + + var sq = req.GetServiceQuery(); + var q2 = sq.Apply(sourceQueryable); + + ServiceQueryOptions serviceQueryOptions = new ServiceQueryOptions(); + var qo = sq.BuildOrderByExpression(sourceQueryable, serviceQueryOptions); + var qs = sq.BuildSelectExpression(serviceQueryOptions); + var qw = sq.BuildWhereExpression(serviceQueryOptions); + var ea = sq.ExecuteAggregate(sourceQueryable, serviceQueryOptions); + var sp = sq.GetSelectProperties(serviceQueryOptions); + + var resp = req.Execute(sourceQueryable); + Assert.True(resp.List.Count == 1); + + req = ServiceQueryRequestBuilder.New().IsEqual("intval", "1").Build(); + + Assert.Throws(() => + { + resp = req.Execute(sourceQueryable); + }); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/PagingTests.cs b/src/Tests/TestFiles/V2/PagingTests.cs new file mode 100644 index 0000000..48a1937 --- /dev/null +++ b/src/Tests/TestFiles/V2/PagingTests.cs @@ -0,0 +1,325 @@ +namespace ServiceQuery.Xunit +{ + public class PagingTests : BaseTest + { + [Fact] + public void NegativePagingRequestTest() + { + var sourceQueryable = GetTestList(); + IServiceQueryRequest serviceQuery; + ServiceQueryResponse result; + + serviceQuery = ServiceQueryRequestBuilder.New().Paging(0, 0, false).Build(); + serviceQuery.Filters.Where(x => + x.FilterType == "pagenumber").First().Values = new List() { "a" }; + Assert.Throws(() => + { + result = serviceQuery.Execute(sourceQueryable); + }); + Assert.Throws(() => + { + result = serviceQuery.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Paging(0, 0, false).Build(); + serviceQuery.Filters.Where(x => + x.FilterType == "pagesize").First().Values = new List() { "a" }; + Assert.Throws(() => + { + result = serviceQuery.Execute(sourceQueryable); + }); + + serviceQuery = ServiceQueryRequestBuilder.New().Paging(0, 0, false).Build(); + serviceQuery.Filters.Where(x => + x.FilterType == "includecount").First().Values = new List() { "a" }; + Assert.Throws(() => + { + result = serviceQuery.Execute(sourceQueryable); + }); + } + + [Fact] + public void PagingStandardTest() + { + var sourceQueryable = GetTestList(); + IServiceQuery serviceQuery; + ServiceQueryResponse result; + + serviceQuery = ServiceQueryBuilder.New().Paging(0, 0, false).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 0); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 0); + + serviceQuery = ServiceQueryBuilder.New().Paging(0, 0, true).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 0); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 0); + + serviceQuery = ServiceQueryBuilder.New().Paging(1, 1, true).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 1); + + serviceQuery = ServiceQueryBuilder.New().Paging(1, 2, true).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 2); + + serviceQuery = ServiceQueryBuilder.New().Paging(1, 3, true).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 3); + + serviceQuery = ServiceQueryBuilder.New().Paging(2, 1, true).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 1); + + serviceQuery = ServiceQueryBuilder.New().Paging(2, 2, true).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 2); + + serviceQuery = ServiceQueryBuilder.New().Paging(2, 3, true).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 1); + + serviceQuery = ServiceQueryBuilder.New().Paging(3, 3, true).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 0); + + serviceQuery = ServiceQueryBuilder.New().Paging(3, 1, true).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 1); + + serviceQuery = ServiceQueryBuilder.New().Paging(3, 2, true).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 0); + + serviceQuery = ServiceQueryBuilder.New().Paging(10, 10, true).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 0); + + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.SharedParentKey), "1").Paging(1, 2, true).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 2); + + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.IntVal), "1").Paging(1, 2, true).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 1); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 1); + + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.BoolVal), "true").Paging(1, 2, true).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 2); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 2); + + serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.BoolVal), "true").Paging(1, 2, false).Build(); + result = serviceQuery.Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 0); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 2); + } + + [Fact] + public void PagingRequestTest() + { + var sourceQueryable = GetTestList(); + IServiceQueryRequest serviceQuery; + ServiceQueryResponse result; + + serviceQuery = ServiceQueryRequestBuilder.New().Paging(0, 0, false).Build(); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 0); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 0); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 0); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 0); + + serviceQuery = ServiceQueryRequestBuilder.New().Paging(0, 0, true).Build(); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 0); + + serviceQuery = ServiceQueryRequestBuilder.New().Paging(1, 1, true).Build(); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 1); + + serviceQuery = ServiceQueryRequestBuilder.New().Paging(1, 2, true).Build(); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 2); + + serviceQuery = ServiceQueryRequestBuilder.New().Paging(1, 3, true).Build(); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 3); + + serviceQuery = ServiceQueryRequestBuilder.New().Paging(2, 1, true).Build(); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 1); + + serviceQuery = ServiceQueryRequestBuilder.New().Paging(2, 2, true).Build(); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 2); + + serviceQuery = ServiceQueryRequestBuilder.New().Paging(2, 3, true).Build(); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 1); + + serviceQuery = ServiceQueryRequestBuilder.New().Paging(3, 3, true).Build(); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 0); + + serviceQuery = ServiceQueryRequestBuilder.New().Paging(3, 1, true).Build(); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 1); + + serviceQuery = ServiceQueryRequestBuilder.New().Paging(3, 2, true).Build(); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 0); + + serviceQuery = ServiceQueryRequestBuilder.New().Paging(10, 10, true).Build(); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 0); + + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.SharedParentKey), "1").Paging(1, 2, true).Build(); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 4); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 2); + + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.IntVal), "1").Paging(1, 2, true).Build(); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 1); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 1); + + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.BoolVal), "true").Paging(1, 2, true).Build(); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 2); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 2); + + serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.BoolVal), "true").Paging(1, 2, false).Build(); + result = serviceQuery.GetServiceQuery().Execute(sourceQueryable); + Assert.NotNull(result); + Assert.True(result.Count == 0); + Assert.True(!result.Aggregate.HasValue); + Assert.NotNull(result.List); + Assert.True(result.List.Count == 2); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/SelectTests.cs b/src/Tests/TestFiles/V2/SelectTests.cs new file mode 100644 index 0000000..ac0341a --- /dev/null +++ b/src/Tests/TestFiles/V2/SelectTests.cs @@ -0,0 +1,4206 @@ +namespace ServiceQuery.Xunit +{ + public class SelectTests : SelectTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class SelectTests : BaseTest where T : class, ITestClass, new() + { + public bool OverrideDatetimeForCosmos { get; set; } + + [Fact] + public void SelectStandardTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + T retRecord; + ITestClass oneRecord; + + // No select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal == oneRecord.SingleVal); + Assert.True(retRecord.StringVal == oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal == oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val == oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val == oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val == oneRecord.UInt64Val); + + // 1 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal != oneRecord.ByteArrayVal); + Assert.True(retRecord.ByteVal != oneRecord.ByteVal); + Assert.True(retRecord.CharVal != oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal != oneRecord.DateTimeOffsetVal); + Assert.True(retRecord.DateTimeVal != oneRecord.DateTimeVal); + Assert.True(retRecord.DecimalVal != oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 2 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal != oneRecord.ByteVal); + Assert.True(retRecord.CharVal != oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal != oneRecord.DateTimeOffsetVal); + Assert.True(retRecord.DateTimeVal != oneRecord.DateTimeVal); + Assert.True(retRecord.DecimalVal != oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 3 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal != oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal != oneRecord.DateTimeOffsetVal); + Assert.True(retRecord.DateTimeVal != oneRecord.DateTimeVal); + Assert.True(retRecord.DecimalVal != oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 4 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal != oneRecord.DateTimeOffsetVal); + Assert.True(retRecord.DateTimeVal != oneRecord.DateTimeVal); + Assert.True(retRecord.DecimalVal != oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 5 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + Assert.True(retRecord.DateTimeVal != oneRecord.DateTimeVal); + Assert.True(retRecord.DecimalVal != oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 6 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal != oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 7 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 8 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 9 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 10 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 11 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 12 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 13 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 14 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Select(nameof(TestClass.ShortVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 15 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Select(nameof(TestClass.ShortVal)) + .Select(nameof(TestClass.SingleVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal == oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 16 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Select(nameof(TestClass.ShortVal)) + .Select(nameof(TestClass.SingleVal)) + .Select(nameof(TestClass.StringVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal == oneRecord.SingleVal); + Assert.True(retRecord.StringVal == oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 17 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Select(nameof(TestClass.ShortVal)) + .Select(nameof(TestClass.SingleVal)) + .Select(nameof(TestClass.StringVal)) + .Select(nameof(TestClass.TimeSpanVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal == oneRecord.SingleVal); + Assert.True(retRecord.StringVal == oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal == oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 18 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Select(nameof(TestClass.ShortVal)) + .Select(nameof(TestClass.SingleVal)) + .Select(nameof(TestClass.StringVal)) + .Select(nameof(TestClass.TimeSpanVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal == oneRecord.SingleVal); + Assert.True(retRecord.StringVal == oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal == oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 19 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Select(nameof(TestClass.ShortVal)) + .Select(nameof(TestClass.SingleVal)) + .Select(nameof(TestClass.StringVal)) + .Select(nameof(TestClass.TimeSpanVal)) + .Select(nameof(TestClass.UInt16Val)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal == oneRecord.SingleVal); + Assert.True(retRecord.StringVal == oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal == oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val == oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 20 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Select(nameof(TestClass.ShortVal)) + .Select(nameof(TestClass.SingleVal)) + .Select(nameof(TestClass.StringVal)) + .Select(nameof(TestClass.TimeSpanVal)) + .Select(nameof(TestClass.UInt16Val)) + .Select(nameof(TestClass.UInt32Val)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal == oneRecord.SingleVal); + Assert.True(retRecord.StringVal == oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal == oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val == oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val == oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 21 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Select(nameof(TestClass.ShortVal)) + .Select(nameof(TestClass.SingleVal)) + .Select(nameof(TestClass.StringVal)) + .Select(nameof(TestClass.TimeSpanVal)) + .Select(nameof(TestClass.UInt16Val)) + .Select(nameof(TestClass.UInt32Val)) + .Select(nameof(TestClass.UInt64Val)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal == oneRecord.SingleVal); + Assert.True(retRecord.StringVal == oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal == oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val == oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val == oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val == oneRecord.UInt64Val); + } + + [Fact] + public void SelectRequestTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + T retRecord; + ITestClass oneRecord; + + // No select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal == oneRecord.SingleVal); + Assert.True(retRecord.StringVal == oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal == oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val == oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val == oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val == oneRecord.UInt64Val); + + // 1 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal != oneRecord.ByteArrayVal); + Assert.True(retRecord.ByteVal != oneRecord.ByteVal); + Assert.True(retRecord.CharVal != oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal != oneRecord.DateTimeOffsetVal); + Assert.True(retRecord.DateTimeVal != oneRecord.DateTimeVal); + Assert.True(retRecord.DecimalVal != oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 2 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal != oneRecord.ByteVal); + Assert.True(retRecord.CharVal != oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal != oneRecord.DateTimeOffsetVal); + Assert.True(retRecord.DateTimeVal != oneRecord.DateTimeVal); + Assert.True(retRecord.DecimalVal != oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 3 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal != oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal != oneRecord.DateTimeOffsetVal); + Assert.True(retRecord.DateTimeVal != oneRecord.DateTimeVal); + Assert.True(retRecord.DecimalVal != oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 4 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal != oneRecord.DateTimeOffsetVal); + Assert.True(retRecord.DateTimeVal != oneRecord.DateTimeVal); + Assert.True(retRecord.DecimalVal != oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 5 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + Assert.True(retRecord.DateTimeVal != oneRecord.DateTimeVal); + Assert.True(retRecord.DecimalVal != oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 6 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal != oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 7 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal != oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 8 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal != oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 9 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal != oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 10 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal != oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 11 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal != oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 12 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal != oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 13 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal != oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 14 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Select(nameof(TestClass.ShortVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal != oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 15 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Select(nameof(TestClass.ShortVal)) + .Select(nameof(TestClass.SingleVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal == oneRecord.SingleVal); + Assert.True(retRecord.StringVal != oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 16 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Select(nameof(TestClass.ShortVal)) + .Select(nameof(TestClass.SingleVal)) + .Select(nameof(TestClass.StringVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal == oneRecord.SingleVal); + Assert.True(retRecord.StringVal == oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal != oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 17 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Select(nameof(TestClass.ShortVal)) + .Select(nameof(TestClass.SingleVal)) + .Select(nameof(TestClass.StringVal)) + .Select(nameof(TestClass.TimeSpanVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal == oneRecord.SingleVal); + Assert.True(retRecord.StringVal == oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal == oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 18 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Select(nameof(TestClass.ShortVal)) + .Select(nameof(TestClass.SingleVal)) + .Select(nameof(TestClass.StringVal)) + .Select(nameof(TestClass.TimeSpanVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal == oneRecord.SingleVal); + Assert.True(retRecord.StringVal == oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal == oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val != oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 19 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Select(nameof(TestClass.ShortVal)) + .Select(nameof(TestClass.SingleVal)) + .Select(nameof(TestClass.StringVal)) + .Select(nameof(TestClass.TimeSpanVal)) + .Select(nameof(TestClass.UInt16Val)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal == oneRecord.SingleVal); + Assert.True(retRecord.StringVal == oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal == oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val == oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val != oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 20 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Select(nameof(TestClass.ShortVal)) + .Select(nameof(TestClass.SingleVal)) + .Select(nameof(TestClass.StringVal)) + .Select(nameof(TestClass.TimeSpanVal)) + .Select(nameof(TestClass.UInt16Val)) + .Select(nameof(TestClass.UInt32Val)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal == oneRecord.SingleVal); + Assert.True(retRecord.StringVal == oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal == oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val == oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val == oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val != oneRecord.UInt64Val); + + // 21 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.BoolVal)) + .Select(nameof(TestClass.ByteArrayVal)) + .Select(nameof(TestClass.ByteVal)) + .Select(nameof(TestClass.CharVal)) + .Select(nameof(TestClass.DateTimeOffsetVal)) + .Select(nameof(TestClass.DateTimeVal)) + .Select(nameof(TestClass.DecimalVal)) + .Select(nameof(TestClass.DoubleVal)) + .Select(nameof(TestClass.FloatVal)) + .Select(nameof(TestClass.GuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.LongVal)) + .Select(nameof(TestClass.SByteVal)) + .Select(nameof(TestClass.ShortVal)) + .Select(nameof(TestClass.SingleVal)) + .Select(nameof(TestClass.StringVal)) + .Select(nameof(TestClass.TimeSpanVal)) + .Select(nameof(TestClass.UInt16Val)) + .Select(nameof(TestClass.UInt32Val)) + .Select(nameof(TestClass.UInt64Val)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.BoolVal == oneRecord.BoolVal); + Assert.True(retRecord.ByteArrayVal[0] == oneRecord.ByteArrayVal[0]); + Assert.True(retRecord.ByteVal == oneRecord.ByteVal); + Assert.True(retRecord.CharVal == oneRecord.CharVal); + Assert.True(retRecord.DateTimeOffsetVal == oneRecord.DateTimeOffsetVal); + if (OverrideDatetimeForCosmos) + { + Assert.True(retRecord.DateTimeOffsetVal.ToLocalTime() == oneRecord.DateTimeOffsetVal); + } + else + { + Assert.True(retRecord.DateTimeVal == oneRecord.DateTimeVal); + } + Assert.True(retRecord.DecimalVal == oneRecord.DecimalVal); + Assert.True(retRecord.DoubleVal == oneRecord.DoubleVal); + Assert.True(retRecord.FloatVal == oneRecord.FloatVal); + Assert.True(retRecord.GuidVal == oneRecord.GuidVal); + Assert.True(retRecord.IntVal == oneRecord.IntVal); + Assert.True(retRecord.LongVal == oneRecord.LongVal); + Assert.True(retRecord.SByteVal == oneRecord.SByteVal); + Assert.True(retRecord.ShortVal == oneRecord.ShortVal); + Assert.True(retRecord.SingleVal == oneRecord.SingleVal); + Assert.True(retRecord.StringVal == oneRecord.StringVal); + Assert.True(retRecord.TimeSpanVal == oneRecord.TimeSpanVal); + Assert.True(retRecord.UInt16Val == oneRecord.UInt16Val); + Assert.True(retRecord.UInt32Val == oneRecord.UInt32Val); + Assert.True(retRecord.UInt64Val == oneRecord.UInt64Val); + } + + [Fact] + public void NullSelectStandardTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + T retRecord; + ITestClass oneRecord; + + // No select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 1 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 2 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 3 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 4 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 5 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 6 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 7 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 8 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 9 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 10 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 11 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 12 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 13 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 14 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Select(nameof(TestClass.NullShortVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 15 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Select(nameof(TestClass.NullShortVal)) + .Select(nameof(TestClass.NullSingleVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 16 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Select(nameof(TestClass.NullShortVal)) + .Select(nameof(TestClass.NullSingleVal)) + .Select(nameof(TestClass.NullStringVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 17 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Select(nameof(TestClass.NullShortVal)) + .Select(nameof(TestClass.NullSingleVal)) + .Select(nameof(TestClass.NullStringVal)) + .Select(nameof(TestClass.NullTimeSpanVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 18 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Select(nameof(TestClass.NullShortVal)) + .Select(nameof(TestClass.NullSingleVal)) + .Select(nameof(TestClass.NullStringVal)) + .Select(nameof(TestClass.NullTimeSpanVal)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 19 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Select(nameof(TestClass.NullShortVal)) + .Select(nameof(TestClass.NullSingleVal)) + .Select(nameof(TestClass.NullStringVal)) + .Select(nameof(TestClass.NullTimeSpanVal)) + .Select(nameof(TestClass.NullUInt16Val)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 20 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Select(nameof(TestClass.NullShortVal)) + .Select(nameof(TestClass.NullSingleVal)) + .Select(nameof(TestClass.NullStringVal)) + .Select(nameof(TestClass.NullTimeSpanVal)) + .Select(nameof(TestClass.NullUInt16Val)) + .Select(nameof(TestClass.NullUInt32Val)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 21 select + serviceQuery = ServiceQueryBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Select(nameof(TestClass.NullShortVal)) + .Select(nameof(TestClass.NullSingleVal)) + .Select(nameof(TestClass.NullStringVal)) + .Select(nameof(TestClass.NullTimeSpanVal)) + .Select(nameof(TestClass.NullUInt16Val)) + .Select(nameof(TestClass.NullUInt32Val)) + .Select(nameof(TestClass.NullUInt64Val)) + .Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + } + + [Fact] + public void NullSelectRequestTests() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + T retRecord; + ITestClass oneRecord; + + // No select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 1 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 2 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 3 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 4 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 5 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 6 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 7 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 8 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 9 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 10 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 11 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 12 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 13 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 14 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Select(nameof(TestClass.NullShortVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 15 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Select(nameof(TestClass.NullShortVal)) + .Select(nameof(TestClass.NullSingleVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 16 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Select(nameof(TestClass.NullShortVal)) + .Select(nameof(TestClass.NullSingleVal)) + .Select(nameof(TestClass.NullStringVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 17 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Select(nameof(TestClass.NullShortVal)) + .Select(nameof(TestClass.NullSingleVal)) + .Select(nameof(TestClass.NullStringVal)) + .Select(nameof(TestClass.NullTimeSpanVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 18 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Select(nameof(TestClass.NullShortVal)) + .Select(nameof(TestClass.NullSingleVal)) + .Select(nameof(TestClass.NullStringVal)) + .Select(nameof(TestClass.NullTimeSpanVal)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 19 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Select(nameof(TestClass.NullShortVal)) + .Select(nameof(TestClass.NullSingleVal)) + .Select(nameof(TestClass.NullStringVal)) + .Select(nameof(TestClass.NullTimeSpanVal)) + .Select(nameof(TestClass.NullUInt16Val)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 20 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Select(nameof(TestClass.NullShortVal)) + .Select(nameof(TestClass.NullSingleVal)) + .Select(nameof(TestClass.NullStringVal)) + .Select(nameof(TestClass.NullTimeSpanVal)) + .Select(nameof(TestClass.NullUInt16Val)) + .Select(nameof(TestClass.NullUInt32Val)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + + // 21 select + serviceQuery = ServiceQueryRequestBuilder.New() + .IsEqual(nameof(TestClass.IntVal), "1") + .Select(nameof(TestClass.NullBoolVal)) + .Select(nameof(TestClass.NullByteArrayVal)) + .Select(nameof(TestClass.NullByteVal)) + .Select(nameof(TestClass.NullCharVal)) + .Select(nameof(TestClass.NullDateTimeOffsetVal)) + .Select(nameof(TestClass.NullDateTimeVal)) + .Select(nameof(TestClass.NullDecimalVal)) + .Select(nameof(TestClass.NullDoubleVal)) + .Select(nameof(TestClass.NullFloatVal)) + .Select(nameof(TestClass.NullGuidVal)) + .Select(nameof(TestClass.IntVal)) + .Select(nameof(TestClass.NullLongVal)) + .Select(nameof(TestClass.NullSByteVal)) + .Select(nameof(TestClass.NullShortVal)) + .Select(nameof(TestClass.NullSingleVal)) + .Select(nameof(TestClass.NullStringVal)) + .Select(nameof(TestClass.NullTimeSpanVal)) + .Select(nameof(TestClass.NullUInt16Val)) + .Select(nameof(TestClass.NullUInt32Val)) + .Select(nameof(TestClass.NullUInt64Val)) + .Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + result = testQueryable.ToList(); + Assert.NotNull(result); + Assert.True(result.Count == 1); + retRecord = result[0]; + oneRecord = new T().GetDefault1Record(); + Assert.True(retRecord.NullBoolVal == oneRecord.NullBoolVal); + Assert.True(retRecord.NullByteArrayVal == oneRecord.NullByteArrayVal); + Assert.True(retRecord.NullByteVal == oneRecord.NullByteVal); + Assert.True(retRecord.NullCharVal == oneRecord.NullCharVal); + Assert.True(retRecord.NullDateTimeOffsetVal == oneRecord.NullDateTimeOffsetVal); + Assert.True(retRecord.NullDateTimeVal == oneRecord.NullDateTimeVal); + Assert.True(retRecord.NullDecimalVal == oneRecord.NullDecimalVal); + Assert.True(retRecord.NullDoubleVal == oneRecord.NullDoubleVal); + Assert.True(retRecord.NullFloatVal == oneRecord.NullFloatVal); + Assert.True(retRecord.NullGuidVal == oneRecord.NullGuidVal); + Assert.True(retRecord.NullIntVal == oneRecord.NullIntVal); + Assert.True(retRecord.NullLongVal == oneRecord.NullLongVal); + Assert.True(retRecord.NullSByteVal == oneRecord.NullSByteVal); + Assert.True(retRecord.NullShortVal == oneRecord.NullShortVal); + Assert.True(retRecord.NullSingleVal == oneRecord.NullSingleVal); + Assert.True(retRecord.NullStringVal == oneRecord.NullStringVal); + Assert.True(retRecord.NullTimeSpanVal == oneRecord.NullTimeSpanVal); + Assert.True(retRecord.NullUInt16Val == oneRecord.NullUInt16Val); + Assert.True(retRecord.NullUInt32Val == oneRecord.NullUInt32Val); + Assert.True(retRecord.NullUInt64Val == oneRecord.NullUInt64Val); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/SortTests.cs b/src/Tests/TestFiles/V2/SortTests.cs new file mode 100644 index 0000000..342b046 --- /dev/null +++ b/src/Tests/TestFiles/V2/SortTests.cs @@ -0,0 +1,1682 @@ +namespace ServiceQuery.Xunit +{ + public class SortTests : SortTests + { + public override IQueryable GetTestList() + { + return new TestClass().GetDefaultList().AsQueryable(); + } + + public override IQueryable GetTestNullCopyList() + { + var list = new TestClass().GetDefaultList(); + foreach (var item in list) + item.CopyToNullVals(); + return list.AsQueryable(); + } + } + + public abstract class SortTests : BaseTest where T : class, ITestClass, new() + { + protected void ValidateSort(List sortedList, bool asc) + { + Assert.NotNull(sortedList); + Assert.True(sortedList.Count == 4); + if (asc) + { + Assert.True(sortedList[0].IntVal == 0); + Assert.True(sortedList[1].IntVal == 1); + Assert.True(sortedList[2].IntVal == 2); + Assert.True(sortedList[3].IntVal == 3); + } + else + { + Assert.True(sortedList[0].IntVal == 3); + Assert.True(sortedList[1].IntVal == 2); + Assert.True(sortedList[2].IntVal == 1); + Assert.True(sortedList[3].IntVal == 0); + } + } + + [Fact] + public void SortAscTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.BoolVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result[0].IntVal == 0 || result[0].IntVal == 2); + Assert.True(result[1].IntVal == 0 || result[1].IntVal == 2); + Assert.True(result[2].IntVal == 1 || result[2].IntVal == 3); + Assert.True(result[3].IntVal == 1 || result[3].IntVal == 3); + + result = testQueryable.ToList(); + Assert.True(result[0].IntVal == 0 || result[0].IntVal == 2); + Assert.True(result[1].IntVal == 0 || result[1].IntVal == 2); + Assert.True(result[2].IntVal == 1 || result[2].IntVal == 3); + Assert.True(result[3].IntVal == 1 || result[3].IntVal == 3); + + serviceQuery = ServiceQueryBuilder.New().SortAsc(nameof(TestClass.BoolVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result[0].IntVal == 0 || result[0].IntVal == 2); + Assert.True(result[1].IntVal == 0 || result[1].IntVal == 2); + Assert.True(result[2].IntVal == 1 || result[2].IntVal == 3); + Assert.True(result[3].IntVal == 1 || result[3].IntVal == 3); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.ByteVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // Char + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.CharVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.DateTimeOffsetVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.DateOnlyVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.DateTimeVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.DecimalVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + } + + // Double + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.DoubleVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // Float + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.FloatVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.GuidVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // Int + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.IntVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // Long + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.LongVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.SByteVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // Short + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.ShortVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // Single + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.SingleVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // String + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.StringVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.TimeOnlyVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.TimeSpanVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.UInt128Val), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.UInt64Val), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.UInt32Val), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.UInt16Val), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + } + + [Fact] + public void SortDescTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.BoolVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result[0].IntVal == 1 || result[0].IntVal == 3); + Assert.True(result[1].IntVal == 1 || result[1].IntVal == 3); + Assert.True(result[2].IntVal == 0 || result[2].IntVal == 2); + Assert.True(result[3].IntVal == 0 || result[3].IntVal == 2); + result = testQueryable.ToList(); + Assert.True(result[0].IntVal == 1 || result[0].IntVal == 3); + Assert.True(result[1].IntVal == 1 || result[1].IntVal == 3); + Assert.True(result[2].IntVal == 0 || result[2].IntVal == 2); + Assert.True(result[3].IntVal == 0 || result[3].IntVal == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.ByteVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // Char + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.CharVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.DateTimeOffsetVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.DateOnlyVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.DateTimeVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.DecimalVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + } + + // Double + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.DoubleVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // Float + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.FloatVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.GuidVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // Int + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.IntVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // Long + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.LongVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.SByteVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // Short + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.ShortVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // Single + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.SingleVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // String + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.StringVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.TimeOnlyVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.TimeSpanVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.UInt128Val), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.UInt64Val), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.UInt32Val), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.UInt16Val), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + } + + [Fact] + public void SortAscRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.BoolVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result[0].IntVal == 0 || result[0].IntVal == 2); + Assert.True(result[1].IntVal == 0 || result[1].IntVal == 2); + Assert.True(result[2].IntVal == 1 || result[2].IntVal == 3); + Assert.True(result[3].IntVal == 1 || result[3].IntVal == 3); + result = testQueryable.ToList(); + Assert.True(result[0].IntVal == 0 || result[0].IntVal == 2); + Assert.True(result[1].IntVal == 0 || result[1].IntVal == 2); + Assert.True(result[2].IntVal == 1 || result[2].IntVal == 3); + Assert.True(result[3].IntVal == 1 || result[3].IntVal == 3); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.ByteVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.CharVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.DateTimeOffsetVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.DateOnlyVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.DateTimeVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.DecimalVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + } + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.DoubleVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.FloatVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.GuidVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.IntVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.LongVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.SByteVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.ShortVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.SingleVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.StringVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.TimeOnlyVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.TimeSpanVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.UInt128Val), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.UInt64Val), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.UInt32Val), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.UInt16Val), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, true); + } + + [Fact] + public void SortDescRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.BoolVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result[0].IntVal == 1 || result[0].IntVal == 3); + Assert.True(result[1].IntVal == 1 || result[1].IntVal == 3); + Assert.True(result[2].IntVal == 0 || result[2].IntVal == 2); + Assert.True(result[3].IntVal == 0 || result[3].IntVal == 2); + result = testQueryable.ToList(); + Assert.True(result[0].IntVal == 1 || result[0].IntVal == 3); + Assert.True(result[1].IntVal == 1 || result[1].IntVal == 3); + Assert.True(result[2].IntVal == 0 || result[2].IntVal == 2); + Assert.True(result[3].IntVal == 0 || result[3].IntVal == 2); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.ByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.ByteVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.CharVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.DateTimeOffsetVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.DateOnlyVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.DateTimeVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.DecimalVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + } + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.DoubleVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.FloatVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.GuidVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.IntVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.LongVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.SByteVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.ShortVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.SingleVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.StringVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.TimeOnlyVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.TimeSpanVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.UInt128Val), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.UInt64Val), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.UInt32Val), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.UInt16Val), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + ValidateSort(result, false); + } + + [Fact] + public void NullSortAscTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullBoolVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + //Assert.True(result[0].IntVal == 0 || result[0].IntVal == 2); + //Assert.True(result[1].IntVal == 0 || result[1].IntVal == 2); + //Assert.True(result[2].IntVal == 1 || result[2].IntVal == 3); + //Assert.True(result[3].IntVal == 1 || result[3].IntVal == 3); + + serviceQuery = ServiceQueryBuilder.New().SortAsc(nameof(TestClass.NullBoolVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + //Assert.True(result[0].IntVal == 0 || result[0].IntVal == 2); + //Assert.True(result[1].IntVal == 0 || result[1].IntVal == 2); + //Assert.True(result[2].IntVal == 1 || result[2].IntVal == 3); + //Assert.True(result[3].IntVal == 1 || result[3].IntVal == 3); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullByteVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Char + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullCharVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullDateTimeOffsetVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + +#if NET6_0_OR_GREATER + + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullDateOnlyVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullDateTimeVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullDecimalVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + + // Double + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullDoubleVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Float + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullFloatVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullGuidVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Int + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullIntVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Long + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullLongVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullSByteVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Short + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullShortVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Single + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullSingleVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // String + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullStringVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullTimeOnlyVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullTimeSpanVal), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullUInt128Val), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullUInt64Val), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullUInt32Val), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullUInt16Val), true).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + + [Fact] + public void NullSortDescTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullBoolVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullByteVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Char + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullCharVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullDateOnlyVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullDateTimeVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullDecimalVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + + // Double + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullDoubleVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Float + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullFloatVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Guid + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullGuidVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Int + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullIntVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Long + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullLongVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // SByte + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullSByteVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Short + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullShortVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Single + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullSingleVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // String + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullStringVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullTimeOnlyVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullTimeSpanVal)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullUInt128Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullUInt64Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullUInt32Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().SortDesc(nameof(TestClass.NullUInt16Val)).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + + [Fact] + public void NullSortDescBoolTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQuery serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullBoolVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullByteVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Char + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullCharVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullDateTimeOffsetVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullDateOnlyVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullDateTimeVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullDecimalVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + + // Double + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullDoubleVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Float + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullFloatVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Guid + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullGuidVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Int + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullIntVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Long + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullLongVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // SByte + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullSByteVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Short + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullShortVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Single + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullSingleVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // String + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullStringVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullTimeOnlyVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullTimeSpanVal), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullUInt128Val), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullUInt64Val), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + + // UInt32 + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullUInt32Val), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // UInt16 + serviceQuery = ServiceQueryBuilder.New().Sort(nameof(TestClass.NullUInt16Val), false).Build(); + testQueryable = serviceQuery.Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + + [Fact] + public void NullSortAscRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullBoolVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullByteVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullCharVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullDateTimeOffsetVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullDateOnlyVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullDateTimeVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullDecimalVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullDoubleVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullFloatVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullGuidVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullIntVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullLongVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullSByteVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullShortVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullSingleVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullStringVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullTimeOnlyVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullTimeSpanVal), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullUInt128Val), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullUInt64Val), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullUInt32Val), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullUInt16Val), true).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + + [Fact] + public void NullSortDescRequestTest() + { + var sourceQueryable = GetTestList(); + IQueryable testQueryable; + IServiceQueryRequest serviceQuery; + List result; + + // Boolean + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullBoolVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // ByteArray + //var tempbyteArray = new byte[1] { 1 }; + //serviceQuery = ServiceQueryRequestBuilder.New().IsEqual(nameof(TestClass.NullByteArrayVal), System.Text.Encoding.UTF8.GetString(tempbyteArray)).Build(); + //testQueryable = serviceQuery.GetQueryable(sourceQueryable); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + //result = testQueryable.ToList(); + //Assert.NotNull(result); + //Assert.True(result.Count == 1); + + // Byte + serviceQuery = ServiceQueryRequestBuilder.New().SortDesc(nameof(TestClass.NullByteVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Char + serviceQuery = ServiceQueryRequestBuilder.New().SortDesc(nameof(TestClass.NullCharVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + if (ValidateDateTimeOffset) + { + // DateTimeOffset + var tempDateTimeOffset = new T().GetDefault1Record().DateTimeOffsetVal; + serviceQuery = ServiceQueryRequestBuilder.New().SortDesc(nameof(TestClass.NullDateTimeOffsetVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + +#if NET6_0_OR_GREATER + // DateOnly + var tempDateOnly = new T().GetDefault1Record().DateOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().SortDesc(nameof(TestClass.NullDateOnlyVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); +#endif + + // DateTime + var tempDateTime = new T().GetDefault1Record().DateTimeVal; + serviceQuery = ServiceQueryRequestBuilder.New().SortDesc(nameof(TestClass.NullDateTimeVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Decimal + if (ValidateDecimal) + { + serviceQuery = ServiceQueryRequestBuilder.New().SortDesc(nameof(TestClass.NullDecimalVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + + // Double + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullDoubleVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Float + serviceQuery = ServiceQueryRequestBuilder.New().SortDesc(nameof(TestClass.NullFloatVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Guid + serviceQuery = ServiceQueryRequestBuilder.New().SortDesc(nameof(TestClass.NullGuidVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Int + serviceQuery = ServiceQueryRequestBuilder.New().SortDesc(nameof(TestClass.NullIntVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Long + serviceQuery = ServiceQueryRequestBuilder.New().SortDesc(nameof(TestClass.NullLongVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // SByte + serviceQuery = ServiceQueryRequestBuilder.New().SortDesc(nameof(TestClass.NullSByteVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Short + serviceQuery = ServiceQueryRequestBuilder.New().SortDesc(nameof(TestClass.NullShortVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // Single + serviceQuery = ServiceQueryRequestBuilder.New().SortDesc(nameof(TestClass.NullSingleVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // String + serviceQuery = ServiceQueryRequestBuilder.New().SortDesc(nameof(TestClass.NullStringVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + +#if NET6_0_OR_GREATER + // TimeOnly + var tempTimeOnly = new T().GetDefault1Record().TimeOnlyVal; + serviceQuery = ServiceQueryRequestBuilder.New().SortDesc(nameof(TestClass.NullTimeOnlyVal)).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); +#endif + + if (ValidateTimeSpan) + { + // TimeSpan + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullTimeSpanVal), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } +#if NET7_0_OR_GREATER + if (ValidateUInt128) + { + // UInt128 + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullUInt128Val), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } +#endif + if (ValidateUInt64) + { + // UInt64 + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullUInt64Val), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + + // UInt32 + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullUInt32Val), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + + // UInt16 + serviceQuery = ServiceQueryRequestBuilder.New().Sort(nameof(TestClass.NullUInt16Val), false).Build(); + testQueryable = serviceQuery.GetServiceQuery().Apply(sourceQueryable); + result = testQueryable.ToList(); + Assert.True(result.Count == 4); + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/TestClass.cs b/src/Tests/TestFiles/V2/TestClass.cs new file mode 100644 index 0000000..d7e9214 --- /dev/null +++ b/src/Tests/TestFiles/V2/TestClass.cs @@ -0,0 +1,259 @@ +namespace ServiceQuery.Xunit +{ + public class TestClass : ITestClass + { + //cosmos key + public Guid CosmosKey { get; set; } + + //db key + public virtual int DatabaseKey { get; set; } + + //For use with shared record testing + public virtual int SharedParentKey { get; set; } + + public virtual string StringVal { get; set; } +#pragma warning disable CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. + public virtual string? NullStringVal { get; set; } +#pragma warning restore CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. + + public virtual byte ByteVal { get; set; } + public virtual byte? NullByteVal { get; set; } + + public virtual byte[] ByteArrayVal { get; set; } + public virtual byte?[] NullByteArrayVal { get; set; } + + public virtual char CharVal { get; set; } + public virtual char? NullCharVal { get; set; } + + public virtual double DoubleVal { get; set; } + public virtual double? NullDoubleVal { get; set; } + + public virtual bool BoolVal { get; set; } + public virtual bool? NullBoolVal { get; set; } + + public virtual DateOnly DateOnlyVal { get; set; } + public virtual DateOnly? NullDateOnlyVal { get; set; } + + public virtual DateTime DateTimeVal { get; set; } + public virtual DateTime? NullDateTimeVal { get; set; } + + public virtual decimal DecimalVal { get; set; } + public virtual decimal? NullDecimalVal { get; set; } + + public virtual Guid GuidVal { get; set; } + public virtual Guid? NullGuidVal { get; set; } + + public virtual DateTimeOffset DateTimeOffsetVal { get; set; } + public virtual DateTimeOffset? NullDateTimeOffsetVal { get; set; } + + public virtual short ShortVal { get; set; } + public virtual short? NullShortVal { get; set; } + + public virtual int IntVal { get; set; } + public virtual int? NullIntVal { get; set; } + + public virtual long LongVal { get; set; } + public virtual long? NullLongVal { get; set; } + + public virtual sbyte SByteVal { get; set; } + public virtual sbyte? NullSByteVal { get; set; } + + public virtual Single SingleVal { get; set; } + public virtual Single? NullSingleVal { get; set; } + + public virtual TimeOnly TimeOnlyVal { get; set; } + public virtual TimeOnly? NullTimeOnlyVal { get; set; } + + public virtual TimeSpan TimeSpanVal { get; set; } + public virtual TimeSpan? NullTimeSpanVal { get; set; } + + public virtual UInt16 UInt16Val { get; set; } + public virtual UInt16? NullUInt16Val { get; set; } + + public virtual UInt32 UInt32Val { get; set; } + public virtual UInt32? NullUInt32Val { get; set; } + + public virtual UInt64 UInt64Val { get; set; } + public virtual UInt64? NullUInt64Val { get; set; } + +#if NET7_0_OR_GREATER + public virtual UInt128 UInt128Val { get; set; } + public virtual UInt128? NullUInt128Val { get; set; } +#endif + public virtual float FloatVal { get; set; } + public virtual float? NullFloatVal { get; set; } + + public virtual List GetDefaultList() + { + //added out of order + return new List() + { + (TestClass)GetDefault3Record(), + (TestClass)GetDefault0Record(), + (TestClass)GetDefault2Record(), + (TestClass)GetDefault1Record(), + }; + } + + public virtual void CopyToNullVals() + { + NullBoolVal = BoolVal; + NullByteArrayVal = new byte?[] { ByteArrayVal[0] }; + NullByteVal = ByteVal; + NullCharVal = CharVal; + NullDateOnlyVal = DateOnlyVal; + NullDateTimeOffsetVal = DateTimeOffsetVal; + NullDateTimeVal = DateTimeVal; + NullDecimalVal = DecimalVal; + NullDoubleVal = DoubleVal; + NullFloatVal = FloatVal; + NullGuidVal = GuidVal; + NullIntVal = IntVal; + NullLongVal = LongVal; + NullShortVal = ShortVal; + NullSByteVal = SByteVal; + NullSingleVal = SingleVal; + NullStringVal = StringVal; + NullTimeOnlyVal = TimeOnlyVal; + NullTimeSpanVal = TimeSpanVal; + NullUInt16Val = UInt16Val; + NullUInt32Val = UInt32Val; + NullUInt64Val = UInt64Val; +#if NET7_0_OR_GREATER + NullUInt128Val = UInt128Val; +#endif + } + + public virtual ITestClass GetDefault0Record() + { + return new TestClass() + { + BoolVal = false, + ByteArrayVal = new byte[] { 0 }, + ByteVal = 0, + CharVal = ' ', + DateOnlyVal = new DateOnly(2000, 1, 1), + DateTimeOffsetVal = new DateTimeOffset(2000, 1, 1, 0, 0, 0, 0, TimeSpan.Zero), + DateTimeVal = new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), + DecimalVal = 0, + DoubleVal = 0, + FloatVal = 0, + GuidVal = Guid.Empty, + IntVal = 0, + LongVal = 0, + ShortVal = 0, + SByteVal = 0, + SingleVal = 0, + StringVal = " ", + TimeOnlyVal = new TimeOnly(0, 0, 0), + TimeSpanVal = TimeSpan.Zero, + UInt16Val = 0, + UInt32Val = 0, + UInt64Val = 0, +#if NET7_0_OR_GREATER + UInt128Val = 0, +#endif + SharedParentKey = 1 + }; + } + + public virtual ITestClass GetDefault1Record() + { + return new TestClass() + { + BoolVal = true, + ByteArrayVal = new byte[] { 1 }, + ByteVal = 1, + CharVal = 'a', + DateOnlyVal = new DateOnly(2001, 1, 1), + DateTimeOffsetVal = new DateTimeOffset(2001, 1, 1, 1, 1, 1, 1, TimeSpan.Zero), + DateTimeVal = new DateTime(2001, 1, 1, 1, 1, 1, 1, DateTimeKind.Utc), + DecimalVal = 1, + DoubleVal = 1, + FloatVal = 1, + GuidVal = Guid.Parse("11111111-1111-1111-1111-111111111111"), + IntVal = 1, + LongVal = 1, + ShortVal = 1, + SByteVal = 1, + SingleVal = 1, + StringVal = "a", + TimeOnlyVal = new TimeOnly(1, 1, 1), + TimeSpanVal = TimeSpan.FromMilliseconds(1), + UInt16Val = 1, + UInt32Val = 1, + UInt64Val = 1, +#if NET7_0_OR_GREATER + UInt128Val = 1, +#endif + SharedParentKey = 1 + }; + } + + public virtual ITestClass GetDefault2Record() + { + return new TestClass() + { + BoolVal = false, + ByteArrayVal = new byte[] { 2 }, + ByteVal = 2, + CharVal = 'b', + DateOnlyVal = new DateOnly(2002, 2, 2), + DateTimeOffsetVal = new DateTimeOffset(2002, 2, 2, 2, 2, 2, 2, TimeSpan.Zero), + DateTimeVal = new DateTime(2002, 2, 2, 2, 2, 2, 2, DateTimeKind.Utc), + DecimalVal = 2, + DoubleVal = 2, + FloatVal = 2, + GuidVal = Guid.Parse("22222222-2222-2222-2222-222222222222"), + IntVal = 2, + LongVal = 2, + ShortVal = 2, + SByteVal = 2, + SingleVal = 2, + StringVal = "b", + TimeOnlyVal = new TimeOnly(2, 2, 2), + TimeSpanVal = TimeSpan.FromMilliseconds(2), + UInt16Val = 2, + UInt32Val = 2, + UInt64Val = 2, +#if NET7_0_OR_GREATER + UInt128Val = 2, +#endif + SharedParentKey = 1 + }; + } + + public virtual ITestClass GetDefault3Record() + { + return new TestClass() + { + BoolVal = true, + ByteArrayVal = new byte[] { 3 }, + ByteVal = 3, + CharVal = 'c', + DateOnlyVal = new DateOnly(2003, 3, 3), + DateTimeOffsetVal = new DateTimeOffset(2003, 3, 3, 3, 3, 3, 3, TimeSpan.Zero), + DateTimeVal = new DateTime(2003, 3, 3, 3, 3, 3, 3, DateTimeKind.Utc), + DecimalVal = 3, + DoubleVal = 3, + FloatVal = 3, + GuidVal = Guid.Parse("33333333-3333-3333-3333-333333333333"), + IntVal = 3, + LongVal = 3, + ShortVal = 3, + SByteVal = 3, + SingleVal = 3, + StringVal = "c", + TimeOnlyVal = new TimeOnly(3, 3, 3), + TimeSpanVal = TimeSpan.FromMilliseconds(3), + UInt16Val = 3, + UInt32Val = 3, + UInt64Val = 3, +#if NET7_0_OR_GREATER + UInt128Val = 3, +#endif + SharedParentKey = 1 + }; + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/TestClassWithUInt128.cs b/src/Tests/TestFiles/V2/TestClassWithUInt128.cs new file mode 100644 index 0000000..53c76d2 --- /dev/null +++ b/src/Tests/TestFiles/V2/TestClassWithUInt128.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Data.Common; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace ServiceQuery.Xunit +{ + public class TestClassWithUInt128 : TestClass + { +#if NET7_0 + public UInt128 UInt128Val { get; set; } +#endif + + public static List GetDefaultList() + { + //added out of order + return new List() + { + GetDefault3Record(), + GetDefault0Record(), + GetDefault2Record(), + GetDefault1Record(), + }; + } + + public static TestClassWithUInt128 GetDefault0Record() + { + return new TestClassWithUInt128() + { + BoolVal = false, + ByteArrayVal = new byte[] { 0 }, + ByteVal = 0, + CharVal = ' ', + DateTimeOffsetVal = new DateTimeOffset(2000, 1, 1, 0, 0, 0, 0, TimeSpan.Zero), + DateTimeVal = new DateTime(2000, 1, 1, 0, 0, 0, 0), + DecimalVal = 0, + DoubleVal = 0, + FloatVal = 0, + GuidVal = Guid.Empty, + IntVal = 0, + LongVal = 0, + ShortVal = 0, + SByteVal = 0, + SingleVal = 0, + StringVal = " ", + TimeSpanVal = TimeSpan.Zero, +#if NET7_0 + UInt128Val = 0, +#endif + UInt16Val = 0, + UInt32Val = 0, + UInt64Val = 0 + }; + } + + public static TestClassWithUInt128 GetDefault1Record() + { + return new TestClassWithUInt128() + { + BoolVal = true, + ByteArrayVal = new byte[] { 1 }, + ByteVal = 1, + CharVal = 'a', + DateTimeOffsetVal = new DateTimeOffset(2001, 1, 1, 1, 1, 1, 1, TimeSpan.Zero), + DateTimeVal = new DateTime(2001, 1, 1, 1, 1, 1, 1), + DecimalVal = 1, + DoubleVal = 1, + FloatVal = 1, + GuidVal = Guid.Parse("11111111-1111-1111-1111-111111111111"), + IntVal = 1, + LongVal = 1, + ShortVal = 1, + SByteVal = 1, + SingleVal = 1, + StringVal = "a", + TimeSpanVal = TimeSpan.FromMilliseconds(1), +#if NET7_0 + UInt128Val = 1, +#endif + UInt16Val = 1, + UInt32Val = 1, + UInt64Val = 1 + }; + } + + public static TestClassWithUInt128 GetDefault2Record() + { + return new TestClassWithUInt128() + { + BoolVal = false, + ByteArrayVal = new byte[] { 2 }, + ByteVal = 2, + CharVal = 'b', + DateTimeOffsetVal = new DateTimeOffset(2002, 2, 2, 2, 2, 2, 2, TimeSpan.Zero), + DateTimeVal = new DateTime(2002, 2, 2, 2, 2, 2, 2), + DecimalVal = 2, + DoubleVal = 2, + FloatVal = 2, + GuidVal = Guid.Parse("22222222-2222-2222-2222-222222222222"), + IntVal = 2, + LongVal = 2, + ShortVal = 2, + SByteVal = 2, + SingleVal = 2, + StringVal = "b", + TimeSpanVal = TimeSpan.FromMilliseconds(2), +#if NET7_0 + UInt128Val = 2, +#endif + UInt16Val = 2, + UInt32Val = 2, + UInt64Val = 2 + }; + } + + public static TestClassWithUInt128 GetDefault3Record() + { + return new TestClassWithUInt128() + { + BoolVal = true, + ByteArrayVal = new byte[] { 3 }, + ByteVal = 3, + CharVal = 'c', + DateTimeOffsetVal = new DateTimeOffset(2003, 3, 3, 3, 3, 3, 3, TimeSpan.Zero), + DateTimeVal = new DateTime(2003, 3, 3, 3, 3, 3, 3), + DecimalVal = 3, + DoubleVal = 3, + FloatVal = 3, + GuidVal = Guid.Parse("33333333-3333-3333-3333-333333333333"), + IntVal = 3, + LongVal = 3, + ShortVal = 3, + SByteVal = 3, + SingleVal = 3, + StringVal = "c", + TimeSpanVal = TimeSpan.FromMilliseconds(3), +#if NET7_0 + UInt128Val = 3, +#endif + UInt16Val = 3, + UInt32Val = 3, + UInt64Val = 3 + }; + } + } +} \ No newline at end of file diff --git a/src/Tests/TestFiles/V2/_HotToGetCodeCoverage.txt b/src/Tests/TestFiles/V2/_HotToGetCodeCoverage.txt new file mode 100644 index 0000000..d54d150 --- /dev/null +++ b/src/Tests/TestFiles/V2/_HotToGetCodeCoverage.txt @@ -0,0 +1,14 @@ +https://stackoverflow.com/questions/70321465/how-to-get-code-coverage-from-unit-tests-in-visual-studio-2022-community-edition + +dotnet tool install -g dotnet-coverage +dotnet tool install -g dotnet-reportgenerator-globaltool + +Run this command in powershell in the test project directory: + +dotnet-coverage collect -f xml -o coverage.xml dotnet test ServiceQueryV2Net8.Xunit.csproj + +Then run this command next: + +reportgenerator -reports:coverage.xml -targetdir:.\report -assemblyfilters:+ServiceQuery.dll + + diff --git a/src/tests/testfiles/_HotToGetCodeCoverage.txt b/src/tests/testfiles/_HotToGetCodeCoverage.txt index ee62582..a836b8a 100644 --- a/src/tests/testfiles/_HotToGetCodeCoverage.txt +++ b/src/tests/testfiles/_HotToGetCodeCoverage.txt @@ -5,7 +5,7 @@ dotnet tool install -g dotnet-reportgenerator-globaltool Run this command in powershell in the test project directory: -dotnet-coverage collect -f xml -o coverage.xml dotnet test ServiceQuery7.Xunit.csproj +dotnet-coverage collect -f xml -o coverage.xml dotnet test ServiceQuery8.Xunit.csproj Then run this command next: