@@ -30,13 +30,19 @@ public class MongoServerTests
30
30
private MongoServer _server ;
31
31
private MongoDatabase _database ;
32
32
private MongoCollection < BsonDocument > _collection ;
33
+ private bool _isMasterSlavePair ;
33
34
34
35
[ TestFixtureSetUp ]
35
36
public void Setup ( )
36
37
{
37
38
_server = Configuration . TestServer ;
38
39
_database = Configuration . TestDatabase ;
39
40
_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" ) ;
40
46
}
41
47
42
48
// TODO: more tests for MongoServer
@@ -55,22 +61,28 @@ public void TestCreateNoArgs()
55
61
[ Test ]
56
62
public void TestDatabaseExists ( )
57
63
{
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
+ }
62
71
}
63
72
64
73
[ Test ]
65
74
public void TestDropDatabase ( )
66
75
{
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 ) ) ;
70
81
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
+ }
74
86
}
75
87
76
88
[ Test ]
0 commit comments