1
- using System . Collections . Generic ;
2
- using System . Dynamic ;
1
+ using System . Collections . Concurrent ;
2
+ using System . Collections . Generic ;
3
+ using System . Collections . ObjectModel ;
3
4
using System . Linq . Expressions ;
4
5
using FluentAssertions ;
5
6
using NFluent ;
@@ -13,6 +14,7 @@ public class Customer
13
14
{
14
15
public string City { get ; set ; }
15
16
public Dictionary < string , Order > Orders { get ; set ; }
17
+ public IReadOnlyDictionary < string , Order > ReadOnlyOrders { get ; set ; }
16
18
public string CompanyName { get ; set ; }
17
19
public string Phone { get ; set ; }
18
20
}
@@ -22,13 +24,32 @@ public class Order
22
24
}
23
25
24
26
[ Fact ]
25
- public void Test_ContainsKey_1 ( )
27
+ public void ReadOnlyDictionary_ContainsKey_1 ( )
26
28
{
27
- var customers = new List < Customer > ( )
29
+ var orders = new ReadOnlyDictionary < string , Order > ( new Dictionary < string , Order >
28
30
{
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 > ( ) }
32
53
} ;
33
54
customers . ForEach ( x => x . Orders . Add ( x . City + "TEST" , new Order ( ) ) ) ;
34
55
@@ -41,13 +62,13 @@ public void Test_ContainsKey_1()
41
62
}
42
63
43
64
[ Fact ]
44
- public void Test_ContainsKey_2 ( )
65
+ public void Dictionary_ContainsKey_2 ( )
45
66
{
46
- var customers = new List < Customer > ( )
67
+ var customers = new List < Customer >
47
68
{
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 > ( ) }
51
72
} ;
52
73
customers . ForEach ( x => x . Orders . Add ( x . City + "TEST" , new Order ( ) ) ) ;
53
74
@@ -61,13 +82,13 @@ public void Test_ContainsKey_2()
61
82
}
62
83
63
84
[ Fact ]
64
- public void Test_ContainsKey_3 ( )
85
+ public void Dictionary_ContainsKey_3 ( )
65
86
{
66
- var customers = new List < Customer > ( )
87
+ var customers = new List < Customer >
67
88
{
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 > ( ) }
71
92
} ;
72
93
customers . ForEach ( x => x . Orders . Add ( x . City + "TEST1" , new Order ( ) ) ) ;
73
94
customers . ForEach ( x => x . Orders . Add ( x . City + "TEST2" , new Order ( ) ) ) ;
@@ -91,7 +112,7 @@ public void Test_ContainsKey_3()
91
112
#else
92
113
[ Fact ( Skip = "Fails in NET452 CI" ) ]
93
114
#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
95
116
{
96
117
object CreateDicParameter ( string name ) => new Dictionary < string , object >
97
118
{
0 commit comments