@@ -30,13 +30,19 @@ public class MongoServerTests
3030 private MongoServer _server ;
3131 private MongoDatabase _database ;
3232 private MongoCollection < BsonDocument > _collection ;
33+ private bool _isMasterSlavePair ;
3334
3435 [ TestFixtureSetUp ]
3536 public void Setup ( )
3637 {
3738 _server = Configuration . TestServer ;
3839 _database = Configuration . TestDatabase ;
3940 _collection = Configuration . TestCollection ;
41+
42+ var adminDatabase = _server . GetDatabase ( "admin" ) ;
43+ var commandResult = adminDatabase . RunCommand ( "getCmdLineOpts" ) ;
44+ var argv = commandResult . Response [ "argv" ] . AsBsonArray ;
45+ _isMasterSlavePair = argv . Contains ( "--master" ) || argv . Contains ( "--slave" ) ;
4046 }
4147
4248 // TODO: more tests for MongoServer
@@ -55,22 +61,28 @@ public void TestCreateNoArgs()
5561 [ Test ]
5662 public void TestDatabaseExists ( )
5763 {
58- _database . Drop ( ) ;
59- Assert . IsFalse ( _server . DatabaseExists ( _database . Name ) ) ;
60- _collection . Insert ( new BsonDocument ( "x" , 1 ) ) ;
61- Assert . IsTrue ( _server . DatabaseExists ( _database . Name ) ) ;
64+ if ( ! _isMasterSlavePair )
65+ {
66+ _database . Drop ( ) ;
67+ Assert . IsFalse ( _server . DatabaseExists ( _database . Name ) ) ;
68+ _collection . Insert ( new BsonDocument ( "x" , 1 ) ) ;
69+ Assert . IsTrue ( _server . DatabaseExists ( _database . Name ) ) ;
70+ }
6271 }
6372
6473 [ Test ]
6574 public void TestDropDatabase ( )
6675 {
67- _collection . Insert ( new BsonDocument ( ) ) ;
68- var databaseNames = _server . GetDatabaseNames ( ) ;
69- Assert . IsTrue ( databaseNames . Contains ( _database . Name ) ) ;
76+ if ( ! _isMasterSlavePair )
77+ {
78+ _collection . Insert ( new BsonDocument ( ) ) ;
79+ var databaseNames = _server . GetDatabaseNames ( ) ;
80+ Assert . IsTrue ( databaseNames . Contains ( _database . Name ) ) ;
7081
71- var result = _server . DropDatabase ( _database . Name ) ;
72- databaseNames = _server . GetDatabaseNames ( ) ;
73- Assert . IsFalse ( databaseNames . Contains ( _database . Name ) ) ;
82+ var result = _server . DropDatabase ( _database . Name ) ;
83+ databaseNames = _server . GetDatabaseNames ( ) ;
84+ Assert . IsFalse ( databaseNames . Contains ( _database . Name ) ) ;
85+ }
7486 }
7587
7688 [ Test ]
0 commit comments