Skip to content

Instantly share code, notes, and snippets.

@petermolnar-dev
Created January 6, 2017 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petermolnar-dev/37425916f0f55039670b0b38b26097d0 to your computer and use it in GitHub Desktop.
Save petermolnar-dev/37425916f0f55039670b0b38b26097d0 to your computer and use it in GitHub Desktop.
PMODownloaderTests.m - With delegate
#import <XCTest/XCTest.h>
#import "PMODownloader.h"
#import "PMODownloadNotifications.h"
@interface PMODownloaderTests : XCTestCase
@property (strong, nonatomic) PMODownloader *downloader;
@end
@implementation PMODownloaderTests
- (void)setUp {
[super setUp];
self.downloader = [[PMODownloader alloc] init];
}
- (void)tearDown {
self.downloader = nil;
[super tearDown];
}
/**
Testing the download failure wiht a nonexisting domain
*/
- (void)testPictureAsyncDownloadFailed {
XCTestExpectation *expectation = [self expectationForNotification:PMODownloadFailed
object: nil
handler:^BOOL(NSNotification * _Nonnull notification) {
[expectation fulfill];
return true;
}];
[self.downloader downloadDataFromURL:[NSURL URLWithString:@"https://ThereIsNoSuCHDomainName/MssedUPName.png"]];
[self waitForExpectationsWithTimeout:5.0 handler:^(NSError *error) {
if (error) {
NSLog(@"Timeout Error: %@", error);
}
}];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment