lundi 2 mai 2016

How to unit test the following methods?

I am adding the following code. I want to see examples of unit testing these. I am very new to this so any help would be great! Please provide code! Thanks

 //Dismiss keyboard when tapping on screen
func tapGesture(gesture:UITapGestureRecognizer){

    romanNumeralTextfield.resignFirstResponder()

}


//When return key is tapped the keyboard is dismissed
func textFieldShouldReturn(textField: UITextField) -> Bool {
    romanNumeralTextfield.resignFirstResponder()
    return true
}


//Display keyboard
func keyboardWillShow(notification: NSNotification) {

    if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
        self.view.frame.origin.y -= keyboardSize.height
    }

}


//Hide keyboard
func keyboardWillHide(notification: NSNotification) {
    if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
        self.view.frame.origin.y += keyboardSize.height
    }
}

Aucun commentaire:

Enregistrer un commentaire