File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed
tests/MongoFramework.Tests/Infrastructure/Linq/Translation/Translators Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Linq ;
4
+ using System . Linq . Expressions ;
5
+ using System . Text ;
6
+ using System . Threading . Tasks ;
7
+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
8
+ using MongoDB . Bson ;
9
+ using MongoFramework . Infrastructure . Linq . Translation . Translators ;
10
+
11
+ namespace MongoFramework . Tests . Infrastructure . Linq . Translation . Translators
12
+ {
13
+ [ TestClass ]
14
+ public class SelectorTranslatorTests : QueryTestBase
15
+ {
16
+ [ TestMethod ]
17
+ public void SelectProperty ( )
18
+ {
19
+ var expression = GetExpression ( q => q . Select ( e => e . Id ) ) ;
20
+ var result = new SelectTranslator ( ) . TranslateMethod ( expression as MethodCallExpression ) ;
21
+ var expected = new BsonDocument
22
+ {
23
+ {
24
+ "$project" ,
25
+ new BsonDocument
26
+ {
27
+ { "Id" , "$Id" } ,
28
+ { "_id" , 0 }
29
+ }
30
+ }
31
+ } ;
32
+
33
+ Assert . AreEqual ( expected , result ) ;
34
+ }
35
+
36
+
37
+ [ TestMethod ]
38
+ public void SelectNewAnonymousType ( )
39
+ {
40
+ var expression = GetExpression ( q => q . Select ( e => new { CustomPropertyName = e . Id } ) ) ;
41
+ var result = new SelectTranslator ( ) . TranslateMethod ( expression as MethodCallExpression ) ;
42
+ var expected = new BsonDocument
43
+ {
44
+ {
45
+ "$project" ,
46
+ new BsonDocument
47
+ {
48
+ { "CustomPropertyName" , "Id" } ,
49
+ { "_id" , 0 }
50
+ }
51
+ }
52
+ } ;
53
+
54
+ Assert . AreEqual ( expected , result ) ;
55
+ }
56
+ }
57
+ }
You can’t perform that action at this time.
0 commit comments