@@ -118,7 +118,7 @@ public void constructor_should_initialize_instance()
118
118
subject . NoCursorTimeout . Should ( ) . NotHaveValue ( ) ;
119
119
subject . OplogReplay . Should ( ) . NotHaveValue ( ) ;
120
120
subject . Projection . Should ( ) . BeNull ( ) ;
121
- subject . ReadConcern . Should ( ) . NotHaveValue ( ) ;
121
+ subject . ReadConcern . Should ( ) . Be ( ReadConcern . Default ) ;
122
122
subject . ResultSerializer . Should ( ) . Be ( BsonDocumentSerializer . Instance ) ;
123
123
subject . ReturnKey . Should ( ) . NotHaveValue ( ) ;
124
124
subject . ShowRecordId . Should ( ) . NotHaveValue ( ) ;
@@ -171,7 +171,7 @@ public void CreateFindCommandOperation_should_return_expected_result()
171
171
subject . NoCursorTimeout = true ;
172
172
subject . OplogReplay = true ;
173
173
subject . Projection = new BsonDocument ( "projection" , 1 ) ;
174
- subject . ReadConcern = 5 ;
174
+ subject . ReadConcern = ReadConcern . Local ;
175
175
subject . ReturnKey = true ;
176
176
subject . ShowRecordId = true ;
177
177
subject . SingleBatch = true ;
@@ -211,7 +211,10 @@ public void CreateFindCommandOperation_should_return_expected_result()
211
211
[ Test ]
212
212
public void CreateFindCommandOperation_should_return_expected_result_when_modifiers_are_provided ( )
213
213
{
214
- var subject = new FindOperation < BsonDocument > ( _collectionNamespace , BsonDocumentSerializer . Instance , _messageEncoderSettings ) ;
214
+ var subject = new FindOperation < BsonDocument > ( _collectionNamespace , BsonDocumentSerializer . Instance , _messageEncoderSettings )
215
+ {
216
+ ReadConcern = ReadConcern . Majority
217
+ } ;
215
218
subject . Modifiers = new BsonDocument
216
219
{
217
220
{ "$hint" , "x_1" } ,
@@ -231,6 +234,7 @@ public void CreateFindCommandOperation_should_return_expected_result_when_modifi
231
234
result . MaxScan . Should ( ) . Be ( subject . Modifiers [ "$maxScan" ] . AsInt32 ) ;
232
235
result . MaxTime . Should ( ) . Be ( TimeSpan . FromMilliseconds ( subject . Modifiers [ "$maxTimeMS" ] . AsInt32 ) ) ;
233
236
result . Min . Should ( ) . Be ( subject . Modifiers [ "$min" ] . AsBsonDocument ) ;
237
+ result . ReadConcern . Should ( ) . Be ( subject . ReadConcern ) ;
234
238
result . ShowRecordId . Should ( ) . Be ( subject . Modifiers [ "$showDiskLoc" ] . AsBoolean ) ;
235
239
result . Snapshot . Should ( ) . Be ( subject . Modifiers [ "$snapshot" ] . AsBoolean ) ;
236
240
result . Sort . Should ( ) . Be ( subject . Modifiers [ "$orderby" ] . AsBsonDocument ) ;
@@ -254,7 +258,7 @@ public void CreateFindOpcodeOperation_should_return_expected_result()
254
258
subject . NoCursorTimeout = true ;
255
259
subject . OplogReplay = true ;
256
260
subject . Projection = new BsonDocument ( "projection" , 1 ) ;
257
- subject . ReadConcern = 5 ;
261
+ subject . ReadConcern = ReadConcern . Local ;
258
262
subject . ReturnKey = true ;
259
263
subject . ShowRecordId = true ;
260
264
subject . SingleBatch = false ;
@@ -367,6 +371,21 @@ public void Execute_should_find_documents_matching_options(
367
371
result . Should ( ) . HaveCount ( 1 ) ;
368
372
}
369
373
374
+ [ Test ]
375
+ [ RequiresServer ( "EnsureTestData" , VersionLessThan = "3.1.0" ) ]
376
+ public void Execute_should_raise_an_error_when_an_unsupported_read_concern_is_specified (
377
+ [ Values ( false , true ) ]
378
+ bool async )
379
+ {
380
+ var subject = new FindOperation < BsonDocument > ( _collectionNamespace , BsonDocumentSerializer . Instance , _messageEncoderSettings )
381
+ {
382
+ ReadConcern = ReadConcern . Majority
383
+ } ;
384
+
385
+ Action act = ( ) => ExecuteOperation ( subject , async ) ;
386
+ act . ShouldThrow < MongoClientException > ( ) ;
387
+ }
388
+
370
389
[ Test ]
371
390
public void ExecuteAsync_should_throw_when_binding_is_null ( )
372
391
{
@@ -566,16 +585,14 @@ public void Projection_get_and_set_should_work(
566
585
}
567
586
568
587
[ Test ]
569
- public void ReadConcern_get_and_set_should_work (
570
- [ Values ( null , 0 , 1 ) ]
571
- int ? value )
588
+ public void ReadConcern_get_and_set_should_work ( )
572
589
{
573
590
var subject = new FindOperation < BsonDocument > ( _collectionNamespace , BsonDocumentSerializer . Instance , _messageEncoderSettings ) ;
574
591
575
- subject . ReadConcern = value ;
592
+ subject . ReadConcern = ReadConcern . Local ;
576
593
var result = subject . ReadConcern ;
577
594
578
- result . Should ( ) . Be ( value ) ;
595
+ result . Should ( ) . Be ( ReadConcern . Local ) ;
579
596
}
580
597
581
598
[ Test ]
0 commit comments