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 TrackSummary { | |
| let trackID: Int | |
| let name: String | |
| let startTime: Double | |
| let distance: Float | |
| } |
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 TrackRepository {} | |
| class TrackRepositoryImpl {} | |
| extension TrackRepositoryImpl: TrackRepository {} |
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 TrackNameUpdateInteractor { | |
| let repository: TrackRepository | |
| init(repository: TrackRepository) { | |
| self.repository = repository | |
| } | |
| } | |
| extension TrackNameUpdateInteractor: Interactor { | |
| func execute() { |
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 TrackSummaryInteractorOutput { | |
| func update(track: TrackSummary) | |
| } | |
| class TrackSummaryInteractor { | |
| let repository: TrackRepository | |
| let output: TrackSummaryInteractorOutput | |
| init(repository: TrackRepository, output: TrackSummaryInteractorOutput) { | |
| self.repository = repository |
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 Interactor { | |
| func execute() | |
| } |
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 interactor = TrackSummaryInteractor( | |
| output: TrackSummaryPresenter( | |
| output: TrackSummaryViewController() | |
| ) | |
| ) | |
| interactor.execute() |
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 TrackSummaryViewController: UIViewController { | |
| @IBOutlet private(set) var nameLabel: UILabel! | |
| @IBOutlet private(set) var dateLabel: UILabel! | |
| @IBOutlet private(set) var distanceLabel: UILabel! | |
| } | |
| extension TrackSummaryViewController: TrackSummaryPresenterOutput { | |
| func setName(name: String) { |
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 | |
| import XCTest | |
| class TrackSummaryPresenterTests: XCTestCase { | |
| func testCallsOutputWithExpectedValues() { | |
| let outputSpy = TrackSummaryPresenterOutputSpy() | |
| let presenter = TrackSummaryPresenter(output: outputSpy) | |
| let track = TrackSummary(name: "Trip", startTime: 1449567617, distance: 200) | |
| presenter.update(track) |
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 | |
| protocol TrackSummaryPresenterOutput { | |
| func setName(name: String) | |
| func setDate(date: String) | |
| func setDistance(distance: String) | |
| } | |
| class TrackSummaryPresenter { | |
| let output: TrackSummaryPresenterOutput |
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 TrackSummaryInteractorOutput { | |
| func update(track: TrackSummary) | |
| } | |
| class TrackSummaryInteractor { | |
| let output: TrackSummaryInteractorOutput | |
| init(output: TrackSummaryInteractorOutput) { | |
| self.output = output | |
| } |