Created
June 3, 2018 18:43
-
-
Save pietrocaselani/9975d611e4290e8b42990950a4ce5343 to your computer and use it in GitHub Desktop.
Testes unitários no iOS sem medo de ser feliz
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 RxSwift | |
public enum MovieViewState: Hashable { | |
case loading | |
case error(error: Error) | |
case showingMovies(titles: [String]) | |
case empty | |
public var hashValue: Int { | |
switch self { | |
case .loading: | |
return "MovieViewState.loading".hashValue | |
case .error(let error): | |
return "MovieViewState.error".hashValue ^ error.localizedDescription.hashValue | |
case .showingMovies(let titles): | |
var hash = "MovieViewState.showingMovies".hashValue | |
titles.forEach { hash ^= $0.hashValue } | |
return hash | |
case .empty: | |
return "MovieViewState.empty".hashValue | |
} | |
} | |
public static func == (lhs: MovieViewState, rhs: MovieViewState) -> Bool { | |
return lhs.hashValue == rhs.hashValue | |
} | |
} | |
public protocol MoviesRepository { | |
func fetchMovies() -> Observable<[String]> | |
} | |
public protocol MoviesViewModel { | |
func viewDidLoad() | |
func observeViewState() -> Observable<MovieViewState> | |
} | |
public protocol MoviesView: class { | |
var viewModel: MoviesViewModel? { get set } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment