Thanks!
I am not sure what I am doing wrong but I want to remove all the
documents from a given collection at the end of each test. I am using
the following code in my TearDown method but it does not seems to be
removing the documents from the collection.
public static void RemoveAllDocumentsFromAllCollections()
{
// should not drop the complete database or else the
indexes will be gone.
// remove all records from all the collections
var mongo = new Mongo();
mongo.Connect();
var db = mongo.getDB(GetDatabaseName());
var collectionNames = db.GetCollectionNames();
foreach (var collectionName in collectionNames)
{
var collection = db.GetCollection(collectionName);
// remove every document from collection
collection.Delete(new Document());
}
mongo.Disconnect();
mongo.Dispose();
}
Thanks,
Azam