• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# FindCommandOperation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中FindCommandOperation的典型用法代码示例。如果您正苦于以下问题:C# FindCommandOperation类的具体用法?C# FindCommandOperation怎么用?C# FindCommandOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FindCommandOperation类属于命名空间,在下文中一共展示了FindCommandOperation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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");
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:10,代码来源:FindCommandOperationTests.cs


示例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);
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:11,代码来源:FindCommandOperationTests.cs


示例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");
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:11,代码来源:FindCommandOperationTests.cs


示例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);
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:11,代码来源:FindCommandOperationTests.cs


示例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);
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:12,代码来源:FindCommandOperationTests.cs


示例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);
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:12,代码来源:FindCommandOperationTests.cs


示例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}' }} }}");
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:15,代码来源:FindCommandOperationTests.cs


示例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);
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:18,代码来源:FindCommandOperationTests.cs


示例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");
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:8,代码来源:FindCommandOperationTests.cs


示例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);
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:11,代码来源:FindCommandOperationTests.cs


示例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);
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:12,代码来源:FindCommandOperationTests.cs


示例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);
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:11,代码来源:FindCommandOperationTests.cs


示例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>();
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:16,代码来源:FindCommandOperationTests.cs


示例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);
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:11,代码来源:FindCommandOperationTests.cs


示例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);
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:9,代码来源:FindCommandOperationTests.cs


示例16: Min_get_and_set_should_work

        public void Min_get_and_set_should_work(
            [Values(null, "{ x : 1 }", "{ x : 2 }")]
            string valueString)
        {
            var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
            var value = valueString == null ? null : BsonDocument.Parse(valueString);

            subject.Min = value;
            var result = subject.Min;

            result.Should().BeSameAs(value);
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:12,代码来源:FindCommandOperationTests.cs


示例17: Limit_get_and_set_should_work

        public void Limit_get_and_set_should_work(
            [Values(-2, -1, 0, 1, 2)]
            int? value)
        {
            var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);

            subject.Limit = value;
            var result = subject.Limit;

            result.Should().Be(value);
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:11,代码来源:FindCommandOperationTests.cs


示例18: CreateCommand_should_return_expected_result_when_maxTime_is_provided

        public void CreateCommand_should_return_expected_result_when_maxTime_is_provided(
            [Values(1, 2)]
            int value)
        {
            var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
            subject.MaxTime = TimeSpan.FromSeconds(value);
            var reflector = new Reflector(subject);
            var serverDescription = CreateServerDescription();

            var result = reflector.CreateCommand(serverDescription, null);

            result.Should().Be($"{{ find : '{_collectionNamespace.CollectionName}', maxTimeMS : {value * 1000} }}");
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:13,代码来源:FindCommandOperationTests.cs


示例19: CreateCommand_should_return_expected_result_when_cursor_is_tailableAwait

        public void CreateCommand_should_return_expected_result_when_cursor_is_tailableAwait(CursorType value, string awaitJson)
        {
            var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
            subject.CursorType = value;
            var reflector = new Reflector(subject);
            var serverDescription = CreateServerDescription();

            var result = reflector.CreateCommand(serverDescription, null);

            result.Should().Be($"{{ find : '{_collectionNamespace.CollectionName}', tailable : true{awaitJson} }}");
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:11,代码来源:FindCommandOperationTests.cs


示例20: CreateCommand_should_return_expected_result

        public void CreateCommand_should_return_expected_result()
        {
            var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
            var reflector = new Reflector(subject);
            var serverDescription = CreateServerDescription();

            var result = reflector.CreateCommand(serverDescription, null);

            result.Should().Be($"{{ find : '{_collectionNamespace.CollectionName}' }}");
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:10,代码来源:FindCommandOperationTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FindOperation类代码示例发布时间:2022-05-24
下一篇:
C# Find类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap