本文整理汇总了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);
}
示例2: TestToBsonDocument
public void TestToBsonDocument()
{
var document = new BsonDocument();
Assert.AreSame(document, document.ToBsonDocument());
Assert.AreSame(document, ((IConvertibleToBsonDocument)document).ToBsonDocument());
}
示例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);
}
示例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());
}