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
struct Provider: TimelineProvider { | |
func placeholder(in context: Context) -> SimpleEntry { | |
SimpleEntry(date: Date(), building: .barrack) | |
} | |
func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) { | |
let entry = SimpleEntry(date: Date(), building: .barrack) | |
completion(entry) | |
} |
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 KeychainAccess | |
class KeychainHelper { | |
let service = "QKLSKFNAE1.com.example.yungkien.com.shared" | |
let accessGroup = "group.com.example.yungkien.com.shared" | |
func save(_ key: String, _ value: String) throws { | |
let keychain = Keychain(service: service, accessGroup: accessGroup) | |
try keychain.set(value, key: key.rawValue) | |
} |
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 SpaceXLaunch | |
import RxCocoa | |
class LaunchListViewControllerTests: XCTestCase { | |
var sut: LaunchListViewController! | |
override func setUpWithError() throws { | |
// Put setup code here. This method is called before the invocation of each test method in the class. | |
try super.setUpWithError() |
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 Foundation | |
@testable import SpaceXLaunch | |
import XCTest | |
extension XCTest { | |
func givenLaunches(count: Int) -> [Launch] { | |
return (1 ... count).map { i in | |
return Launch(id: "id_\(i)", name: "name_\(i)", details: "details_\(i)", date_utc: Date(), upcoming: true, success: true, rocket: "rocket_\(i)") | |
} | |
} |
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 SpaceXLaunch | |
import Alamofire | |
import RxSwift | |
class LaunchListViewModelTests: XCTestCase { | |
var sut: LaunchListViewModel! | |
var mockAPIService: MockAPIService! | |
// 1 | |
var mockViewController: MockLaunchListViewController! |
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 SpaceXLaunch | |
class LaunchListTableViewCellViewModelTests: XCTestCase { | |
// 1 | |
var sut: LaunchListTableViewCellViewModel! | |
var cell: LaunchListTableViewCell! | |
override func setUpWithError() throws { | |
// Put setup code here. This method is called before the invocation of each test method in the class. |
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 SpaceXLaunch | |
import Alamofire | |
class APIServiceTests: XCTestCase { | |
// 1 | |
var mockSessionManager: MockSessionManager! | |
var mockDataRequest: MockDataRequest! | |
var mockBaseUrlString: String! | |
var sut: APIService! |
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
@testable import SpaceXLaunch | |
import Alamofire | |
enum MockAPIServiceError: Error { | |
case permissionDenied | |
} | |
class MockAPIService: APIServiceProtocol { // 1 | |
enum Status { | |
case success |
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 Foundation | |
@testable import SpaceXLaunch | |
import Alamofire // 1 | |
class MockDataRequest: DataRequestProtocol { // 2 | |
// 3 | |
static var statusCode: Int = 200 | |
static var data: Data? | |
var dataResponse = AFDataResponse<Any>( |
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 SpaceXLaunch | |
class LaunchTests: XCTestCase { | |
var sut: Launch! | |
override func setUpWithError() throws { | |
// Put setup code here. This method is called before the invocation of each test method in the class. | |
try super.setUpWithError() | |
try givenSUTFromJSON() |
NewerOlder