本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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>();
}
示例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);
}