Skip to content

Commit

Permalink
Test coverage for new designated initializer (with delegate)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdzombak committed Feb 1, 2016
1 parent b04b273 commit 5797ee1
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions Example/Tests/NYTPhotosViewControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,48 @@ - (void)testRightBarButtonItemsAreNilAfterSettingToNil {
XCTAssertNil(photosViewController.rightBarButtonItems);
}

- (void)testConvenienceInitializerAcceptsNil {
- (void)testOneArgConvenienceInitializerAcceptsNil {
XCTAssertNoThrow([[NYTPhotosViewController alloc] initWithPhotos:nil]);
}

- (void)testDesignatedInitializerAcceptsNilForPhotosParameter {
- (void)testTwoArgConvenienceInitializerAcceptsNilForPhotosParameter {
XCTAssertNoThrow([[NYTPhotosViewController alloc] initWithPhotos:nil initialPhoto:[[NYTExamplePhoto alloc] init]]);
}

- (void)testDesignatedInitializerAcceptsNilForInitialPhotoParameter {
- (void)testTwoArgConvenienceInitializerAcceptsNilForInitialPhotoParameter {
XCTAssertNoThrow([[NYTPhotosViewController alloc] initWithPhotos:[self newTestPhotos] initialPhoto:nil]);
}

- (void)testDesignatedInitializerAcceptsNilForBothParameters {
- (void)testTwoArgConvenienceInitializerAcceptsNilForBothParameters {
XCTAssertNoThrow([[NYTPhotosViewController alloc] initWithPhotos:nil initialPhoto:nil]);
}

- (void)testDesignatedInitializerAcceptsNilForPhotosParameter {
id delegateMock = OCMProtocolMock(@protocol(NYTPhotosViewControllerDelegate));
XCTAssertNoThrow([[NYTPhotosViewController alloc] initWithPhotos:nil initialPhoto:[NYTExamplePhoto new] delegate:delegateMock]);

}

- (void)testDesignatedInitializerAcceptsNilForInitialPhotoParameter {
id delegateMock = OCMProtocolMock(@protocol(NYTPhotosViewControllerDelegate));
XCTAssertNoThrow([[NYTPhotosViewController alloc] initWithPhotos:[self newTestPhotos] initialPhoto:nil delegate:delegateMock]);
}

- (void)testDesignatedInitializerAcceptsNilForDelegateParameter {
XCTAssertNoThrow([[NYTPhotosViewController alloc] initWithPhotos:[self newTestPhotos] initialPhoto:[NYTExamplePhoto new] delegate:nil]);
}

- (void)testDesignatedInitializerAcceptsNilForAllParameters {
XCTAssertNoThrow([[NYTPhotosViewController alloc] initWithPhotos:nil initialPhoto:nil delegate:nil]);
}

- (void)testDesignatedInitializerSetsDelegate {
id delegateMock = OCMProtocolMock(@protocol(NYTPhotosViewControllerDelegate));
NYTPhotosViewController *sut = [[NYTPhotosViewController alloc] initWithPhotos:[self newTestPhotos] initialPhoto:nil delegate:delegateMock];

XCTAssertEqual(sut.delegate, delegateMock);
}

- (void)testDisplayPhotoAcceptsNil {
NYTPhotosViewController *photosViewController = [[NYTPhotosViewController alloc] initWithPhotos:[self newTestPhotos]];
XCTAssertNoThrow([photosViewController displayPhoto:nil animated:NO]);
Expand Down

0 comments on commit 5797ee1

Please sign in to comment.