Esempio n. 1
0
        public void DropDatabase(
            string name,
            CancellationToken cancellationToken = default)
        {
            if (TryGetSession(out IClientSessionHandle? session))
            {
                _client.DropDatabase(session, name, cancellationToken);
                return;
            }

            _client.DropDatabase(name, cancellationToken);
        }
Esempio n. 2
0
 public void DropDB(string dbName)
 {
     if (mClient != null)
     {
         mClient.DropDatabase(dbName);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Drops a given database from the server.
 /// </summary>
 /// <param name="client">The Mongo connection client.</param>
 /// <param name="databaseName">The name of the database to drop.</param>
 public static void DropDatabase(IMongoClient client, string databaseName)
 {
     Log.DebugFormat("Dropping database '{0}'..", databaseName);
     client.DropDatabase(databaseName);
     if (DatabaseExists(client, databaseName))
     {
         throw new MongoException(String.Format("Failed to drop database '{0}'!  Issued drop database command but data still exists.", databaseName));
     }
 }
Esempio n. 4
0
 public DbEngine()
 {
     _client = new MongoClient();
     _client.DropDatabase(DB_NAME);
     _database = _client.GetDatabase(DB_NAME);
     tankMeasuresCollection   = _database.GetCollection <BsonDocument>(TANK_MEASURES_NAME);
     nozzleMeasuresCollection = _database.GetCollection <BsonDocument>(NOZZLE_MEASURES_NAME);
     refuelsCollection        = _database.GetCollection <BsonDocument>(REFUELS_NAME);
 }
        public bool DeleteDatabase(string dbName)
        {
            try
            {
                _client.DropDatabase(dbName);
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 6
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                client.DropDatabase(databaseName);
            }
            disposed = true;
        }
Esempio n. 7
0
        public static bool DeleteDatabase()
        {
            try
            {
                client.DropDatabase("BsonDemo");
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 8
0
 public RepositoryTests()
 {
     _runner = MongoDbRunner.StartForDebugging();
     _client = new MongoClient(_runner.ConnectionString);
     _client.DropDatabase(_dbname);
     _database = _client.GetDatabase(_dbname);
     _repo     = new Repository <Person>(_database);
     _persons  = new Faker <Person>()
                 .CustomInstantiator(f =>
     {
         return(new Person
         {
             Name = f.Person.FullName,
             Email = f.Person.Email,
             Points = f.Random.Int(0, 10000)
         });
     });
 }
Esempio n. 9
0
        public static void EnsureReplicationSetReady(this IMongoClient mongoClient)
        {
            var delay    = InitialDelay;
            var database = mongoClient.GetDatabase("__dummy-db");

            try
            {
                while (true)
                {
                    try
                    {
                        _ = database.GetCollection <DummyEntry>("__dummy");
                        database.DropCollection("__dummy");

                        var session = mongoClient.StartSession();

                        try
                        {
                            session.StartTransaction();
                            session.AbortTransaction();
                        }
                        finally
                        {
                            session.Dispose();
                        }

                        break;
                    }
                    catch (NotSupportedException)
                    {
                    }

                    Thread.Sleep(delay);
                    delay = Min(Double(delay), MaxDelay);
                }
            }
            finally
            {
                mongoClient.DropDatabase("__dummy-db");
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Permanently deletes (drops) the database with all records
        /// in it without the possibility to recover them later.
        ///
        /// This method should only be used to free storage. For
        /// all other purposes, methods that preserve history should
        /// be used.
        ///
        /// ATTENTION - THIS METHOD WILL DELETE ALL DATA WITHOUT
        /// THE POSSIBILITY OF RECOVERY. USE WITH CAUTION.
        /// </summary>
        public override void DeleteDb()
        {
            if (ReadOnly != null && ReadOnly.Value)
            {
                throw new Exception(
                          $"Attempting to drop (delete) database for the data source {DataSourceName} where ReadOnly flag is set.");
            }

            // Do not delete (drop) the database this class did not create
            if (client_ != null && Db != null)
            {
                // As an extra safety measure, this method will delete
                // the database only if the first token of its name is
                // TEST or DEV.
                //
                // Use other tokens such as UAT or PROD to protect the
                // database from accidental deletion
                if (envType_ == EnvType.Dev ||
                    envType_ == EnvType.User ||
                    envType_ == EnvType.Test)
                {
                    // The name is the database key in the standard
                    // semicolon delimited format. However this method
                    // performs additional validation for restricted
                    // characters and database name length.
                    client_.DropDatabase(dbName_);
                }
                else
                {
                    throw new Exception(
                              $"As an extra safety measure, database {dbName_} cannot be " +
                              $"dropped because this operation is not permitted for database " +
                              $"environment type {envType_.ToString().ToUpper()}.");
                }
            }
        }
Esempio n. 11
0
 public void GlobalCleanup()
 {
     _client.DropDatabase(_databaseName);
 }
 public void Dispose()
 {
     _mongoClient.DropDatabase(_databaseName);
 }
Esempio n. 13
0
 public void RunCleanup()
 {
     mongoClient.DropDatabase(mongoDatabase.DatabaseNamespace.DatabaseName);
 }
 public void Initialize()
 {
     _client.DropDatabase(DbName);
 }
        /// <summary>
        /// Drop the existing database
        /// </summary>
        /// <param name="name"></param>

        protected void DropDatabase(string name)
        {
            _client.DropDatabase(name);
        }
 public void DropDatabase(string databaseName)
 {
     _client.DropDatabase(databaseName);
 }
Esempio n. 17
0
        public void RunCleanup()
        {
            mongoClient.DropDatabase(mongoDatabase.DatabaseNamespace.DatabaseName);

            eventConsumerActor.Dispose();
        }
 public void Cleanup()
 {
     mongoClient.DropDatabase("EventStoreTest");
 }
Esempio n. 19
0
 public void Dispose()
 {
     client.DropDatabase(testDBName);
 }
Esempio n. 20
0
 public void Dispose()
 {
     mongoClient.DropDatabase("EventStoreTest");
 }
Esempio n. 21
0
 public void DropDatabase()
 {
     _mongoClient.DropDatabase(_mongoDbConfigurations.Database);
 }
 public void FixtureTeardown()
 {
     _client.DropDatabase("workflows");
 }
Esempio n. 23
0
 /// <inheritdoc />
 public virtual void DropDatabase()
 => _mongoClient.DropDatabase(new MongoDbModelAnnotations(_model).Database);
Esempio n. 24
0
 private void Disconnect()
 {
     Client?.DropDatabase(ConnectionSettings.MongoDBName);
 }
Esempio n. 25
0
 public void DropDatabase(string name, CancellationToken cancellationToken = default(CancellationToken))
 {
     wrapped.DropDatabase(name, cancellationToken);
 }
 public void TearDown()
 {
     _client.DropDatabase(DatabaseName);
 }
Esempio n. 27
0
        public void RunCleanup()
        {
            mongoClient.DropDatabase(mongoDatabase.DatabaseNamespace.DatabaseName);

            eventReceiver.Dispose();
        }
 public void SetUp()
 {
     _client.DropDatabase(database);
 }
 public void AfterTest()
 {
     Database.DropCollection("users");
     Database.DropCollection("roles");
     Client.DropDatabase("identity-testing");
 }
Esempio n. 30
0
 public void Dispose()
 {
     mongoClient.DropDatabase("GridFSTest");
 }