Created
June 1, 2019 18:17
-
-
Save jemai/1e83bd2a7a04cbcbd0cec95f26bb88a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XCTest | |
@testable import RealmDB_Manager | |
@testable import RealmSwift | |
@testable import Realm | |
class RealmDB_ManagerTests: XCTestCase { | |
struct service: LocalFileReader { } | |
struct db: Persister { } | |
var things = [Thing]() | |
override func setUp() { | |
service.loadLocalData(to: Mapper.self, fileName: "data", fileType: .json) | |
things = Array(db.select(type: Thing.self)) | |
} | |
override func tearDown() { | |
db.resetDB() | |
} | |
func testQuery() { | |
assert(things.count == 3, "the count should be 3") | |
} | |
func testFilter() { | |
let queryResult = db.select(type: Thing.self, filter: NSPredicate(format: "id == %d", 0)) | |
assert(queryResult.count == 1, "the count should be 1 since we are quering by id, and the id is activated in the object") | |
let aThing = queryResult.first! | |
assert(aThing.id == 0, "id should be the same as the filtered one") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment