|
1 |
| -using System.Collections.Generic; |
| 1 | +using System.Collections.Generic; |
2 | 2 | using System.Dynamic;
|
3 | 3 | using System.Globalization;
|
4 | 4 | using System.Linq.Dynamic.Core.Exceptions;
|
@@ -1304,6 +1304,69 @@ public void ExpressionTests_Method_OneParam_With_it()
|
1304 | 1304 | Assert.Equal(expected.Count(), result.Count());
|
1305 | 1305 | }
|
1306 | 1306 |
|
| 1307 | + public class DefaultDynamicLinqCustomTypeProviderForStaticTesting : CustomTypeProviders.DefaultDynamicLinqCustomTypeProvider |
| 1308 | + { |
| 1309 | + public override HashSet<Type> GetCustomTypes() => new HashSet<Type>(base.GetCustomTypes()) { typeof(Methods), typeof(MethodsItemExtension) }; |
| 1310 | + } |
| 1311 | + |
| 1312 | + [Fact] |
| 1313 | + public void ExpressionTests_MethodCall_GenericStatic() |
| 1314 | + { |
| 1315 | + var config = new ParsingConfig |
| 1316 | + { |
| 1317 | + CustomTypeProvider = new DefaultDynamicLinqCustomTypeProviderForStaticTesting() |
| 1318 | + }; |
| 1319 | + |
| 1320 | + // Arrange |
| 1321 | + var list = new[] { 0, 1, 2, 3, 4 }.Select(value => new Methods.Item { Value = value }).ToArray(); |
| 1322 | + |
| 1323 | + // Act |
| 1324 | + var expectedResult = list.Where(x => Methods.StaticGenericMethod(x)); |
| 1325 | + var result = list.AsQueryable().Where(config, "Methods.StaticGenericMethod(it)"); |
| 1326 | + |
| 1327 | + // Assert |
| 1328 | + Assert.Equal(expectedResult.Count(), result.Count()); |
| 1329 | + } |
| 1330 | + |
| 1331 | + [Fact] |
| 1332 | + public void ExpressionTests_MethodCall_Generic() |
| 1333 | + { |
| 1334 | + var config = new ParsingConfig |
| 1335 | + { |
| 1336 | + CustomTypeProvider = new DefaultDynamicLinqCustomTypeProviderForStaticTesting() |
| 1337 | + }; |
| 1338 | + |
| 1339 | + // Arrange |
| 1340 | + var list = new[] { 0, 1, 2, 3, 4 }.Select(value => new Methods.Item { Value = value }).ToArray(); |
| 1341 | + |
| 1342 | + // Act |
| 1343 | + var methods = new Methods(); |
| 1344 | + var expectedResult = list.Where(x => methods.GenericMethod(x)); |
| 1345 | + var result = list.AsQueryable().Where("@0.GenericMethod(it)", methods); |
| 1346 | + |
| 1347 | + // Assert |
| 1348 | + Assert.Equal(expectedResult.Count(), result.Count()); |
| 1349 | + } |
| 1350 | + |
| 1351 | + [Fact] |
| 1352 | + public void ExpressionTests_MethodCall_GenericExtension() |
| 1353 | + { |
| 1354 | + var config = new ParsingConfig |
| 1355 | + { |
| 1356 | + CustomTypeProvider = new DefaultDynamicLinqCustomTypeProviderForStaticTesting() |
| 1357 | + }; |
| 1358 | + |
| 1359 | + // Arrange |
| 1360 | + var list = new[] { 0, 1, 2, 3, 4 }.Select(value => new Methods.Item { Value = value }).ToArray(); |
| 1361 | + |
| 1362 | + // Act |
| 1363 | + var methods = new Methods(); |
| 1364 | + var expectedResult = list.Where(x => MethodsItemExtension.Functions.EfCoreCollate(x.Value, "tlh-KX") == 2); |
| 1365 | + var result = list.AsQueryable().Where(config, "MethodsItemExtension.Functions.EfCoreCollate(it.Value,\"tlh-KX\")==2"); |
| 1366 | + |
| 1367 | + // Assert |
| 1368 | + Assert.Equal(expectedResult.Count(), result.Count()); |
| 1369 | + } |
1307 | 1370 |
|
1308 | 1371 | [Fact]
|
1309 | 1372 | public void ExpressionTests_MethodCall_ValueTypeToValueTypeParameter()
|
|
0 commit comments