forked from nytimes/NYTPhotoViewer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nytimes#253 from jamesstout/fix-tests
Fix tests
- Loading branch information
Showing
7 changed files
with
151 additions
and
68 deletions.
There are no files selected for viewing
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
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
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
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
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
64 changes: 64 additions & 0 deletions
64
NYTPhotoViewerTests/NYTPhotoViewerSinglePhotoDataSourceTests.m
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// NYTPhotosDataSourceTests.m | ||
// NYTPhotoViewer | ||
// | ||
// Created by Brian Capps on 2/26/15. | ||
// Copyright (c) 2015 NYTimes. All rights reserved. | ||
// | ||
|
||
@import UIKit; | ||
@import XCTest; | ||
|
||
#import "NYTExamplePhoto.h" | ||
#import "NYTPhotoViewerSinglePhotoDataSource.h" | ||
|
||
@interface NYTPhotoViewerSinglePhotoDataSourceTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation NYTPhotoViewerSinglePhotoDataSourceTests | ||
|
||
- (void)testInitializerAcceptsNil { | ||
XCTAssertNoThrow([[NYTPhotoViewerSinglePhotoDataSource alloc] initWithPhoto:nil]); | ||
} | ||
|
||
- (void)testOutOfBoundsDoesNotCrash { | ||
NYTPhotoViewerSinglePhotoDataSource *dataSource = [[NYTPhotoViewerSinglePhotoDataSource alloc] initWithPhoto:nil]; | ||
XCTAssertNoThrow([dataSource photoAtIndex:1]); | ||
} | ||
|
||
- (void)testOutOfBoundsReturnsNil { | ||
NYTPhotoViewerSinglePhotoDataSource *dataSource = [[NYTPhotoViewerSinglePhotoDataSource alloc] initWithPhoto:nil]; | ||
XCTAssertNil([dataSource photoAtIndex:1]); | ||
} | ||
|
||
- (void)testValidIndexReturnsPhotoAtIndex { | ||
NYTExamplePhoto *photo = [[NYTExamplePhoto alloc] init]; | ||
NYTPhotoViewerSinglePhotoDataSource *dataSource = [[NYTPhotoViewerSinglePhotoDataSource alloc] initWithPhoto:photo]; | ||
XCTAssertEqual(0, [dataSource indexOfPhoto:photo]); | ||
} | ||
|
||
- (void)testValidIndexReturnsPhoto { | ||
NYTExamplePhoto *photo = [[NYTExamplePhoto alloc] init]; | ||
NYTPhotoViewerSinglePhotoDataSource *dataSource = [[NYTPhotoViewerSinglePhotoDataSource alloc] initWithPhoto:photo]; | ||
XCTAssertNotNil([dataSource photoAtIndex:1]); | ||
} | ||
|
||
- (void)testValidIndexReturnsCorrectPhoto { | ||
NSArray *photos = [self newTestPhotos]; | ||
NYTPhotoViewerSinglePhotoDataSource *dataSource = [[NYTPhotoViewerSinglePhotoDataSource alloc] initWithPhoto:photos.firstObject]; | ||
XCTAssertEqualObjects(photos.firstObject, [dataSource photoAtIndex:0]); | ||
} | ||
|
||
- (NSArray *)newTestPhotos { | ||
NSMutableArray *photos = [NSMutableArray array]; | ||
|
||
for (int i = 0; i < 5; i++) { | ||
NYTExamplePhoto *photo = [[NYTExamplePhoto alloc] init]; | ||
[photos addObject:photo]; | ||
} | ||
|
||
return photos; | ||
} | ||
|
||
@end |
Oops, something went wrong.