|
1 |
| -using System.Linq.Dynamic.Core.Tests.Helpers; |
| 1 | +using System.Collections.Generic; |
2 | 2 | using System.Linq.Dynamic.Core.Tests.Helpers.Models;
|
3 | 3 | using Xunit;
|
4 | 4 |
|
5 | 5 | namespace System.Linq.Dynamic.Core.Tests
|
6 | 6 | {
|
7 | 7 | public class ComplexTests
|
8 | 8 | {
|
| 9 | + /// <summary> |
| 10 | + /// groupByExpressionX "new (new (Company.Name as CompanyName) as GroupByFields)" string |
| 11 | + /// </summary> |
| 12 | + [Fact] |
| 13 | + public void GroupByAndSelect_Test_Illegal_one_byte_branch_at_position_9_Requested_branch_was_143() |
| 14 | + { |
| 15 | + var testList = new List<Entities.Employee>(); |
| 16 | + var qry = testList.AsQueryable(); |
| 17 | + |
| 18 | + string keySelector = "new (new (Company.Name as CompanyName) as GroupByFields)"; |
| 19 | + var group = qry.GroupBy(keySelector); |
| 20 | + Assert.NotNull(group); |
| 21 | + |
| 22 | + var result = group.ToDynamicList(); |
| 23 | + Assert.NotNull(result); |
| 24 | + } |
| 25 | + |
| 26 | + /// <summary> |
| 27 | + /// groupByExpressionX "new (new (Company.Name as CompanyName) as GroupByFields)" string |
| 28 | + /// string.Format("new (it AS TEntity__{0})", includesX) "new (it AS TEntity__, it.Company as TEntity__Company, it.Company.MainCompany as TEntity__Company_MainCompany, it.Country as TEntity__Country, it.Function as TEntity__Function, it.SubFunction as TEntity__SubFunction)" string |
| 29 | + /// selectExpressionBeforeOrderByX = "new (Key.GroupByFields, it as Grouping , new (Count() as count__CompanyName, Min(TEntity__.EmployeeNumber) as min__Number, Max(TEntity__.EmployeeNumber) as max__Number, Average(TEntity__.EmployeeNumber) as average__Number, Sum(TEntity__.EmployeeNumber) as sum__Number) as Aggregates)"; |
| 30 | + /// </summary> |
| 31 | + [Fact] |
| 32 | + public void GroupByAndSelect_Test_GroupByWithSelect() |
| 33 | + { |
| 34 | + var testList = new List<Entities.Employee>(); |
| 35 | + var qry = testList.AsQueryable(); |
| 36 | + |
| 37 | + string keySelector = "new (new (Company.Name as CompanyName) as GroupByFields)"; |
| 38 | + string resultSelector = "new (it AS TEntity__, it.Company as TEntity__Company, it.Company.MainCompany as TEntity__Company_MainCompany, it.Country as TEntity__Country, it.Function as TEntity__Function, it.SubFunction as TEntity__SubFunction)"; |
| 39 | + var group = qry.GroupBy(keySelector, resultSelector); |
| 40 | + Assert.NotNull(group); |
| 41 | + |
| 42 | + var result = group.ToDynamicList(); |
| 43 | + Assert.NotNull(result); |
| 44 | + |
| 45 | + string selectExpressionBeforeOrderByX = "new (Key.GroupByFields, it as Grouping , new (Count() as count__CompanyName, Min(TEntity__.EmployeeNumber) as min__Number, Max(TEntity__.EmployeeNumber) as max__Number, Average(TEntity__.EmployeeNumber) as average__Number, Sum(TEntity__.EmployeeNumber) as sum__Number) as Aggregates)"; |
| 46 | + var selectQ = group.Select(selectExpressionBeforeOrderByX); |
| 47 | + Assert.NotNull(selectQ); |
| 48 | + |
| 49 | + var resultSelect = selectQ.ToDynamicList(); |
| 50 | + Assert.NotNull(resultSelect); |
| 51 | + } |
| 52 | + |
9 | 53 | /// <summary>
|
10 | 54 | /// The purpose of this test is to verify that after a group by of a dynamically created
|
11 | 55 | /// key, the Select clause can access the key's members
|
|
0 commit comments