本文整理汇总了C#中WriteConcern.ToBsonDocument方法的典型用法代码示例。如果您正苦于以下问题:C# WriteConcern.ToBsonDocument方法的具体用法?C# WriteConcern.ToBsonDocument怎么用?C# WriteConcern.ToBsonDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WriteConcern
的用法示例。
在下文中一共展示了WriteConcern.ToBsonDocument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToBsonDocument_should_return_expected_result
public void ToBsonDocument_should_return_expected_result(object w, int? wTimeoutSeconds, bool? fsync, bool? journal, string expectedResult)
{
var wValue = ToWValue(w);
var wTimeout = ToWTimeout(wTimeoutSeconds);
var subject = new WriteConcern(wValue, wTimeout, fsync, journal);
var result = subject.ToBsonDocument();
result.Should().Be(expectedResult);
}
示例2: CreateCommand_should_return_expected_result_when_WriteConcern_is_set
public void CreateCommand_should_return_expected_result_when_WriteConcern_is_set(
[Values(1, 2)]
int w,
[Values(false, true)]
bool isWriteConcernSupported)
{
var requests = new[] { new CreateIndexRequest(new BsonDocument("x", 1)) };
var writeConcern = new WriteConcern(w);
var subject = new CreateIndexesUsingCommandOperation(_collectionNamespace, requests, _messageEncoderSettings)
{
WriteConcern = writeConcern
};
var serverVersion = Feature.CommandsThatWriteAcceptWriteConcern.SupportedOrNotSupportedVersion(isWriteConcernSupported);
var result = subject.CreateCommand(serverVersion);
var expectedResult = new BsonDocument
{
{ "createIndexes", _collectionNamespace.CollectionName },
{ "indexes", new BsonArray { requests[0].CreateIndexDocument(null) } },
{ "writeConcern", () => writeConcern.ToBsonDocument(), isWriteConcernSupported }
};
result.Should().Be(expectedResult);
}