16
16
using System ;
17
17
using MongoDB . Bson ;
18
18
using MongoDB . Driver ;
19
+ using MongoDB . Driver . Builders ;
19
20
using NUnit . Framework ;
20
21
21
22
namespace MongoDB . DriverUnitTests
@@ -39,7 +40,22 @@ public void TestSetDelegate()
39
40
CanCommandBeSentToSecondary . Delegate = CanCommandBeSentToSecondary . DefaultImplementation ; // reset Delegate
40
41
}
41
42
42
- [ TestCase ( "aggregate" , true ) ]
43
+ [ Test ]
44
+ public void TestCanSendAggregateWithReadOnlyPipelineToSecondary ( )
45
+ {
46
+ var pipeline = new BsonArray
47
+ {
48
+ new BsonDocument { { "$match" , new BsonDocument ( "x" , 1 ) } }
49
+ } ;
50
+ var command = new BsonDocument
51
+ {
52
+ { "aggregate" , "collection" } ,
53
+ { "pipeline" , pipeline }
54
+ } ;
55
+ var result = CanCommandBeSentToSecondary . DefaultImplementation ( command ) ;
56
+ Assert . IsTrue ( result ) ;
57
+ }
58
+
43
59
[ TestCase ( "collStats" , true ) ]
44
60
[ TestCase ( "dbStats" , true ) ]
45
61
[ TestCase ( "count" , true ) ]
@@ -76,6 +92,23 @@ public void TestCanSendInlineMapReduceToSecondary()
76
92
Assert . IsTrue ( result ) ;
77
93
}
78
94
95
+ [ Test ]
96
+ public void TestCannotSendAggregateWithWritePipelineToSecondary ( )
97
+ {
98
+ var pipeline = new BsonArray
99
+ {
100
+ new BsonDocument { { "$match" , new BsonDocument ( "x" , 1 ) } } ,
101
+ new BsonDocument { { "$out" , "output" } }
102
+ } ;
103
+ var command = new BsonDocument
104
+ {
105
+ { "aggregate" , "collection" } ,
106
+ { "pipeline" , pipeline }
107
+ } ;
108
+ var result = CanCommandBeSentToSecondary . DefaultImplementation ( command ) ;
109
+ Assert . IsFalse ( result ) ;
110
+ }
111
+
79
112
[ Test ]
80
113
public void TestCannotSendNonInlineMapReduceToSecondary ( )
81
114
{
0 commit comments