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
| func test_receiveImage_onButtonClick_version2() { | |
| let testScheduler = TestScheduler(initialClock: 0) | |
| } |
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
| func test_receiveImage_onButtonClick() { | |
| var resultImage: UIImage! | |
| subject.image.drive(onNext: { image in | |
| resultImage = image | |
| }).disposed(by: rx_disposeBag) | |
| buttonTap.onNext(()) | |
| XCTAssertEqual(resultImage, imageHavingMock.expectedImage) | |
| } |
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
| buttonTap.onNext(()) | |
| XCTAssertEqual(resultImage, imageHavingMock.expectedImage) |
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
| var resultImage: UIImage! | |
| subject.image.drive(onNext: { image in | |
| resultImage = image | |
| }).disposed(by: rx_disposeBag) |
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 buttonTap = PublishSubject<Void>() | |
| buttonTap.bindTo(subject.chooseImageButtonPressed) | |
| .disposed(by: rx_disposeBag) |
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
| func test_receiveImage_onButtonClick() { | |
| } |
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
| final class ViewModelTests: XCTestCase { | |
| private var subject: AvatarViewModel! | |
| var imageHavingMock: ImageHavingStub! | |
| override func setUp() { | |
| super.setUp() | |
| rx_disposeBag = DisposeBag() | |
| imageHavingMock = ImageHavingStub() | |
| subject = AvatarViewModel(imageReceiver: imageHavingMock) | |
| } |
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
| final class ImageHavingStub: ImageHaving { | |
| var expectedImage = UIImage() | |
| var givenError: Error? = nil | |
| var image: Observable<UIImage> { | |
| if let error = givenError { | |
| return .error(error) | |
| } | |
| return .just(expectedImage) | |
| } |
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
| private var selectedOption: Observable<ImageSource> { | |
| return Observable.create { [weak self] observer in | |
| guard let `self` = self else { | |
| observer.onCompleted() | |
| return Disposables.create() | |
| } | |
| let actionSheet = self.prepareActionSheet(with: observer) | |
| self.presenter?.present(actionSheet) | |
| return Disposables.create { |
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
| // | |
| // Created by Adam Borek on 17.06.2016. | |
| // | |
| import Foundation | |
| import RxSwift | |
| import RxCocoa | |
| class PostsListViewModel { | |
| typealias Index = Int |