Skip to content

Commit

Permalink
Change tests that use dropDatabase to use small databases.
Browse files Browse the repository at this point in the history
  • Loading branch information
rstam committed Apr 1, 2015
1 parent f52f3e8 commit f8297b9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public class ListIndexesOperationTests
[TestFixtureSetUp]
public void TestFixtureSetUp()
{
_collectionNamespace = CoreTestConfiguration.GetCollectionNamespaceForTestFixture();
var databaseNamespace = CoreTestConfiguration.GetDatabaseNamespaceForTestFixture();
_collectionNamespace = new CollectionNamespace(databaseNamespace, "ListIndexesOperationTests");
_messageEncoderSettings = CoreTestConfiguration.MessageEncoderSettings;
}

Expand Down
15 changes: 9 additions & 6 deletions src/MongoDB.Driver.Legacy.Tests/MongoDatabaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public void Setup()
_server = LegacyTestConfiguration.Server;
_primary = LegacyTestConfiguration.Server.Primary;
_database = LegacyTestConfiguration.Database;
_database.Drop();
// TODO: DropDatabase
//_database.Drop();
}

// TODO: more tests for MongoDatabase
Expand Down Expand Up @@ -251,11 +252,13 @@ public void TestGetCollectionGeneric()
[Test]
public void TestGetCollectionNames()
{
_database.Drop();
_database.GetCollection("a").Insert(new BsonDocument("a", 1));
_database.GetCollection("b").Insert(new BsonDocument("b", 1));
_database.GetCollection("c").Insert(new BsonDocument("c", 1));
var collectionNames = _database.GetCollectionNames();
var databaseNamespace = CoreTestConfiguration.GetDatabaseNamespaceForTestFixture();
var database = _server.GetDatabase(databaseNamespace.DatabaseName);
database.Drop();
database.GetCollection("a").Insert(new BsonDocument("a", 1));
database.GetCollection("b").Insert(new BsonDocument("b", 1));
database.GetCollection("c").Insert(new BsonDocument("c", 1));
var collectionNames = database.GetCollectionNames();
Assert.AreEqual(new[] { "a", "b", "c" }, collectionNames.Where(n => n != "system.indexes"));
}

Expand Down
24 changes: 16 additions & 8 deletions src/MongoDB.Driver.Legacy.Tests/MongoServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,14 @@ public void TestDatabaseExists()
{
if (!_isMasterSlavePair)
{
_database.Drop();
Assert.IsFalse(_server.DatabaseExists(_database.Name));
_collection.Insert(new BsonDocument("x", 1));
Assert.IsTrue(_server.DatabaseExists(_database.Name));
var databaseNamespace = CoreTestConfiguration.GetDatabaseNamespaceForTestFixture();
var database = _server.GetDatabase(databaseNamespace.DatabaseName);
var collection = database.GetCollection("test");

database.Drop();
Assert.IsFalse(_server.DatabaseExists(database.Name));
collection.Insert(new BsonDocument("x", 1));
Assert.IsTrue(_server.DatabaseExists(database.Name));
}
}

Expand All @@ -100,13 +104,17 @@ public void TestDropDatabase()
{
if (!_isMasterSlavePair)
{
_collection.Insert(new BsonDocument());
var databaseNamespace = CoreTestConfiguration.GetDatabaseNamespaceForTestFixture();
var database = _server.GetDatabase(databaseNamespace.DatabaseName);
var collection = database.GetCollection("test");

collection.Insert(new BsonDocument());
var databaseNames = _server.GetDatabaseNames();
Assert.IsTrue(databaseNames.Contains(_database.Name));
Assert.IsTrue(databaseNames.Contains(database.Name));

_server.DropDatabase(_database.Name);
_server.DropDatabase(database.Name);
databaseNames = _server.GetDatabaseNames();
Assert.IsFalse(databaseNames.Contains(_database.Name));
Assert.IsFalse(databaseNames.Contains(database.Name));
}
}

Expand Down

0 comments on commit f8297b9

Please sign in to comment.