本文整理汇总了C#中FindCommandOperation类的典型用法代码示例。如果您正苦于以下问题:C# FindCommandOperation类的具体用法?C# FindCommandOperation怎么用?C# FindCommandOperation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FindCommandOperation类属于命名空间,在下文中一共展示了FindCommandOperation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BatchSize_set_should_throw_when_value_is_invalid
public void BatchSize_set_should_throw_when_value_is_invalid(
[Values(-1)]
int value)
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
Action action = () => subject.BatchSize = value;
action.ShouldThrow<ArgumentException>().And.ParamName.Should().Be("value");
}
示例2: BatchSize_get_and_set_should_work
public void BatchSize_get_and_set_should_work(
[Values(null, 0, 1)]
int? value)
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
subject.BatchSize = value;
var result = subject.BatchSize;
result.Should().Be(value);
}
示例3: BatchSize_set_should_throw_when_value_is_invalid
public void BatchSize_set_should_throw_when_value_is_invalid(
[Values(-2, -1)]
int value)
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
var exception = Record.Exception(() => subject.BatchSize = value);
var argumentOutOfRangeException = exception.Should().BeOfType<ArgumentOutOfRangeException>().Subject;
argumentOutOfRangeException.ParamName.Should().Be("value");
}
示例4: AllowPartialResults_get_and_set_should_work
public void AllowPartialResults_get_and_set_should_work(
[Values(null, false, true)]
bool? value)
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
subject.AllowPartialResults = value;
var result = subject.AllowPartialResults;
result.Should().Be(value);
}
示例5: Collation_get_and_set_should_work
public void Collation_get_and_set_should_work(
[Values(null, "en_US", "fr_CA")]
string locale)
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
var value = locale == null ? null : new Collation(locale);
subject.Collation = value;
var result = subject.Collation;
result.Should().BeSameAs(value);
}
示例6: CollectionNamespace_get_should_return_expected_result
public void CollectionNamespace_get_should_return_expected_result(
[Values("a", "b")]
string collectionName)
{
var databaseNamespace = new DatabaseNamespace("test");
var collectionNamespace = new CollectionNamespace(databaseNamespace, collectionName);
var subject = new FindCommandOperation<BsonDocument>(collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
var result = subject.CollectionNamespace;
result.Should().Be(collectionNamespace);
}
示例7: CreateCommand_should_return_expected_result_when_readPreference_is_provided
public void CreateCommand_should_return_expected_result_when_readPreference_is_provided(
[Values(ReadPreferenceMode.PrimaryPreferred, ReadPreferenceMode.Secondary)]
ReadPreferenceMode value)
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
var readPreference = new ReadPreference(value);
var reflector = new Reflector(subject);
var serverDescription = CreateServerDescription(type: ServerType.ShardRouter);
var result = reflector.CreateCommand(serverDescription, readPreference);
var mode = value.ToString();
var camelCaseMode = char.ToLower(mode[0]) + mode.Substring(1);
result.Should().Be($"{{ find : '{_collectionNamespace.CollectionName}', readPreference : {{ mode : '{camelCaseMode}' }} }}");
}
示例8: ExecuteAsync_should_find_documents_matching_options
public async Task ExecuteAsync_should_find_documents_matching_options()
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
Comment = "funny",
Filter = BsonDocument.Parse("{ y : 1 }"),
Limit = 4,
MaxTime = TimeSpan.FromSeconds(20),
Projection = BsonDocument.Parse("{ y : 1 }"),
Skip = 1,
Sort = BsonDocument.Parse("{ _id : -1 }")
};
var cursor = await ExecuteOperationAsync(subject);
var result = await ReadCursorToEndAsync(cursor);
result.Should().HaveCount(1);
}
示例9: ExecuteAsync_should_throw_when_binding_is_null
public void ExecuteAsync_should_throw_when_binding_is_null()
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
Func<Task> action = () => subject.ExecuteAsync(null, CancellationToken.None);
action.ShouldThrow<ArgumentNullException>().And.ParamName.Should().Be("binding");
}
示例10: CursorType_get_and_set_should_work
public void CursorType_get_and_set_should_work(
[Values(CursorType.NonTailable, CursorType.Tailable)]
CursorType value)
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
subject.CursorType = value;
var result = subject.CursorType;
result.Should().Be(value);
}
示例11: ExecuteAsync_should_find_all_the_documents_matching_the_query_when_split_across_batches
public async Task ExecuteAsync_should_find_all_the_documents_matching_the_query_when_split_across_batches()
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
BatchSize = 2
};
var cursor = await ExecuteOperationAsync(subject);
var result = await ReadCursorToEndAsync(cursor);
result.Should().HaveCount(5);
}
示例12: Comment_get_and_set_should_work
public void Comment_get_and_set_should_work(
[Values(null, "a", "b")]
string value)
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
subject.Comment = value;
var result = subject.Comment;
result.Should().Be(value);
}
示例13: Execute_should_throw_when_Collation_is_set_and_not_suppported
public void Execute_should_throw_when_Collation_is_set_and_not_suppported(
[Values(false, true)]
bool async)
{
RequireServer.Check().Supports(Feature.FindCommand).DoesNotSupport(Feature.Collation);
EnsureTestData();
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
Collation = new Collation("en_US", caseLevel: false, strength: CollationStrength.Primary),
Filter = BsonDocument.Parse("{ x : 'd' }")
};
var exception = Record.Exception(() => ExecuteOperation(subject, async));
exception.Should().BeOfType<NotSupportedException>();
}
示例14: MessageEncoderSettings_get_should_return_expected_result
public void MessageEncoderSettings_get_should_return_expected_result(
[Values(GuidRepresentation.CSharpLegacy, GuidRepresentation.Standard)]
GuidRepresentation guidRepresentation)
{
var messageEncoderSettings = new MessageEncoderSettings { { "GuidRepresentation", guidRepresentation } };
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, messageEncoderSettings);
var result = subject.MessageEncoderSettings;
result.Should().BeEquivalentTo(messageEncoderSettings);
}
示例15: ResultSerializer_get_should_return_expected_result
public void ResultSerializer_get_should_return_expected_result()
{
var resultSerializer = new BsonDocumentSerializer();
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, resultSerializer, _messageEncoderSettings);
var result = subject.ResultSerializer;
result.Should().Be(resultSerializer);
}