|
13 | 13 | * limitations under the License.
|
14 | 14 | */
|
15 | 15 |
|
| 16 | +using System; |
16 | 17 | using FluentAssertions;
|
17 | 18 | using MongoDB.Bson;
|
18 | 19 | using MongoDB.Bson.TestHelpers.XunitExtensions;
|
19 | 20 | using MongoDB.Driver.Core;
|
20 | 21 | using MongoDB.Driver.Core.Clusters;
|
| 22 | +using MongoDB.Driver.Core.Configuration; |
21 | 23 | using MongoDB.Driver.Core.Events;
|
22 | 24 | using MongoDB.Driver.Core.TestHelpers.XunitExtensions;
|
23 | 25 | using MongoDB.Driver.TestHelpers;
|
| 26 | +using Xunit; |
24 | 27 |
|
25 | 28 | namespace MongoDB.Driver.Tests
|
26 | 29 | {
|
27 | 30 | public class RetryableWritesTests
|
28 | 31 | {
|
| 32 | + [SkippableFact] |
| 33 | + public void Insert_with_RetryWrites_true_should_work_whether_retryable_writes_are_supported_or_not() |
| 34 | + { |
| 35 | + RequireServer.Check(); |
| 36 | + |
| 37 | + using (var client = GetClient()) |
| 38 | + { |
| 39 | + var database = client.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName); |
| 40 | + var collection = database.GetCollection<BsonDocument>(DriverTestConfiguration.CollectionNamespace.CollectionName); |
| 41 | + var document = new BsonDocument("x", 1); |
| 42 | + collection.InsertOne(document); |
| 43 | + } |
| 44 | + } |
| 45 | + |
29 | 46 | [SkippableFact]
|
30 | 47 | public void TxnNumber_should_be_included_with_FindOneAndDelete()
|
31 | 48 | {
|
@@ -159,21 +176,31 @@ public void TxnNumber_should_be_included_with_UpdateOne()
|
159 | 176 | }
|
160 | 177 | }
|
161 | 178 |
|
162 |
| - private DisposableMongoClient GetClient(EventCapturer capturer) |
| 179 | + private DisposableMongoClient GetClient() |
| 180 | + { |
| 181 | + return GetClient(cb => { }); |
| 182 | + } |
| 183 | + |
| 184 | + private DisposableMongoClient GetClient(Action<ClusterBuilder> clusterConfigurator) |
163 | 185 | {
|
164 | 186 | var connectionString = CoreTestConfiguration.ConnectionString.ToString();
|
165 | 187 | var clientSettings = MongoClientSettings.FromUrl(new MongoUrl(connectionString));
|
166 | 188 | clientSettings.RetryWrites = true;
|
167 |
| - clientSettings.ClusterConfigurator = cb => cb.Subscribe(capturer); |
| 189 | + clientSettings.ClusterConfigurator = cb => cb.Subscribe(clusterConfigurator); |
168 | 190 |
|
169 | 191 | return new DisposableMongoClient(new MongoClient(clientSettings));
|
170 | 192 | }
|
171 | 193 |
|
| 194 | + private DisposableMongoClient GetClient(EventCapturer capturer) |
| 195 | + { |
| 196 | + return GetClient(cb => cb.Subscribe(capturer)); |
| 197 | + } |
| 198 | + |
172 | 199 | private void RequireSupportForRetryableWrites()
|
173 | 200 | {
|
174 | 201 | RequireServer.Check()
|
175 |
| - .VersionGreaterThanOrEqualTo("3.6.0-rc0") |
176 |
| - .ClusterTypes(ClusterType.Sharded, ClusterType.ReplicaSet); |
| 202 | + .VersionGreaterThanOrEqualTo("3.6.0-rc0") |
| 203 | + .ClusterTypes(ClusterType.Sharded, ClusterType.ReplicaSet); |
177 | 204 | }
|
178 | 205 | }
|
179 | 206 | }
|
0 commit comments