当前位置: 首页>>代码示例>>C#>>正文


C# BsonDocument.ToBsonDocument方法代码示例

本文整理汇总了C#中BsonDocument.ToBsonDocument方法的典型用法代码示例。如果您正苦于以下问题:C# BsonDocument.ToBsonDocument方法的具体用法?C# BsonDocument.ToBsonDocument怎么用?C# BsonDocument.ToBsonDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BsonDocument的用法示例。


在下文中一共展示了BsonDocument.ToBsonDocument方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestToBsonDocumentEmptyDocument

 public void TestToBsonDocumentEmptyDocument()
 {
     var empty = new BsonDocument();
     var document = empty.ToBsonDocument();
     Assert.AreEqual(0, document.ElementCount);
 }
开发者ID:jenrom,项目名称:mongo-csharp-driver,代码行数:6,代码来源:BsonExtensionMethodsTests.cs

示例2: TestToBsonDocument

 public void TestToBsonDocument()
 {
     var document = new BsonDocument();
     Assert.AreSame(document, document.ToBsonDocument());
     Assert.AreSame(document, ((IConvertibleToBsonDocument)document).ToBsonDocument());
 }
开发者ID:jijamw,项目名称:mongo-csharp-driver,代码行数:6,代码来源:BsonDocumentTests.cs

示例3: Stream_IgnoresEverythingBeforeTimestampPassedIn

        public async Task Stream_IgnoresEverythingBeforeTimestampPassedIn()
        {
            var tailer = new Tailer(m_client);
            IOutlet outlet = Substitute.For<IOutlet>();
            var stream = new Stream(tailer, outlet);

            var databaseName = "_Test_MongoRiver";
            var collectionName = "_Test_MongoRiver";

            var insertedDocument = new FooBarDocument { Id = "foo", Bar = "baz" };
            var filterDocument = new BsonDocument("_id", "foo");
            var updatedDocument = new FooBarDocument { Id = "foo", Bar = "qux" };

            IMongoDatabase database = m_client.GetDatabase(databaseName);
            IMongoCollection<FooBarDocument> collection = database.GetCollection<FooBarDocument>(collectionName);

            await collection.InsertOneAsync(insertedDocument);
            await collection.ReplaceOneAsync(filterDocument, updatedDocument);

            Oplog lastOplog = await tailer.GetMostRecentOplog(DateTime.UtcNow.AddSeconds(-3));
            await m_client.DropDatabaseAsync(databaseName);
            await RunStream(stream, lastOplog);

            outlet.Received(4).UpdateOptime(Arg.Any<BsonTimestamp>());
            outlet.Received().Insert(databaseName, collectionName, insertedDocument.ToBsonDocument());
            outlet.Received().Update(databaseName, collectionName, filterDocument.ToBsonDocument(), updatedDocument.ToBsonDocument());
            outlet.Received().DeleteDatabase(databaseName);
        }
开发者ID:andreimatusevich,项目名称:MongoRiver.NET,代码行数:28,代码来源:RiverConnectedTests.cs

示例4: TestConstructorNoArgs

        public void TestConstructorNoArgs()
        {
            var document = new BsonDocument();
            Assert.AreEqual(false, document.AllowDuplicateNames);
            Assert.IsInstanceOf<BsonDocument>(document.AsBsonDocument);
            Assert.AreEqual(BsonType.Document, document.BsonType);
            Assert.AreEqual(false, document.Contains("name"));
            Assert.AreEqual(false, document.ContainsValue(0));
            Assert.AreEqual(0, document.ElementCount);
            Assert.AreEqual(0, document.Elements.Count());
            Assert.AreEqual(false, document.IsBsonArray);
            Assert.AreEqual(true, document.IsBsonDocument);
            Assert.AreEqual(0, document.Names.Count());
#pragma warning disable 618
            Assert.AreEqual(null, document.RawValue);
            Assert.AreEqual(0, document.RawValues.Count());
#pragma warning restore
            Assert.AreEqual(true, document.ToBoolean());
            Assert.AreSame(document, document.ToBsonDocument());
            Assert.AreEqual("{ }", document.ToJson());
            Assert.AreEqual(0, document.Values.Count());
        }
开发者ID:jijamw,项目名称:mongo-csharp-driver,代码行数:22,代码来源:BsonDocumentTests.cs


注:本文中的BsonDocument.ToBsonDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。