Last active
December 17, 2015 03:19
-
-
Save ecgreb/5542029 to your computer and use it in GitHub Desktop.
This file contains 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
@implementation HelloTDDViewControllerTests { | |
HelloTDDViewController *viewController; | |
} | |
- (void)setUp { | |
viewController = [[HelloTDDViewController alloc] init]; | |
} | |
//... | |
- (void)testOnButtonClickNotifiesDelegate { | |
MockHelloTDDViewControllerDelegate *delegate = | |
[[MockHelloTDDViewControllerDelegate alloc] init]; | |
viewController.delegate = delegate; | |
[viewController onButtonClick:nil]; | |
BOOL result = delegate.buttonWasClicked; | |
STAssertTrue(result, | |
@"View controller should notify delegate on button click."); | |
} | |
- (void)testOnButtonClickPassesNameToDelegate { | |
MockHelloTDDViewControllerDelegate *delegate = | |
[[MockHelloTDDViewControllerDelegate alloc] init]; | |
viewController.delegate = delegate; | |
UITextField *textField = [[UITextField alloc] init]; | |
textField.text = @"First Last"; | |
viewController.nameField = textField; | |
[viewController onButtonClick:nil]; | |
STAssertEqualObjects(delegate.lastNameSent, @"First Last", | |
@"View controller should pass name to delegate."); | |
} | |
//... | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment