本文整理汇总了C#中CreateCollectionOperation类的典型用法代码示例。如果您正苦于以下问题:C# CreateCollectionOperation类的具体用法?C# CreateCollectionOperation怎么用?C# CreateCollectionOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CreateCollectionOperation类属于命名空间,在下文中一共展示了CreateCollectionOperation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Capped_should_work
public void Capped_should_work()
{
var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings);
subject.Capped.Should().NotHaveValue();
subject.Capped = true;
subject.Capped.Should().BeTrue();
}
示例2: Capped_get_and_set_should_work
public void Capped_get_and_set_should_work(
[Values(null, false, true)]
bool? value)
{
var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings);
subject.Capped = value;
var result = subject.Capped;
result.Should().Be(value);
}
示例3: 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 CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings);
var value = locale == null ? null : new Collation(locale);
subject.Collation = value;
var result = subject.Collation;
result.Should().BeSameAs(value);
}
示例4: constructor_should_initialize_subject
public void constructor_should_initialize_subject()
{
var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings);
subject.AutoIndexId.Should().NotHaveValue();
subject.Capped.Should().NotHaveValue();
subject.CollectionNamespace.Should().BeSameAs(_collectionNamespace);
subject.MaxDocuments.Should().NotHaveValue();
subject.MaxSize.Should().NotHaveValue();
subject.MessageEncoderSettings.Should().BeSameAs(_messageEncoderSettings);
subject.UsePowerOf2Sizes.Should().NotHaveValue();
}
示例5: Execute_should_create_collection_when_Validator_is_set
public void Execute_should_create_collection_when_Validator_is_set(
[Values(false, true)] bool async)
{
var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
{
ValidationAction = DocumentValidationAction.Error,
ValidationLevel = DocumentValidationLevel.Strict,
Validator = new BsonDocument("_id", new BsonDocument("$exists", true))
};
using (var binding = CoreTestConfiguration.GetReadWriteBinding())
{
var result = ExecuteOperation(subject, binding, async);
result["ok"].ToBoolean().Should().BeTrue();
var collectionInfo = GetCollectionInfo(binding, _collectionNamespace.CollectionName);
Assert.That(collectionInfo["options"]["validator"], Is.EqualTo(new BsonDocument("_id", new BsonDocument("$exists", true))));
Assert.That(collectionInfo["options"]["validationAction"].AsString, Is.EqualTo("error"));
Assert.That(collectionInfo["options"]["validationLevel"].AsString, Is.EqualTo("strict"));
}
}
示例6: Execute_should_create_collection_when_UsePowerOf2Sizes_is_set
public void Execute_should_create_collection_when_UsePowerOf2Sizes_is_set(
[Values(false, true)]
bool usePowerOf2Sizes,
[Values(false, true)]
bool async)
{
var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
{
UsePowerOf2Sizes = usePowerOf2Sizes
};
using (var binding = CoreTestConfiguration.GetReadWriteBinding())
{
var result = ExecuteOperation(subject, binding, async);
result["ok"].ToBoolean().Should().BeTrue();
var stats = GetCollectionStats(binding, async);
stats["ns"].ToString().Should().Be(_collectionNamespace.FullName);
stats["userFlags"].ToInt32().Should().Be(usePowerOf2Sizes ? 1 : 0);
}
}
示例7: ExecuteOperation
private BsonDocument ExecuteOperation(CreateCollectionOperation subject, IWriteBinding binding, bool async)
{
if (async)
{
return subject.ExecuteAsync(binding, CancellationToken.None).GetAwaiter().GetResult();
}
else
{
return subject.Execute(binding, CancellationToken.None);
}
}
示例8: MaxSize_set_should_throw_when_value_is_invalid
public void MaxSize_set_should_throw_when_value_is_invalid(
[Values(-1, 0)]
long maxSize)
{
var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings);
Action action = () => { subject.MaxSize = maxSize; };
action.ShouldThrow<ArgumentOutOfRangeException>().And.ParamName.Should().Equals("value");
}
示例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_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);
}
示例11: Execute_should_create_collection
public void Execute_should_create_collection(
[Values(false, true)]
bool async)
{
var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings);
using (var binding = CoreTestConfiguration.GetReadWriteBinding())
{
var result = ExecuteOperation(subject, binding, async);
result["ok"].ToBoolean().Should().BeTrue();
var stats = GetCollectionStats(binding, async);
stats["ns"].ToString().Should().Be(_collectionNamespace.FullName);
}
}
示例12: 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);
}
示例13: 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);
}
示例14: 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);
}
示例15: 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);
}