当前位置: 首页>>代码示例>>C#>>正文


C# CreateCollectionOperation.CreateCommand方法代码示例

本文整理汇总了C#中CreateCollectionOperation.CreateCommand方法的典型用法代码示例。如果您正苦于以下问题:C# CreateCollectionOperation.CreateCommand方法的具体用法?C# CreateCollectionOperation.CreateCommand怎么用?C# CreateCollectionOperation.CreateCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CreateCollectionOperation的用法示例。


在下文中一共展示了CreateCollectionOperation.CreateCommand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateCommand_should_return_expected_result

        public void CreateCommand_should_return_expected_result()
        {
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings);
            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:12,代码来源:CreateCollectionOperationTests.cs

示例2: CreateCommand_should_return_expected_result_when_ValidationLevel_is_set

        public void CreateCommand_should_return_expected_result_when_ValidationLevel_is_set(
            [Values(DocumentValidationLevel.Moderate, DocumentValidationLevel.Off)]
            DocumentValidationLevel value)
        {
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                ValidationLevel = value
            };
            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "validationLevel", value.ToString().ToLowerInvariant() }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:18,代码来源:CreateCollectionOperationTests.cs

示例3: CreateCommand_should_return_expected_result_when_Validator_is_set

        public void CreateCommand_should_return_expected_result_when_Validator_is_set()
        {
            var value = new BsonDocument("x", 1);
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                Validator = value
            };
            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "validator", value }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:17,代码来源:CreateCollectionOperationTests.cs

示例4: CreateCommand_should_return_expected_result_when_StorageEngine_is_set

        public void CreateCommand_should_return_expected_result_when_StorageEngine_is_set(
            [Values(null, "{ awesome: true }")]
            string storageEngine)
        {
            var storageEngineDoc = storageEngine == null ? null : BsonDocument.Parse(storageEngine);
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                StorageEngine = storageEngineDoc
            };
            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "storageEngine", storageEngineDoc, storageEngine != null }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:19,代码来源:CreateCollectionOperationTests.cs

示例5: CreateCommand_should_return_expected_result_when_UsePowerOf2Sizes_is_set

        public void CreateCommand_should_return_expected_result_when_UsePowerOf2Sizes_is_set(
            [Values(false, true)]
            bool usePowerOf2Sizes)
        {
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                UsePowerOf2Sizes = usePowerOf2Sizes
            };
            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "flags", usePowerOf2Sizes ? 1 : 0 }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:18,代码来源:CreateCollectionOperationTests.cs

示例6: CreateCommand_should_return_expected_result_when_IndexOptionDefaults_is_set

        public void CreateCommand_should_return_expected_result_when_IndexOptionDefaults_is_set()
        {
            var value = new BsonDocument("storageEngine", new BsonDocument("x", 1));
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                IndexOptionDefaults = value
            };
            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "indexOptionDefaults", value }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:17,代码来源:CreateCollectionOperationTests.cs

示例7: CreateCommand_should_return_expected_result_when_MaxSize_is_set

        public void CreateCommand_should_return_expected_result_when_MaxSize_is_set(
            [Values(1, 2)]
            long maxSize)
        {
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                MaxSize = maxSize
            };
            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "size", maxSize }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:18,代码来源:CreateCollectionOperationTests.cs

示例8: CreateCommand_should_return_expected_result_when_WriteConcern_is_set

        public void CreateCommand_should_return_expected_result_when_WriteConcern_is_set(
            [Values(null, 1, 2)]
            int? w,
            [Values(false, true)]
            bool isWriteConcernSupported)
        {
            var writeConcern = w.HasValue ? new WriteConcern(w.Value) : null;
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                WriteConcern = writeConcern
            };
            var serverVersion = Feature.CommandsThatWriteAcceptWriteConcern.SupportedOrNotSupportedVersion(isWriteConcernSupported);

            var result = subject.CreateCommand(serverVersion);

            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "writeConcern", () => writeConcern.ToBsonDocument(), writeConcern != null && isWriteConcernSupported }
            };
            result.Should().Be(expectedResult);
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:22,代码来源:CreateCollectionOperationTests.cs

示例9: CreateCommand_should_return_expected_result_when_Capped_is_set

        public void CreateCommand_should_return_expected_result_when_Capped_is_set(
            [Values(false, true)]
            bool capped)
        {
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                Capped = capped
            };
            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "capped", capped }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:18,代码来源:CreateCollectionOperationTests.cs

示例10: CreateCommand_should_return_expected_result_when_ValidationAction_is_set

        public void CreateCommand_should_return_expected_result_when_ValidationAction_is_set(
            [Values(null, DocumentValidationAction.Error, DocumentValidationAction.Warn)]
            DocumentValidationAction? validationAction)
        {
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                ValidationAction = validationAction
            };

            var result = subject.CreateCommand(null);

            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "validationAction", () => validationAction.ToString().ToLowerInvariant(), validationAction != null }
            };
            result.Should().Be(expectedResult);
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:18,代码来源:CreateCollectionOperationTests.cs

示例11: CreateCommand_should_return_expected_result_when_Validator_is_set

        public void CreateCommand_should_return_expected_result_when_Validator_is_set(
            [Values(null, "{ x : 1 }", "{ x : 2 }")]
            string validatorString)
        {
            var validator = validatorString == null ? null : BsonDocument.Parse(validatorString);
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                Validator = validator
            };

            var result = subject.CreateCommand(null);

            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "validator", validator, validator != null }
            };
            result.Should().Be(expectedResult);
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:19,代码来源:CreateCollectionOperationTests.cs

示例12: CreateCommand_should_return_expected_result_when_MaxDocuments_is_set

        public void CreateCommand_should_return_expected_result_when_MaxDocuments_is_set(
            [Values(null, 1L, 2L)]
            long? maxDocuments)
        {
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                MaxDocuments = maxDocuments
            };

            var result = subject.CreateCommand(null);

            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "max", () => maxDocuments.Value, maxDocuments != null }
            };
            result.Should().Be(expectedResult);
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:18,代码来源:CreateCollectionOperationTests.cs

示例13: CreateCommand_should_return_expected_result_when_IndexOptionDefaults_is_set

        public void CreateCommand_should_return_expected_result_when_IndexOptionDefaults_is_set(
            [Values(null, "{ x : 1 }", "{ x : 2 }")]
            string indexOptionDefaultsString)
        {
            var indexOptionDefaults = indexOptionDefaultsString == null ? null : BsonDocument.Parse(indexOptionDefaultsString);
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                IndexOptionDefaults = indexOptionDefaults
            };

            var result = subject.CreateCommand(null);

            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "indexOptionDefaults", () => indexOptionDefaults, indexOptionDefaults != null }
            };
            result.Should().Be(expectedResult);
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:19,代码来源:CreateCollectionOperationTests.cs

示例14: CreateCommand_should_throw_when_Collation_is_set_and_not_supported

        public void CreateCommand_should_throw_when_Collation_is_set_and_not_supported()
        {
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                Collation = new Collation("en_US")
            };

            var exception = Record.Exception(() => subject.CreateCommand(Feature.Collation.LastNotSupportedVersion));

            exception.Should().BeOfType<NotSupportedException>();
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:11,代码来源:CreateCollectionOperationTests.cs

示例15: CreateCommand_should_return_expected_result_when_Collation_is_set

        public void CreateCommand_should_return_expected_result_when_Collation_is_set(
            [Values(null, "en_US", "fr_CA")]
            string locale)
        {
            var collation = locale == null ? null : new Collation(locale);
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                Collation = collation
            };

            var result = subject.CreateCommand(Feature.Collation.FirstSupportedVersion);

            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "collation", () => collation.ToBsonDocument(), collation != null }
            };
            result.Should().Be(expectedResult);
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:19,代码来源:CreateCollectionOperationTests.cs


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