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 | |
class LaunchResponseTests: XCTestCase { | |
override func setUpWithError() throws { | |
// Put setup code here. This method is called before the invocation of each test method in the class. | |
} | |
override func tearDownWithError() throws { | |
// Put teardown code here. This method is called after 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 // 1 | |
class LaunchResponseTests: XCTestCase, DecodableTestCase { // 2 | |
var sut: LaunchResponse! // 3 | |
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() // 4 |
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 | |
import XCTest | |
protocol DecodableTestCase: class { | |
associatedtype T: Decodable | |
var sut: T! { get set } | |
} | |
extension DecodableTestCase { | |
func givenSUTFromJSON(fileName: String = "\(T.self)") throws { | |
let decoder = JSONDecoder() |
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 | |
import XCTest | |
extension Data { | |
public static func fromJSON(fileName: String) throws -> Data { | |
let bundle = Bundle(for: TestBundleClass.self) | |
let url = try XCTUnwrap(bundle.url(forResource: fileName, withExtension: "json")) | |
return try Data(contentsOf: url) | |
} | |
} |
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() |
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
@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 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
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 | |
import RxSwift | |
class LaunchListViewModelTests: XCTestCase { | |
var sut: LaunchListViewModel! | |
var mockAPIService: MockAPIService! | |
// 1 | |
var mockViewController: MockLaunchListViewController! |