當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。