 import UIKit
 import XCTest
 import SwiftAddressBook
+import AddressBook
 
 //**** Run the example project first, to accept address book access ****
 class SwiftAddressBookTests: XCTestCase {

        swiftAddressBook?.requestAccessWithCompletion({ (success, error) -> Void in
            XCTAssertTrue(success, self.accessError)
            if success {
                var person: SwiftAddressBookPerson? = SwiftAddressBookPerson.create()
                var timeStamp = self.getDateTimestamp()
                if let person = person {
                    person.firstName = "Test" + timeStamp;
                    swiftAddressBook?.addRecord(person)
                    swiftAddressBook?.save()
                }
                
                person = swiftAddressBook?.allPeople?.filter({ p in p.firstName == "Test" + timeStamp }).first
                XCTAssertNotNil(person, "Couldn't find newly added person")
                
                if person != nil {
                    if let person = person {
                        //TODO: test ALL fields
                        person.firstName = "Darth" + timeStamp
                        person.lastName = "Vader" + timeStamp

                    swiftAddressBook?.save()
                }
                
                optionalPerson = swiftAddressBook?.allPeople?.filter({ p in p.firstName == "Darth" + timeStamp }).first
                XCTAssertNotNil(optionalPerson, "Couldn't find newly added person")
                
                if let person = optionalPerson {
                    XCTAssert(person.firstName == "Darth" + timeStamp, "Failed to save first name")
                    XCTAssert(person.lastName == "Vader" + timeStamp, "Failed to save last name")
                    XCTAssert(person.nickname == "Anakin" + timeStamp, "Failed to save nickname")
                    
                    swiftAddressBook?.removeRecord(person)
                    swiftAddressBook?.save()
