Skip to content

Instantly share code, notes, and snippets.

View TheAdamBorek's full-sized avatar

Adam Borek TheAdamBorek

View GitHub Profile
enum ScreenSizes {
static let threePointFiveInchesPhoneFrame = CGRect(x: 0, y: 0, width: 320, height: 480)
static let fourInchesPhoneFrame = CGRect(x: 0, y: 0, width: 320, height: 568)
static let fourPointSevenInchesPhoneFrame = CGRect(x: 0, y: 0, width: 375, height: 667)
static let iPadPortrait = CGRect(x: 0, y: 0, width: 768, height: 1024)
static let iPadLandscape = CGRect(x: 0, y: 0, width: 1024, height: 768)
}
import Foundation
import RxSwift
import RxSwiftExt
import RxCocoa
extension Variable {
func bidirectionalBind(with controlProperty: ControlProperty<Element>) -> Disposable {
let bindingToControl = self
.asDriver()
.drive(controlProperty)
func test_asksManagerForLastPhotoTaken_version2() {
let expectedImage = UIImage()
photosManagerMock.expectedImage = expectedImage
expect(subject.lastPhotoTaken) == expectedImage
}
func test_asksManagerForLastPhotoTaken_version2() {
let expectedImage = UIImage()
photosManagerMock.expectedImage = expectedImage
let image = try! subject.lastPhotoTaken.toBlocking().first()!
XCTAssertEqual(image, expectedImage)
}
override func setUp() {
//...
driveOnScheduler(testScheduler) {
subject = AvatarViewModel(imageReceiver: imageHavingMock)
}
}
func test_receiveImage_onButtonClick2() {
simulateTaps(at: 100, 200)
let observer = testScheduler.createObserver(UIImage.self)
subject.image.drive(observer)
.disposed(by: rx_disposeBag)
testScheduler.start()
XCTAssertEqual(observer.events, [next(100, imageHavingMock.expectedImage), next(200, imageHavingMock.expectedImage)])
}
func test_receiveImage_onButtonClick_version2() {
let buttonTaps = testScheduler.createHotObservable([next(100, ()), next(200, ())])
buttonTaps.bindTo(subject.chooseImageButtonPressed)
.disposed(by: rx_disposeBag)
let observer = testScheduler.createObserver(UIImage.self)
self.subject.image.drive(observer)
.disposed(by: self.rx_disposeBag)
testScheduler.start()
testScheduler.start()
XCTAssertEqual(observer.events, [next(100, imageHavingMock.expectedImage), next(200, imageHavingMock.expectedImage)])
let observer = testScheduler.createObserver(UIImage.self)
subject.image.drive(observer)
.disposed(by: rx_disposeBag)
let buttonTaps = testScheduler.createHotObservable([next(100, ()), next(200, ())])
buttonTaps.bindTo(subject.chooseImageButtonPressed)
.disposed(by: rx_disposeBag)