Skip to content

Instantly share code, notes, and snippets.

@jemai
Created June 1, 2019 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jemai/1e83bd2a7a04cbcbd0cec95f26bb88a3 to your computer and use it in GitHub Desktop.
Save jemai/1e83bd2a7a04cbcbd0cec95f26bb88a3 to your computer and use it in GitHub Desktop.
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