This file contains hidden or 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
| var syncService: SyncService! | |
| func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
| syncService = SyncService(modelTypes: [User.self]) | |
| return true | |
| } |
This file contains hidden or 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
| syncService = SyncService(modelTypes: [User.self]) |
This file contains hidden or 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
| typealias Syncable = Object & Uploadable | |
| struct Update { | |
| let insertions: [Syncable] | |
| let modifications: [Syncable] | |
| let deletedIds: [String] | |
| let type: Syncable.Type | |
| } | |
| extension Uploadable where Self: Object { |
This file contains hidden or 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
| extension Uploadable where Self: Object { | |
| func getId() -> String { | |
| guard let primaryKey = type(of: self).primaryKey() else { | |
| fatalError("Object can't be managed without a primary key") | |
| } | |
| guard let id = self.value(forKey: primaryKey) else { | |
| fatalError("Objects primary key isn't set") | |
| } |
This file contains hidden or 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
| class User: Object, Uploadable { | |
| @objc dynamic var id: Int = 0 | |
| @objc dynamic var username: String = "" | |
| @objc dynamic var updatedDate: Date = Date() | |
| override static func primaryKey() -> String? { | |
| return "id" | |
| } | |
| var resourceURL: URL { |
This file contains hidden or 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
| protocol Uploadable: Decodable { | |
| var resourceURL: URL { get } | |
| } |
This file contains hidden or 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
| class User: Object { | |
| @objc dynamic var id: Int = 0 | |
| @objc dynamic var username: String = "" | |
| @objc dynamic var updatedDate: Date = Date() | |
| override static func primaryKey() -> String? { | |
| return "id" | |
| } | |
| } |
This file contains hidden or 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
| fun testTeamIsAwesome() { | |
| val quickBirdTeamMembers = fetchTeamMembers() | |
| val awesomeTeamMembers = quickBirdTeamMembers.filter { teamMember -> | |
| teamMember.isPassionate && | |
| teamMember.isFriendly && | |
| teamMember.isConstantlyImproving | |
| } | |
| assertEquals(quickBirdTeamMembers.size, awesomeTeamMembers.size) |
This file contains hidden or 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
| func test_TeamIsAwesome() { | |
| let quickBirdTeamMembers = fetchTeamMembers() | |
| let awesomeTeamMembers = quickBirdTeamMembers.filter { teamMember in | |
| teamMember.isPassionate && | |
| teamMember.isFriendly && | |
| teamMember.isConstantlyImproving | |
| } | |
| XCTAssertEqual(quickBirdTeamMembers.count, awesomeTeamMembers.count) |
This file contains hidden or 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
| @Test | |
| public void testAddNote() { | |
| // press “add note” button | |
| onView(withId(R.id.addNote)).perform(click()); | |
| // type “Espresso rules” as the note content | |
| onView(withId(R.id.noteContent)).perform(typeText("Espresso rules")); | |
| // press “ok/save” button | |
| onView(withId(R.id.ok)).perform(click()); | |
| // check if note-list contains note with the text “Espresso rules" | |
| onView(withText("Espresso rules")).check(matches(isDisplayed())); |