Skip to content

Instantly share code, notes, and snippets.

View HelloCore's full-sized avatar

Core HelloCore

  • Bangkok, Thailand
View GitHub Profile
import XCTest
class FizzBuzzTDDSwiftUITests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
func testTabButtonNumberButtonIncreased() {
let app = XCUIApplication()
let numberBtn = app.buttons["numberBtn"]
numberBtn.tap()
XCTAssertEqual(numberBtn.label, "1", "Score on button should increase")
}
func testPlayToGameOverFirstTime() {
let app = XCUIApplication()
let numberBtn = app.buttons["numberBtn"]
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
if ProcessInfo.processInfo.arguments.contains("HighSpeedAnimation") {
UIApplication.shared.keyWindow?.layer.speed = 100
}
return true
}
UIDevice.rx.orientation
.filter { value in
return value != .landscape
}
.map { _ in
return "Portrait is the best!"
}
.subscribe(onNext: { (string) in
showAlert(text: string)
})
textField
.rx //** <--- สำคัญมาก
.text
.orEmpty
.asObservable()
.subscribe(onNext: { (str) in
print("TextField1 str: [\(str)]")
})
.disposed(by: disposeBag)
func onTextChanged() {
loginBtn.isEnabled = (username.length > 4) && (password.length > 4)
}
func loginFailure() {
username.text = ""
password.text = ""
}
func loginFailure() {
username.text = ""
password.text = ""
loginBtn.isEnabled = (username.length > 4) && (password.length > 4)
}
let usr = username.rx
.text
.orEmpty
.asObservable()
.map { (str)-> Bool in
return str.characters.count > 4
}
let pwd = password.rx
.text
let usrObservable = username.rx
.text
.orEmpty
.asObservable()