public void GetDatabase() { var db1 = client.GetDatabase("test"); var db2 = client.GetDatabase("test"); Assert.NotNull(db1); Assert.Equal("test", db1.DatabaseNamespace.DatabaseName); Assert.Equal(db1, db2); }
public FakeMongoCollectionTest() { var client = new FakeMongoClient(MongoUrl.Create("mongodb://localhost:27017")); var db = client.GetDatabase("test"); collection = db.GetCollection <Document>("test"); }
public void GetDatabaseReturnsDatabase() { var client = new FakeMongoClient(); var database = client.GetDatabase("fake-database"); database.Should().NotBeNull(); database.Client.Should().BeSameAs(client); }
public void DropDatabase() { var client = new FakeMongoClient(); client.GetDatabase("fake-database"); var _databasesProperty = client.GetType().GetField("_databases", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); var databases = (ConcurrentDictionary <string, IMongoDatabase>)_databasesProperty.GetValue(client); Assert.Single(databases); client.DropDatabase("fake-database"); Assert.Empty(databases); }