public void TestClassWithBsonObjectId()
        {
            _collection.RemoveAll();

            var doc = new ClassWithBsonObjectId { Id = null, X = 1 };
            _collection.Insert(doc);
            Assert.IsNotNull(doc.Id);
            Assert.AreNotEqual(ObjectId.Empty, doc.Id.AsObjectId);

            doc = new ClassWithBsonObjectId { Id = ObjectId.Empty, X = 1 };
            _collection.Insert(doc);
            Assert.AreNotEqual(ObjectId.Empty, doc.Id.AsObjectId);

            doc = new ClassWithBsonObjectId { Id = ObjectId.GenerateNewId(), X = 1 };
            _collection.Insert(doc);
        }
예제 #2
0
        public void TestClassWithBsonObjectId()
        {
            _collection.RemoveAll();

            var doc = new ClassWithBsonObjectId { Id = null, X = 1 };
            _collection.Insert(doc);
            Assert.NotNull(doc.Id);
            Assert.NotEqual(ObjectId.Empty, doc.Id.AsObjectId);

            doc = new ClassWithBsonObjectId { Id = ObjectId.Empty, X = 1 };
            _collection.Insert(doc);
            Assert.NotEqual(ObjectId.Empty, doc.Id.AsObjectId);

            doc = new ClassWithBsonObjectId { Id = ObjectId.GenerateNewId(), X = 1 };
            _collection.Insert(doc);
        }