Ejemplo n.º 1
0
        // helper methods
        private void EnsureDatabaseExists(IWriteBinding binding)
        {
            var collectionNamespace = new CollectionNamespace(_databaseNamespace, "test");
            var requests            = new[] { new InsertRequest(new BsonDocument()) };
            var insertOperation     = new BulkInsertOperation(collectionNamespace, requests, _messageEncoderSettings);

            insertOperation.Execute(binding, CancellationToken.None);
        }
Ejemplo n.º 2
0
        // helper methods
        private void EnsureTestData()
        {
            if (_testDataHasBeenCreated)
            {
                return;
            }

            using (var binding = SuiteConfiguration.GetReadWriteBinding())
            {
                var dropCollectionOperation = new DropCollectionOperation(_collectionNamespace, _messageEncoderSettings);
                dropCollectionOperation.Execute(binding);

                var requests = Enumerable.Range(1, 5)
                               .Select(id => new BsonDocument("_id", id))
                               .Select(document => new InsertRequest(document));
                var insertOperation = new BulkInsertOperation(_collectionNamespace, requests, _messageEncoderSettings);
                insertOperation.Execute(binding);
            }

            _testDataHasBeenCreated = true;
        }