//
//  BCRocksTests.m
//  BCRocks
//
//  Created by Iska on 15/11/14.
//  Copyright (c) 2014 BrainCookie. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "RocksDB.h"

@interface BCRocksTests : XCTestCase

@end

@implementation BCRocksTests

- (void)setUp
{
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
}

- (void)tearDown
{
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
}

- (void)testCompile
{
	RocksDB *rocks = [RocksDB new];

    XCTAssert(YES, @"Pass");
}

@end

//
//  BCRocksTests.m
//  BCRocks
//
//  Created by Iska on 15/11/14.
//  Copyright (c) 2014 BrainCookie. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "BCRocks.h"

@interface BCRocksTests : XCTestCase
{
	RocksDB *_rocks;
}
@end

@implementation BCRocksTests

- (void)setUp
{
	[super setUp];

	NSString * path = [[NSBundle bundleForClass:[self class]] resourcePath];
	path = [path stringByAppendingPathComponent:@"BCRocks"];
	_rocks = [[RocksDB alloc] initWithPath:path andOptions:^(RocksDBOptions *options) {
		options.createIfMissing = YES;
	}];
}

- (void)tearDown
{
	[_rocks close];

	NSString * path = [[NSBundle bundleForClass:[self class]] resourcePath];
	path = [path stringByAppendingPathComponent:@"BCRocks"];

	NSError *error = nil;
	[[NSFileManager defaultManager] removeItemAtPath:path error:&error];
	if (error) {
		NSLog(@"Error test teardown: %@", [error debugDescription]);
	}
	[super tearDown];
}

- (void)testDB_Init
{
	NSString *key = @"key";
	NSString *value = @"value";

	BOOL ok = [_rocks setData:[value dataUsingEncoding:NSUTF8StringEncoding] forKey:[key dataUsingEncoding:NSUTF8StringEncoding]];
    XCTAssert(ok, @"Put Data");

	NSData *data = [_rocks dataForKey:[key dataUsingEncoding:NSUTF8StringEncoding]];
	XCTAssertNotNil(data);

	NSString *roundtrip = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
	XCTAssertEqualObjects(roundtrip, value);
}

@end

Add first test case for put/get data
Add first test case for put/get data
