0
根据代码文档MongoServer.GetDatabase
:MongoServer.GetDatabase不返回同一个实例
获取表示该服务器上的数据库MongoDatabase实例。 只有一个实例为数据库 设置每个组合创建。
但是,下面的测试失败(我得到一个不同的实例回来,尽管数据库名称相同):
void describe_get_database()
{
MongoServer server = null;
MongoDatabase db = null;
MongoDatabase db2 = null;
string dbName = null;
before =() =>
{
var client = new MongoClient("mongodb://localhost");
server = client.GetServer();
dbName = "test";
db = server.GetDatabase(dbName);
};
act =() => db2 = server.GetDatabase(dbName);
context["when the database name is the same"] =() =>
{
it["should return the same database instance"] =
() => db2.should_be_same(db);
};
}
我有没有误解的文件?