Created
October 28, 2014 20:26
-
-
Save catehstn/3df06cb16c0d67af60b6 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
#import <OCMock/OCMock.h> | |
#import <XCTest/XCTest.h> | |
#import "Presenter.h" | |
#import "ViewController.h" | |
@interface ViewControllerTest : XCTestCase { | |
id mockPresenter_; | |
ViewController *viewController_; | |
} | |
@end | |
@implementation ViewControllerTest | |
- (void)setUp { | |
[super setUp]; | |
mockPresenter_ = OCMStrictClassMock([Presenter class]); | |
OCMExpect([mockPresenter_ setViewController:OCMOCK_ANY]); | |
viewController_ = [[ViewController alloc] initWithPresenter:mockPresenter_]; | |
} | |
- (void)tearDown { | |
[mockPresenter_ verify]; | |
[super tearDown]; | |
} | |
- (void)testInit { | |
OCMVerify([mockPresenter_ setViewController:viewController_]); | |
} | |
- (void)testViewDidLoad { | |
OCMExpect([mockPresenter_ leftNavigationButtons]); | |
OCMExpect([mockPresenter_ rightNavigationButtons]); | |
OCMExpect([mockPresenter_ viewLoaded]); | |
[viewController_ viewDidLoad]; | |
OCMVerify([mockPresenter_ leftNavigationButtons]); | |
OCMVerify([mockPresenter_ rightNavigationButtons]); | |
OCMVerify([mockPresenter_ viewLoaded]); | |
} | |
- (void)testDismissViewController { | |
id mockNavigationController = OCMStrictClassMock([UINavigationController class]); | |
id mockViewController = [OCMockObject partialMockForObject:viewController_]; | |
[[[mockViewController expect] andReturn:mockNavigationController] navigationController]; | |
OCMExpect([mockNavigationController dismissViewControllerAnimated:YES completion:nil]); | |
[viewController_ dismissViewControllerAnimated:YES withCompletionBlock:nil]; | |
OCMVerify([mockNavigationController dismissViewControllerAnimated:YES completion:nil]); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment