public void CreateFreshTestDatabase()
        {
            if (string.IsNullOrWhiteSpace(RavenDbSettings.TestDatabaseName))
            {
                throw new ArgumentNullException(nameof(RavenDbSettings.TestDatabaseName));
            }

            try
            {
                Store.Maintenance.ForDatabase(RavenDbSettings.TestDatabaseName).Send(new GetStatisticsOperation());
                //it didn't throw so it exists and we can delete it
                var deleteOperation = new DeleteDatabasesOperation(RavenDbSettings.TestDatabaseName, true);
                Store.Maintenance.Server.Send(deleteOperation);
            }
            catch (DatabaseDoesNotExistException)
            {
            }

            try
            {
                var createOperation = new CreateDatabaseOperation(new DatabaseRecord(RavenDbSettings.TestDatabaseName));
                Store.Maintenance.Server.Send(createOperation);
            }
            catch (ConcurrencyException)
            {
                // Something created the database already
            }
        }
Example #2
0
        public async Task DeleteDatabase(IDocumentStore documentStore, string databaseName)
        {
            var operation = new DeleteDatabasesOperation(databaseName, hardDelete: true);

            try
            {
                await documentStore.Maintenance.Server.SendAsync(operation);
            }
            catch (DatabaseDoesNotExistException)
            {
            }
        }
        public void DeleteTestDatabase()
        {
            var deleteOperation = new DeleteDatabasesOperation(RavenDbSettings.TestDatabaseName, true);

            Store.Maintenance.Server.Send(deleteOperation);
        }
Example #4
0
        public Task DeleteDatabase(IDocumentStore documentStore, string databaseName)
        {
            var operation = new DeleteDatabasesOperation(databaseName, hardDelete: true);

            return(documentStore.Maintenance.Server.SendAsync(operation));
        }