Represents a BSON document that can be used where an IMongoCollectionOptions is expected.
Inheritance: BsonDocument, IMongoCollectionOptions
        public void TestCreateCollectionSetUsePowerOf2Sizes(
            [Values(false, true)]
            bool usePowerOf2Sizes)
        {
            var collection = _database.GetCollection("cappedcollection");
            collection.Drop();
            var userFlags = usePowerOf2Sizes ? CollectionUserFlags.UsePowerOf2Sizes : CollectionUserFlags.None;
            var options = new CollectionOptionsDocument
            {
                { "flags", (int)userFlags }
            };

            _database.CreateCollection(collection.Name, options);

            var stats = collection.GetStats();
            Assert.That(stats.UserFlags, Is.EqualTo(userFlags));
        }
        public void TestCollectionOptionsDocumentConstructor()
        {
            var document1 = new CollectionOptionsDocument(dictionary);
            var document2 = new CollectionOptionsDocument(hashtable);
            var document3 = new CollectionOptionsDocument(idictionaryNonGeneric);
            var document4 = new CollectionOptionsDocument(idictionary);

            Assert.AreEqual("Dictionary<string, object>", document1["type"].AsString);
            Assert.AreEqual("Hashtable", document2["type"].AsString);
            Assert.AreEqual("IDictionary", document3["type"].AsString);
            Assert.AreEqual("IDictionary<string, object>", document4["type"].AsString);
        }
Ejemplo n.º 3
0
        public void TestCreateCollectionSetUsePowerOf2Sizes(
            [Values(false, true)]
            bool usePowerOf2Sizes)
        {
            RequireServer.Where(storageEngines: "mmapv1", clusterTypes: ClusterTypes.StandaloneOrReplicaSet);
            var collection = _database.GetCollection("cappedcollection");
            collection.Drop();
            var userFlags = usePowerOf2Sizes ? CollectionUserFlags.UsePowerOf2Sizes : CollectionUserFlags.None;
            var options = new CollectionOptionsDocument
            {
                { "flags", (int)userFlags }
            };

            _database.CreateCollection(collection.Name, options);

            var stats = collection.GetStats();
            Assert.Equal(userFlags, stats.UserFlags);
        }