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
import XCTest | |
import Hamcrest | |
import FutureKit | |
@testable import MyExampleApp | |
class ExampleViewControllerTest: XCTestCase { | |
var fakeExampleService: FakeExampleService! | |
override func setUp() { |
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
import Foundation | |
class AppEnvironment: NSObject { | |
static let sharedEnvironment = AppEnvironment() | |
let exampleService: ExampleService | |
override init() { | |
self.exampleService = ExampleService() |
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
import UIKit | |
import FutureKit | |
class ListOfFruitsViewController: UITableViewController { | |
... | |
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { | |
if (segue.identifier == "goToFruitDetailsSegue") { | |
if let |
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
import UIKit | |
class FruitDetailViewController: UIViewController { | |
var fruit: FruitAppFruit? | |
... | |
} | |
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
import XCTest | |
import Hamcrest | |
import FutureKit | |
@testable import FruitApp | |
class ListOfFruitsViewControllerTest: XCTestCase { | |
... | |
func testShowsFruitDetailsWhenFruitRowIsTapped() { |
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
import FutureKit | |
import SwiftyJSON | |
class VillainService { | |
let url: String | |
var session: URLSession = URLSession.shared | |
func getVillainList() -> Future<VillainResponse> { | |
let promise = Promise<VillainResponse>() | |
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
import XCTest | |
import Nimble | |
import SwiftyJSON | |
import FutureKit | |
@testable import VillainApp | |
class VillainServiceTest: XCTestCase { | |
var service: VillainService! |
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 MockSession: URLSession { | |
var completionHandler: ((Data?, URLResponse?, Error?) -> Void)? | |
var request: URLRequest? | |
let stubbedDataTask: MockURLSessionDataTask = MockURLSessionDataTask() | |
override func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask { | |
self.completionHandler = completionHandler | |
self.request = request | |
return stubbedDataTask |
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
import FutureKit | |
import UIKit | |
class VillainsMasterViewController: UIViewController { | |
let villainService: VillainService? | |
... | |
func viewDidLoad() { | |
villainService?.getVillainList() |
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
import FutureKit | |
import XCTest | |
import Nimble | |
@testable import VillainApp | |
class VillainsMasterViewControllerTest: XCTestCase { | |
var viewController: VillainsMasterViewController! | |
var mockVillainService: MockVillainService! |