@@ -27,6 +27,7 @@ public sealed class JsonDrivenRunCommandTest : JsonDrivenDatabaseTest
2727 {
2828 // private fields
2929 private BsonDocument _command ;
30+ private ReadConcern _readConcern = new ReadConcern ( ) ;
3031 private ReadPreference _readPreference ;
3132 private BsonDocument _result ;
3233 private IClientSessionHandle _session ;
@@ -40,7 +41,8 @@ public JsonDrivenRunCommandTest(IMongoDatabase database, Dictionary<string, obje
4041 // public methods
4142 public override void Arrange ( BsonDocument document )
4243 {
43- JsonDrivenHelper . EnsureAllFieldsAreValid ( document , "name" , "object" , "command_name" , "arguments" , "result" ) ;
44+ var expectedNames = new [ ] { "name" , "object" , "command_name" , "arguments" , "result" , "databaseOptions" } ;
45+ JsonDrivenHelper . EnsureAllFieldsAreValid ( document , expectedNames ) ;
4446 base . Arrange ( document ) ;
4547
4648 if ( document . Contains ( "command_name" ) )
@@ -65,23 +67,31 @@ protected override void CallMethod(CancellationToken cancellationToken)
6567 {
6668 if ( _session == null )
6769 {
68- _result = _database . RunCommand < BsonDocument > ( _command , _readPreference , cancellationToken ) ;
70+ _result = _database
71+ . WithReadConcern ( _readConcern )
72+ . RunCommand < BsonDocument > ( _command , _readPreference , cancellationToken ) ;
6973 }
7074 else
7175 {
72- _result = _database . RunCommand < BsonDocument > ( _session , _command , _readPreference , cancellationToken ) ;
76+ _result = _database
77+ . WithReadConcern ( _readConcern )
78+ . RunCommand < BsonDocument > ( _session , _command , _readPreference , cancellationToken ) ;
7379 }
7480 }
7581
7682 protected override async Task CallMethodAsync ( CancellationToken cancellationToken )
7783 {
7884 if ( _session == null )
7985 {
80- _result = await _database . RunCommandAsync < BsonDocument > ( _command , _readPreference , cancellationToken ) ;
86+ _result = await _database
87+ . WithReadConcern ( _readConcern )
88+ . RunCommandAsync < BsonDocument > ( _command , _readPreference , cancellationToken ) . ConfigureAwait ( false ) ;
8189 }
8290 else
8391 {
84- _result = await _database . RunCommandAsync < BsonDocument > ( _session , _command , _readPreference , cancellationToken ) ;
92+ _result = await _database
93+ . WithReadConcern ( _readConcern )
94+ . RunCommandAsync < BsonDocument > ( _session , _command , _readPreference , cancellationToken ) . ConfigureAwait ( false ) ;
8595 }
8696 }
8797
@@ -92,6 +102,13 @@ protected override void SetArgument(string name, BsonValue value)
92102 case "command" :
93103 _command = value . AsBsonDocument ;
94104 return ;
105+
106+ case "databaseOptions" :
107+ if ( value . AsBsonDocument . TryGetValue ( "readConcern" , out var readConcernValue ) )
108+ {
109+ _readConcern = ReadConcern . FromBsonDocument ( readConcernValue . AsBsonDocument ) ;
110+ }
111+ return ;
95112
96113 case "readPreference" :
97114 _readPreference = ReadPreference . FromBsonDocument ( value . AsBsonDocument ) ;
0 commit comments