Skip to content

Instantly share code, notes, and snippets.

View ykpoh's full-sized avatar

Yk Poh ykpoh

  • Melaka, Malaysia
View GitHub Profile
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)
}
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)
}
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()
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)")
}
}
import XCTest
@testable import SpaceXLaunch
import Alamofire
import RxSwift
class LaunchListViewModelTests: XCTestCase {
var sut: LaunchListViewModel!
var mockAPIService: MockAPIService!
// 1
var mockViewController: MockLaunchListViewController!
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.
import XCTest
@testable import SpaceXLaunch
import Alamofire
class APIServiceTests: XCTestCase {
// 1
var mockSessionManager: MockSessionManager!
var mockDataRequest: MockDataRequest!
var mockBaseUrlString: String!
var sut: APIService!
@testable import SpaceXLaunch
import Alamofire
enum MockAPIServiceError: Error {
case permissionDenied
}
class MockAPIService: APIServiceProtocol { // 1
enum Status {
case success
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>(
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()