private static WriteModel <T> ConvertInsertRequest(InsertRequest request)
        {
            object document;
            var    wrapper = request.Document as BsonDocumentWrapper;

            if (wrapper != null)
            {
                document = wrapper.Wrapped;
            }
            else
            {
                document = request.Document;
            }

            return(new InsertOneModel <T>((T)document));
        }
        public async Task InsertOneAsync_should_execute_the_BulkMixedOperation()
        {
            var document        = BsonDocument.Parse("{_id:1,a:1}");
            var expectedRequest = new InsertRequest(document)
            {
                CorrelationId = 0
            };
            var operationResult = new BulkWriteOperationResult.Unacknowledged(1, new[] { expectedRequest });

            _operationExecutor.EnqueueResult <BulkWriteOperationResult>(operationResult);

            await _subject.InsertOneAsync(
                document,
                CancellationToken.None);

            var call = _operationExecutor.GetWriteCall <BulkWriteOperationResult>();

            VerifySingleWrite(expectedRequest, call);
        }
        private static WriteModel <TDocument> ConvertInsertRequest(InsertRequest request)
        {
            var document = (TDocument)Unwrap(request.Document);

            return(new InsertOneModel <TDocument>(document));
        }
 public void ShowOffDirectBulkWriteToSpecifyOtherArguments()
 {
     var args = new BulkWriteArgs
     {
         CheckElementNames = false
     };
     var insert = new InsertRequest(typeof (BsonDocument), new BsonDocument {{"$invalid", 1}});
     try
     {
         _Collection.BulkWrite(args, insert);
     }
     catch (BulkWriteException exception)
     {
         WriteErrors(exception);
         throw;
     }
 }