@@ -1185,6 +1185,47 @@ public void TestUpsertWithOneMatchingDocument(bool ordered)
11851185 }
11861186 }
11871187
1188+ [ Test ]
1189+ [ TestCase ( false ) ]
1190+ [ TestCase ( true ) ]
1191+ public void TestW2AgainstStandalone ( bool ordered )
1192+ {
1193+ using ( _server . RequestStart ( null , ReadPreference . Primary ) )
1194+ {
1195+ var serverInstance = _server . RequestConnection . ServerInstance ;
1196+ if ( serverInstance . InstanceType == MongoServerInstanceType . StandAlone )
1197+ {
1198+ _collection . Drop ( ) ;
1199+ var documents = new [ ] { new BsonDocument ( "x" , 1 ) } ;
1200+
1201+ var bulk = InitializeBulkOperation ( _collection , ordered ) ;
1202+ bulk . Insert ( documents [ 0 ] ) ;
1203+
1204+ if ( serverInstance . Supports ( FeatureId . WriteCommands ) )
1205+ {
1206+ var exception = Assert . Throws < MongoCommandException > ( ( ) => { bulk . Execute ( WriteConcern . W2 ) ; } ) ;
1207+ Assert . AreEqual ( 0 , _collection . Count ( ) ) ;
1208+ }
1209+ else
1210+ {
1211+ var exception = Assert . Throws < BulkWriteException > ( ( ) => { bulk . Execute ( WriteConcern . W2 ) ; } ) ;
1212+ var result = exception . Result ;
1213+
1214+ var expectedResult = new ExpectedResult { InsertedCount = 1 , RequestCount = 1 } ;
1215+ CheckExpectedResult ( expectedResult , result ) ;
1216+
1217+ Assert . AreEqual ( 0 , exception . UnprocessedRequests . Count ) ;
1218+ Assert . AreEqual ( 0 , exception . WriteErrors . Count ) ;
1219+
1220+ var writeConcernError = exception . WriteConcernError ;
1221+ Assert . IsNotNull ( writeConcernError ) ;
1222+
1223+ Assert . That ( _collection . FindAll ( ) , Is . EquivalentTo ( documents ) ) ;
1224+ }
1225+ }
1226+ }
1227+ }
1228+
11881229 // private methods
11891230 private void CheckExpectedResult ( ExpectedResult expectedResult , BulkWriteResult result )
11901231 {
0 commit comments