/******************************************************************************
   BDBAbstractTEST
   BDB
 
  @copyright 2004, 2005, 2006 Free Software Foundation, Inc.
  
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA


  -------------------------------------------------------------------------
  Modification history

  27.12.2005 ola     initial version
  23.08.2006 ola     license changed
  -------------------------------------------------------------------------
******************************************************************************/

#include "BDBAbstractBTreeTEST.h"


@implementation BDBAbstractBTreeTEST

+ deleteDatabase {
  NSFileManager *fileManager = [NSFileManager defaultManager];
  [fileManager removeFileAtPath: __BDBBTreeTestDatabaseName handler: nil];
  
  return self;
}


- testSpecificConfigurables: (BDBDatabaseConfig *) config {
  [ config setAllowCreate: YES ];
  [ config setAllocSortedDuplicates: YES ];
  [ config setDatabaseType: BDB_BTREE ];
  return self;
}


- setup {
  BDBDatabaseConfig *config;
  
  config = [ [ BDBDatabaseConfig alloc ] init ];
  [self testSpecificConfigurables: config ];
  
  NSLog( @"Trying to create a database..." );

  database = [ BDBDatabase 
  initWithFilename: __BDBBTreeTestDatabaseName 
  databaseName: @"first"
  databaseConfig: config ];
  
  ECAssertTrue( database != nil, @"Database instance could not be created!" );
  NSLog( @"Database opened!" );
  
  return self;
}


- (void) cleanup { 
  if( nil != database ) {
    [ database close ];
	[ database release ];
	database = nil;
	
	NSLog( @"Database closed" );
  }
}
@end
