@@ -92,6 +92,20 @@ public void Should_translate_a_single_top_level_field_with_an_operation()
92
92
result . Value . Should ( ) . Be ( "jack" ) ;
93
93
}
94
94
95
+ [ Fact ]
96
+ public void Should_translate_a_new_expression_where_one_field_starts_with_another_field ( )
97
+ {
98
+ var result = Project ( p => new { p . C . E , p . C . E1 } , "{ C : { E : { F : 2, H : 3 }, E1 : { F : 4, H : 5 } } }" ) ;
99
+
100
+ result . Projection . Should ( ) . Be ( "{ \" C.E\" : 1, \" C.E1\" : 1, _id : 0 }" ) ;
101
+
102
+ result . Value . E . F . Should ( ) . Be ( 2 ) ;
103
+ result . Value . E . H . Should ( ) . Be ( 3 ) ;
104
+
105
+ result . Value . E1 . F . Should ( ) . Be ( 4 ) ;
106
+ result . Value . E1 . H . Should ( ) . Be ( 5 ) ;
107
+ }
108
+
95
109
[ Fact ]
96
110
public void Should_translate_a_new_expression_with_a_single_top_level_field ( )
97
111
{
@@ -112,6 +126,17 @@ public void Should_translate_a_new_expression_with_a_single_top_level_computed_f
112
126
result . Value . FullName . Should ( ) . Be ( "Jack Awesome" ) ;
113
127
}
114
128
129
+ [ Fact ]
130
+ public void Should_translate_a_new_expression_with_top_level_fields_when_one_field_starts_with_another ( )
131
+ {
132
+ var result = Project ( p => new { p . A , p . A1 } , "{ A : \" Jack\" , A1 : \" Peter\" }" ) ;
133
+
134
+ result . Projection . Should ( ) . Be ( "{ A : 1, A1 : 1 _id: 0 }" ) ;
135
+
136
+ result . Value . A . Should ( ) . Be ( "Jack" ) ;
137
+ result . Value . A1 . Should ( ) . Be ( "Peter" ) ;
138
+ }
139
+
115
140
[ Fact ]
116
141
public void Should_translate_when_a_top_level_field_is_repeated ( )
117
142
{
@@ -144,7 +169,19 @@ public void Should_translate_with_a_single_computed_nested_field()
144
169
}
145
170
146
171
[ Fact ]
147
- public void Should_translate_with_a_hierarchical_redundancy ( )
172
+ public void Should_translate_with_a_hierarchical_redundancy_and_a_non_top_level_projection ( )
173
+ {
174
+ var result = Project ( p => new { p . C . E , F = p . C . E . F } , "{ C : { E : { F : 2, H : 3 } } }" ) ;
175
+
176
+ result . Projection . Should ( ) . Be ( "{ \" C.E\" : 1, _id : 0 }" ) ;
177
+
178
+ result . Value . E . H . Should ( ) . Be ( 3 ) ;
179
+ result . Value . F . Should ( ) . Be ( 2 ) ;
180
+ result . Value . E . F . Should ( ) . Be ( 2 ) ;
181
+ }
182
+
183
+ [ Fact ]
184
+ public void Should_translate_with_a_hierarchical_redundancy_and_a_top_level_projection ( )
148
185
{
149
186
var result = Project ( p => new { p . C , F = p . C . E . F } , "{ C: { D: \" CEO\" , E: { F: 2 } } }" ) ;
150
187
@@ -155,6 +192,18 @@ public void Should_translate_with_a_hierarchical_redundancy()
155
192
result . Value . F . Should ( ) . Be ( 2 ) ;
156
193
}
157
194
195
+ [ Fact ]
196
+ public void Should_translate_with_a_hierarchical_redundancy_and_when_one_field_starts_with_another ( )
197
+ {
198
+ var result = Project ( p => new { p . C . E , F = p . C . E . E1 . F } , "{ C : { E : { E1 : { F : 2, H : 3 } } } }" ) ;
199
+
200
+ result . Projection . Should ( ) . Be ( "{ \" C.E\" : 1, _id : 0 }" ) ;
201
+
202
+ result . Value . E . E1 . H . Should ( ) . Be ( 3 ) ;
203
+ result . Value . E . E1 . F . Should ( ) . Be ( 2 ) ;
204
+ result . Value . F . Should ( ) . Be ( 2 ) ;
205
+ }
206
+
158
207
[ Fact ]
159
208
public void Should_translate_a_single_top_level_array ( )
160
209
{
@@ -259,6 +308,8 @@ private class Root
259
308
260
309
public string A { get ; set ; }
261
310
311
+ public string A1 { get ; set ; }
312
+
262
313
public string B { get ; set ; }
263
314
264
315
public C C { get ; set ; }
@@ -271,6 +322,8 @@ public class C
271
322
public string D { get ; set ; }
272
323
273
324
public E E { get ; set ; }
325
+
326
+ public E E1 { get ; set ; }
274
327
}
275
328
276
329
public class E
@@ -280,6 +333,8 @@ public class E
280
333
public int H { get ; set ; }
281
334
282
335
public IEnumerable < string > I { get ; set ; }
336
+
337
+ public E E1 { get ; set ; }
283
338
}
284
339
}
285
340
}
0 commit comments