1- using System . Collections . Generic ;
2- using System . Dynamic ;
1+ using System . Collections . Concurrent ;
2+ using System . Collections . Generic ;
3+ using System . Collections . ObjectModel ;
34using System . Linq . Expressions ;
45using FluentAssertions ;
56using NFluent ;
@@ -13,6 +14,7 @@ public class Customer
1314 {
1415 public string City { get ; set ; }
1516 public Dictionary < string , Order > Orders { get ; set ; }
17+ public IReadOnlyDictionary < string , Order > ReadOnlyOrders { get ; set ; }
1618 public string CompanyName { get ; set ; }
1719 public string Phone { get ; set ; }
1820 }
@@ -22,13 +24,32 @@ public class Order
2224 }
2325
2426 [ Fact ]
25- public void Test_ContainsKey_1 ( )
27+ public void ReadOnlyDictionary_ContainsKey_1 ( )
2628 {
27- var customers = new List < Customer > ( )
29+ var orders = new ReadOnlyDictionary < string , Order > ( new Dictionary < string , Order >
2830 {
29- new Customer ( ) { City = "ZZZ1" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) } ,
30- new Customer ( ) { City = "ZZZ2" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) } ,
31- new Customer ( ) { City = "ZZZ3" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) }
31+ { "TEST" , new Order ( ) }
32+ } ) ;
33+ var customers = new List < Customer >
34+ {
35+ new Customer { City = "abc" , CompanyName = "ZZZ" , ReadOnlyOrders = orders }
36+ } ;
37+
38+ var data = customers . AsQueryable ( )
39+ . Where ( "ReadOnlyOrders.ContainsKey(\" TEST\" )" )
40+ . ToList ( ) ;
41+
42+ data . Should ( ) . HaveCount ( 1 ) ;
43+ }
44+
45+ [ Fact ]
46+ public void Dictionary_ContainsKey_1 ( )
47+ {
48+ var customers = new List < Customer >
49+ {
50+ new Customer { City = "ZZZ1" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) } ,
51+ new Customer { City = "ZZZ2" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) } ,
52+ new Customer { City = "ZZZ3" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) }
3253 } ;
3354 customers . ForEach ( x => x . Orders . Add ( x . City + "TEST" , new Order ( ) ) ) ;
3455
@@ -41,13 +62,13 @@ public void Test_ContainsKey_1()
4162 }
4263
4364 [ Fact ]
44- public void Test_ContainsKey_2 ( )
65+ public void Dictionary_ContainsKey_2 ( )
4566 {
46- var customers = new List < Customer > ( )
67+ var customers = new List < Customer >
4768 {
48- new Customer ( ) { City = "ZZZ1" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) } ,
49- new Customer ( ) { City = "ZZZ2" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) } ,
50- new Customer ( ) { City = "ZZZ3" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) }
69+ new Customer { City = "ZZZ1" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) } ,
70+ new Customer { City = "ZZZ2" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) } ,
71+ new Customer { City = "ZZZ3" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) }
5172 } ;
5273 customers . ForEach ( x => x . Orders . Add ( x . City + "TEST" , new Order ( ) ) ) ;
5374
@@ -61,13 +82,13 @@ public void Test_ContainsKey_2()
6182 }
6283
6384 [ Fact ]
64- public void Test_ContainsKey_3 ( )
85+ public void Dictionary_ContainsKey_3 ( )
6586 {
66- var customers = new List < Customer > ( )
87+ var customers = new List < Customer >
6788 {
68- new Customer ( ) { City = "ZZZ1" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) } ,
69- new Customer ( ) { City = "ZZZ2" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) } ,
70- new Customer ( ) { City = "ZZZ3" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) }
89+ new Customer { City = "ZZZ1" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) } ,
90+ new Customer { City = "ZZZ2" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) } ,
91+ new Customer { City = "ZZZ3" , CompanyName = "ZZZ" , Orders = new Dictionary < string , Order > ( ) }
7192 } ;
7293 customers . ForEach ( x => x . Orders . Add ( x . City + "TEST1" , new Order ( ) ) ) ;
7394 customers . ForEach ( x => x . Orders . Add ( x . City + "TEST2" , new Order ( ) ) ) ;
@@ -91,7 +112,7 @@ public void Test_ContainsKey_3()
91112#else
92113 [ Fact ( Skip = "Fails in NET452 CI" ) ]
93114#endif
94- public void Test_DynamicIndexCall ( ) // https://github.com/zzzprojects/System.Linq.Dynamic.Core/issues/397
115+ public void DynamicIndexCall ( ) // https://github.com/zzzprojects/System.Linq.Dynamic.Core/issues/397
95116 {
96117 object CreateDicParameter ( string name ) => new Dictionary < string , object >
97118 {
0 commit comments