Exemplo n.º 1
0
 public CollectionDescriptor(
     Type type,
     bool capped       = false,
     long maxDocuments = 0,
     long maxSize      = 0,
     DocumentValidationAction validationAction = DocumentValidationAction.Error,
     DocumentValidationLevel validationLevel   = DocumentValidationLevel.Off)
 {
     this.Type             = type;
     this.Capped           = capped;
     this.MaxDocuments     = maxDocuments;
     this.MaxSize          = maxSize;
     this.ValidationAction = validationAction;
     this.ValidationLevel  = validationLevel;
 }
        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);
        }
 /// <summary>
 /// Sets the validation level.
 /// </summary>
 /// <param name="validationLevel">The validation level.</param>
 /// <returns>The builder (so method calls can be chained).</returns>
 public CollectionOptionsBuilder SetValidationLevel(DocumentValidationLevel validationLevel)
 {
     _document["validationLevel"] = validationLevel.ToString().ToLowerInvariant();
     return(this);
 }
 /// <summary>
 /// Sets the validation level.
 /// </summary>
 /// <param name="validationLevel">The validation level.</param>
 /// <returns>The builder (so method calls can be chained).</returns>
 public static CollectionOptionsBuilder SetValidationLevel(DocumentValidationLevel validationLevel)
 {
     return(new CollectionOptionsBuilder().SetValidationLevel(validationLevel));
 }