@@ -27,6 +27,7 @@ public sealed class JsonDrivenRunCommandTest : JsonDrivenDatabaseTest
27
27
{
28
28
// private fields
29
29
private BsonDocument _command ;
30
+ private ReadConcern _readConcern = new ReadConcern ( ) ;
30
31
private ReadPreference _readPreference ;
31
32
private BsonDocument _result ;
32
33
private IClientSessionHandle _session ;
@@ -40,7 +41,8 @@ public JsonDrivenRunCommandTest(IMongoDatabase database, Dictionary<string, obje
40
41
// public methods
41
42
public override void Arrange ( BsonDocument document )
42
43
{
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 ) ;
44
46
base . Arrange ( document ) ;
45
47
46
48
if ( document . Contains ( "command_name" ) )
@@ -65,23 +67,31 @@ protected override void CallMethod(CancellationToken cancellationToken)
65
67
{
66
68
if ( _session == null )
67
69
{
68
- _result = _database . RunCommand < BsonDocument > ( _command , _readPreference , cancellationToken ) ;
70
+ _result = _database
71
+ . WithReadConcern ( _readConcern )
72
+ . RunCommand < BsonDocument > ( _command , _readPreference , cancellationToken ) ;
69
73
}
70
74
else
71
75
{
72
- _result = _database . RunCommand < BsonDocument > ( _session , _command , _readPreference , cancellationToken ) ;
76
+ _result = _database
77
+ . WithReadConcern ( _readConcern )
78
+ . RunCommand < BsonDocument > ( _session , _command , _readPreference , cancellationToken ) ;
73
79
}
74
80
}
75
81
76
82
protected override async Task CallMethodAsync ( CancellationToken cancellationToken )
77
83
{
78
84
if ( _session == null )
79
85
{
80
- _result = await _database . RunCommandAsync < BsonDocument > ( _command , _readPreference , cancellationToken ) ;
86
+ _result = await _database
87
+ . WithReadConcern ( _readConcern )
88
+ . RunCommandAsync < BsonDocument > ( _command , _readPreference , cancellationToken ) . ConfigureAwait ( false ) ;
81
89
}
82
90
else
83
91
{
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 ) ;
85
95
}
86
96
}
87
97
@@ -92,6 +102,13 @@ protected override void SetArgument(string name, BsonValue value)
92
102
case "command" :
93
103
_command = value . AsBsonDocument ;
94
104
return ;
105
+
106
+ case "databaseOptions" :
107
+ if ( value . AsBsonDocument . TryGetValue ( "readConcern" , out var readConcernValue ) )
108
+ {
109
+ _readConcern = ReadConcern . FromBsonDocument ( readConcernValue . AsBsonDocument ) ;
110
+ }
111
+ return ;
95
112
96
113
case "readPreference" :
97
114
_readPreference = ReadPreference . FromBsonDocument ( value . AsBsonDocument ) ;
0 commit comments