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 UserDefaults { | |
| static var testDefaults: UserDefaults = UserDefaults(suiteName: "testDefaults")! | |
| static func dropTestDefaults() { | |
| UserDefaults().removePersistentDomain(forName: "testDefaults") | |
| } | |
| } |
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 testUserDefaultsInsert() { | |
| UserDefaults.testDefaults.set(true, forKey: "somePreference") | |
| XCTAssertTrue(UserDefaults.testDefaults.bool(forKey: "somePreference")) | |
| } | |
| override func tearDown() { | |
| super.tearDown() | |
| UserDefaults.dropTestDefaults() | |
| } |
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 AdvertismentClient { | |
| func getAttributionDetails(_ completionHandler: @escaping ([AnyHashable : Any]?, _ error: Error?) -> Void) | |
| } |
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 ADClient: AdvertismentClient { | |
| func getAttributionDetails(_ completionHandler: @escaping ([AnyHashable : Any]?, _ error: Error?) -> Void) { | |
| ADClient.shared().requestAttributionDetails(completionHandler) | |
| } | |
| } | |
| class MockAdClient: AdvertismentClient { | |
| func getAttributionDetails(_ completionHandler: @escaping ([AnyHashable : Any]?, _ error: Error?) -> Void) { | |
| completionHandler(MockResponseManager.getSearchAdAttributions(), nil) | |
| } |
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
| adClient.getAttributionDetails { (attribution, _) in | |
| //Code for using fetched attribution dict | |
| } |
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
| let stubbedJSON = [ | |
| "userId": 1, | |
| "id": 1, | |
| "title": "Mocked Task", | |
| "completed": false | |
| ] as [String : Any] | |
| stub(condition: pathEndsWith("todos")) { _ in | |
| return OHHTTPStubsResponse( | |
| jsonObject: stubbedJSON, |
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
| stub(condition: pathEndsWith("todos")) { _ in | |
| let stubPath = OHPathForFile("myResponse.json", type(of: self)) | |
| return fixture(filePath: stubPath!, headers: ["Content-Type":"application/json"]) | |
| } |
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
| stub(condition: pathEndsWith("todos")) { _ in | |
| let error = NSError( | |
| domain: "Server Error", | |
| code: 500, | |
| userInfo: [:] | |
| ) | |
| return OHHTTPStubsResponse(error: error) | |
| } |
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
| struct ColorPalette { | |
| var primaryColor: UIColor | |
| var primaryShade: UIColor | |
| var secondaryColor: UIColor | |
| var secondaryShade: UIColor | |
| var accentColor: UIColor | |
| } | |
| struct TextStyle { | |
| var headerTextFont: UIFont |
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
| struct DefaultTheme: Theme { | |
| var colorPalette: ColorPalette = ColorPalette(...) //Custom Initialization based on your app default colors | |
| var textStyle: TextStyle = TextStyle(headerTextFont: UIFont.boldSystemFont(ofSize: 22), detailTextFont: UIFont.boldSystemFont(ofSize: 14)) | |
| } | |
| struct NightTheme: Theme { | |
| var colorPalette: ColorPalette = ColorPalette(...) //Custom Initialization based on your app night theme colors | |
| var textStyle: TextStyle = TextStyle(headerTextFont: UIFont.boldSystemFont(ofSize: 22), detailTextFont: UIFont.boldSystemFont(ofSize: 14)) | |
| } |