Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#import <OCMock/OCMock.h>
#import <XCTest/XCTest.h>
#import "HomeViewController.h"
#import "HomeViewPresenter.h"
@interface HomeViewControllerTest : XCTestCase {
id mockPresenter_;
HomeViewController *viewController_;
}
@end
@implementation HomeViewControllerTest
- (void)setUp {
[super setUp];
mockPresenter_ = OCMStrictClassMock([HomeViewPresenter class]);
OCMExpect([mockPresenter_ setViewController:[OCMArg any]]);
viewController_ = [[HomeViewController alloc] initWithPresenter:mockPresenter_];
}
- (void)testViewLoaded {
[viewController_ loadView];
XCTAssertNotNil([viewController_ homeView]);
}
- (void)testShowImagePickerWithType {
id mockNavigationController = OCMStrictClassMock([UINavigationController class]);
id mockViewController = [OCMockObject partialMockForObject:viewController_];
[[[mockViewController expect] andReturn:mockNavigationController] navigationController];
OCMExpect([mockNavigationController presentViewController:[OCMArg any]
animated:YES
completion:nil]);
[viewController_ showImagePickerWithType:UIImagePickerControllerSourceTypePhotoLibrary
delegate:mockPresenter_];
OCMVerify([mockNavigationController presentViewController:[OCMArg any]
animated:YES
completion:nil]);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment