コード例 #1
0
        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);
        }
コード例 #2
0
        public FakeMongoCollectionTest()
        {
            var client = new FakeMongoClient(MongoUrl.Create("mongodb://localhost:27017"));
            var db     = client.GetDatabase("test");

            collection = db.GetCollection <Document>("test");
        }
コード例 #3
0
        public void GetDatabaseReturnsDatabase()
        {
            var client   = new FakeMongoClient();
            var database = client.GetDatabase("fake-database");

            database.Should().NotBeNull();
            database.Client.Should().BeSameAs(client);
        }
コード例 #4
0
        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);
        }