File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
MongoDB.DriverUnitTests/Operations Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -1136,6 +1136,32 @@ public void TestW2AgainstStandalone(bool ordered)
1136
1136
}
1137
1137
}
1138
1138
1139
+ [ Test ]
1140
+ public void TestWTimeoutPlusDuplicateKeyError ( )
1141
+ {
1142
+ if ( _primary . InstanceType == MongoServerInstanceType . ReplicaSetMember )
1143
+ {
1144
+ _collection . Drop ( ) ;
1145
+
1146
+ var bulk = _collection . InitializeUnorderedBulkOperation ( ) ;
1147
+ bulk . Insert ( new BsonDocument ( "_id" , 1 ) ) ;
1148
+ bulk . Insert ( new BsonDocument ( "_id" , 1 ) ) ;
1149
+ var exception = Assert . Throws < BulkWriteException > ( ( ) => bulk . Execute ( new WriteConcern { W = 999 , WTimeout = TimeSpan . FromMilliseconds ( 1 ) } ) ) ;
1150
+ var result = exception . Result ;
1151
+
1152
+ var expectedResult = new ExpectedResult { InsertedCount = 1 , RequestCount = 2 } ;
1153
+ CheckExpectedResult ( expectedResult , result ) ;
1154
+
1155
+ var writeErrors = exception . WriteErrors ;
1156
+ Assert . AreEqual ( 1 , writeErrors . Count ) ;
1157
+ Assert . AreEqual ( 11000 , writeErrors [ 0 ] . Code ) ;
1158
+ Assert . AreEqual ( 1 , writeErrors [ 0 ] . Index ) ;
1159
+
1160
+ var writeConcernError = exception . WriteConcernError ;
1161
+ Assert . AreEqual ( 64 , writeConcernError . Code ) ;
1162
+ }
1163
+ }
1164
+
1139
1165
// private methods
1140
1166
private void CheckExpectedResult ( ExpectedResult expectedResult , BulkWriteResult result )
1141
1167
{
You can’t perform that action at this time.
0 commit comments