diff --git a/Haneke/HNKCache.h b/Haneke/HNKCache.h index 5ccaed8..8d3017f 100644 --- a/Haneke/HNKCache.h +++ b/Haneke/HNKCache.h @@ -134,7 +134,7 @@ Returns the key of the original image returned by the fetcher. @discussion If two different fetchers provide the same image, they should return the same key for better performance. */ -@property (nonatomic, readonly) NSString *cacheKey; +@property (nonatomic, readonly) NSString *key; /** Retrieves the original image associated with the fetcher. diff --git a/Haneke/HNKCache.m b/Haneke/HNKCache.m index 04badbc..79a5e90 100644 --- a/Haneke/HNKCache.m +++ b/Haneke/HNKCache.m @@ -124,7 +124,7 @@ - (NSDictionary*)formats - (BOOL)fetchImageForFetcher:(id)fetcher formatName:(NSString *)formatName success:(void (^)(UIImage *image))successBlock failure:(void (^)(NSError *error))failureBlock { - NSString *key = fetcher.cacheKey; + NSString *key = fetcher.key; return [self fetchImageForKey:key formatName:formatName success:^(UIImage *image) { if (successBlock) successBlock(image); } failure:^(NSError *error) { @@ -259,7 +259,7 @@ - (void)fetchImageFromFetcher:(id)fetcher completionBlock:(void(^)(U } else { - NSString *key = fetcher.cacheKey; + NSString *key = fetcher.key; NSString *errorDescription = [NSString stringWithFormat:NSLocalizedString(@"Invalid fetcher %@: Must return non-nil in success block", @""), key.lastPathComponent]; HanekeLog(@"%@", errorDescription); NSDictionary *userInfo = @{ NSLocalizedDescriptionKey : errorDescription }; diff --git a/Haneke/HNKDiskFetcher.m b/Haneke/HNKDiskFetcher.m index 6e38b1b..c2c42d9 100644 --- a/Haneke/HNKDiskFetcher.m +++ b/Haneke/HNKDiskFetcher.m @@ -34,7 +34,7 @@ - (instancetype)initWithPath:(NSString*)path return self; } -- (NSString*)cacheKey +- (NSString*)key { return _path; } diff --git a/Haneke/HNKNetworkFetcher.m b/Haneke/HNKNetworkFetcher.m index 4e47d0a..1b4d69a 100644 --- a/Haneke/HNKNetworkFetcher.m +++ b/Haneke/HNKNetworkFetcher.m @@ -35,7 +35,7 @@ - (instancetype)initWithURL:(NSURL*)URL return self; } -- (NSString*)cacheKey +- (NSString*)key { return _URL.absoluteString; } diff --git a/Haneke/HNKSimpleFetcher.m b/Haneke/HNKSimpleFetcher.m index a3e24b2..f317454 100644 --- a/Haneke/HNKSimpleFetcher.m +++ b/Haneke/HNKSimpleFetcher.m @@ -35,7 +35,7 @@ - (instancetype)initWithKey:(NSString*)key image:(UIImage*)image return self; } -- (NSString*)cacheKey +- (NSString*)key { return _key; } diff --git a/Haneke/UIButton+Haneke.m b/Haneke/UIButton+Haneke.m index 59c47c3..0167d76 100644 --- a/Haneke/UIButton+Haneke.m +++ b/Haneke/UIButton+Haneke.m @@ -149,12 +149,12 @@ - (BOOL)hnk_fetchImageFromFetcher:(id)fetcher forState:(UIControlSta __weak __typeof__(self) weakSelf = self; const BOOL didSetImage = [[HNKCache sharedCache] fetchImageForFetcher:fetcher formatName:format.name success:^(UIImage *image) { __typeof__(weakSelf) strongSelf = weakSelf; - if ([strongSelf hnk_shouldCancelSetImageForKey:fetcher.cacheKey]) return; + if ([strongSelf hnk_shouldCancelSetImageForKey:fetcher.key]) return; [strongSelf hnk_setImage:image forState:state animated:animated success:successBlock]; } failure:^(NSError *error) { __typeof__(weakSelf) strongSelf = weakSelf; - if ([strongSelf hnk_shouldCancelSetImageForKey:fetcher.cacheKey]) return; + if ([strongSelf hnk_shouldCancelSetImageForKey:fetcher.key]) return; strongSelf.hnk_imageFetcher = nil; @@ -183,7 +183,7 @@ - (void)hnk_setImage:(UIImage*)image forState:(UIControlState)state animated:(BO - (BOOL)hnk_shouldCancelSetImageForKey:(NSString*)key { - if ([self.hnk_imageFetcher.cacheKey isEqualToString:key]) return NO; + if ([self.hnk_imageFetcher.key isEqualToString:key]) return NO; HanekeLog(@"Cancelled set image from key %@", key.lastPathComponent); return YES; @@ -310,12 +310,12 @@ - (BOOL)hnk_fetchBackgroundImageFromFetcher:(id)fetcher forState:(UI __weak __typeof__(self) weakSelf = self; const BOOL didSetImage = [[HNKCache sharedCache] fetchImageForFetcher:fetcher formatName:format.name success:^(UIImage *image) { __typeof__(weakSelf) strongSelf = weakSelf; - if ([strongSelf hnk_shouldCancelSetBackgroundImageForKey:fetcher.cacheKey]) return; + if ([strongSelf hnk_shouldCancelSetBackgroundImageForKey:fetcher.key]) return; [strongSelf hnk_setBackgroundImage:image forState:state animated:animated success:successBlock]; } failure:^(NSError *error) { __typeof__(weakSelf) strongSelf = weakSelf; - if ([strongSelf hnk_shouldCancelSetBackgroundImageForKey:fetcher.cacheKey]) return; + if ([strongSelf hnk_shouldCancelSetBackgroundImageForKey:fetcher.key]) return; strongSelf.hnk_backgroundImageFetcher = nil; @@ -344,7 +344,7 @@ - (void)hnk_setBackgroundImage:(UIImage*)image forState:(UIControlState)state an - (BOOL)hnk_shouldCancelSetBackgroundImageForKey:(NSString*)key { - if ([self.hnk_backgroundImageFetcher.cacheKey isEqualToString:key]) return NO; + if ([self.hnk_backgroundImageFetcher.key isEqualToString:key]) return NO; HanekeLog(@"Cancelled set background image from key %@", key.lastPathComponent); return YES; diff --git a/Haneke/UIImageView+Haneke.m b/Haneke/UIImageView+Haneke.m index 61bcd8e..93d215f 100644 --- a/Haneke/UIImageView+Haneke.m +++ b/Haneke/UIImageView+Haneke.m @@ -133,12 +133,12 @@ - (BOOL)hnk_fetchImageForFetcher:(id)fetcher success:(void (^)(UIIma __weak __typeof__(self) weakSelf = self; const BOOL didSetImage = [[HNKCache sharedCache] fetchImageForFetcher:fetcher formatName:format.name success:^(UIImage *image) { __typeof__(weakSelf) strongSelf = weakSelf; - if ([strongSelf hnk_shouldCancelForKey:fetcher.cacheKey]) return; + if ([strongSelf hnk_shouldCancelForKey:fetcher.key]) return; [strongSelf hnk_setImage:image animated:animated success:successBlock]; } failure:^(NSError *error) { __typeof__(weakSelf) strongSelf = weakSelf; - if ([strongSelf hnk_shouldCancelForKey:fetcher.cacheKey]) return; + if ([strongSelf hnk_shouldCancelForKey:fetcher.key]) return; strongSelf.hnk_fetcher = nil; @@ -167,7 +167,7 @@ - (void)hnk_setImage:(UIImage*)image animated:(BOOL)animated success:(void (^)(U - (BOOL)hnk_shouldCancelForKey:(NSString*)key { - if ([self.hnk_fetcher.cacheKey isEqualToString:key]) return NO; + if ([self.hnk_fetcher.key isEqualToString:key]) return NO; HanekeLog(@"Cancelled set image for %@", key.lastPathComponent); return YES; diff --git a/HanekeTests/HNKCacheTests.m b/HanekeTests/HNKCacheTests.m index a725154..4c1d5eb 100644 --- a/HanekeTests/HNKCacheTests.m +++ b/HanekeTests/HNKCacheTests.m @@ -210,7 +210,7 @@ - (void)testFetchImageForFetcher_MemoryCacheHit id fetcher = [HNKCache fetcherWithKey:@"1" image:image]; HNKCacheFormat *format = [_sut registerFormatWithSize:CGSizeMake(1, 1)]; NSString *formatName = format.name; - [_sut setImage:image forKey:fetcher.cacheKey formatName:formatName]; + [_sut setImage:image forKey:fetcher.key formatName:formatName]; BOOL result = [_sut fetchImageForFetcher:fetcher formatName:format.name success:^(UIImage *result) { XCTAssertEqualObjects(result, image, @""); diff --git a/HanekeTests/HNKDiskFetcherTests.m b/HanekeTests/HNKDiskFetcherTests.m index 3342059..a462a48 100644 --- a/HanekeTests/HNKDiskFetcherTests.m +++ b/HanekeTests/HNKDiskFetcherTests.m @@ -49,12 +49,12 @@ - (void)tearDown [super tearDown]; } -- (void)testCacheKey +- (void)testKey { NSString *path = [_directory stringByAppendingPathComponent:self.name]; _sut = [[HNKDiskFetcher alloc] initWithPath:path]; - XCTAssertEqualObjects(_sut.cacheKey, path, @""); + XCTAssertEqualObjects(_sut.key, path, @""); } - (void)testFetchImage_Success diff --git a/HanekeTests/HNKNetworkFetcherTests.m b/HanekeTests/HNKNetworkFetcherTests.m index 435e260..e1098d6 100644 --- a/HanekeTests/HNKNetworkFetcherTests.m +++ b/HanekeTests/HNKNetworkFetcherTests.m @@ -51,11 +51,11 @@ - (void)testURL XCTAssertEqualObjects(_sut.URL, _URL, @""); } -- (void)testCacheKey +- (void)testKey { _sut = [[HNKNetworkFetcher alloc] initWithURL:_URL]; - XCTAssertEqualObjects(_sut.cacheKey, _URL.absoluteString, @""); + XCTAssertEqualObjects(_sut.key, _URL.absoluteString, @""); } - (void)testFetchImage_Success diff --git a/HanekeTests/HNKSimpleFetcherTests.m b/HanekeTests/HNKSimpleFetcherTests.m index d3ce314..c5a2c7d 100644 --- a/HanekeTests/HNKSimpleFetcherTests.m +++ b/HanekeTests/HNKSimpleFetcherTests.m @@ -30,13 +30,13 @@ @implementation HNKSimpleFetcherTests { HNKSimpleFetcher *_sut; } -- (void)testCacheKey +- (void)testKey { UIImage *image = [UIImage hnk_imageWithColor:[UIColor greenColor] size:CGSizeMake(10, 10)]; NSString *key = self.name; _sut = [[HNKSimpleFetcher alloc] initWithKey:key image:image]; - XCTAssertEqualObjects(_sut.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.key, key, @""); } - (void)testFetchImage diff --git a/HanekeTests/UIButton+HanekeTests.m b/HanekeTests/UIButton+HanekeTests.m index 1855860..5d8daee 100644 --- a/HanekeTests/UIButton+HanekeTests.m +++ b/HanekeTests/UIButton+HanekeTests.m @@ -209,7 +209,7 @@ - (void)testSetImageWithKey_MemoryCacheMiss [_sut hnk_setImage:image withKey:key forState:UIControlStateNormal]; - XCTAssertEqualObjects(_sut.hnk_imageFetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_imageFetcher.key, key, @""); XCTAssertNil([_sut imageForState:UIControlStateNormal], @""); } @@ -223,7 +223,7 @@ - (void)testSetImageWithKey_ImageSet_MemoryCacheMiss [_sut hnk_setImage:image withKey:key forState:state]; - XCTAssertEqualObjects(_sut.hnk_imageFetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_imageFetcher.key, key, @""); XCTAssertEqualObjects([_sut imageForState:state], previousImage, @""); } @@ -249,7 +249,7 @@ - (void)testSetImageWithKeyPlaceholder_MemoryCacheMiss [_sut hnk_setImage:image withKey:key forState:UIControlStateNormal placeholder:placeholder]; - XCTAssertEqualObjects(_sut.hnk_imageFetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_imageFetcher.key, key, @""); XCTAssertEqualObjects([_sut imageForState:UIControlStateNormal], placeholder, @""); } @@ -264,7 +264,7 @@ - (void)testSetImageWithKeyPlaceholder_ImageSet_MemoryCacheMiss [_sut hnk_setImage:image withKey:key forState:state placeholder:placeholder]; - XCTAssertEqualObjects(_sut.hnk_imageFetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_imageFetcher.key, key, @""); XCTAssertEqualObjects([_sut imageForState:state], placeholder, @""); } @@ -313,7 +313,7 @@ - (void)testSetImageWithKeyPlaceholderSuccessFailure_MemoryCacheMiss [_sut hnk_setImage:image withKey:key forState:state placeholder:nil success:nil failure:nil]; - XCTAssertEqualObjects(_sut.hnk_imageFetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_imageFetcher.key, key, @""); XCTAssertNil([_sut imageForState:state], @""); } @@ -327,7 +327,7 @@ - (void)testSetImageWithKeyPlaceholderSuccessFailure_ImageSet_MemoryCacheMiss [_sut hnk_setImage:image withKey:key forState:state placeholder:nil success:nil failure:nil]; - XCTAssertEqualObjects(_sut.hnk_imageFetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_imageFetcher.key, key, @""); XCTAssertEqualObjects([_sut imageForState:state], previousImage, @""); } @@ -339,7 +339,7 @@ - (void)testSetImageFromFile_MemoryCacheHit_UIControlStateNormal id fetcher = [[HNKDiskFetcher alloc] initWithPath:path]; UIImage *image = [UIImage hnk_imageWithColor:[UIColor greenColor] size:CGSizeMake(10, 20)]; HNKCacheFormat *format = _sut.hnk_imageFormat; - [[HNKCache sharedCache] setImage:image forKey:fetcher.cacheKey formatName:format.name]; + [[HNKCache sharedCache] setImage:image forKey:fetcher.key formatName:format.name]; const UIControlState state = UIControlStateNormal; [_sut hnk_setImageFromFile:path forState:state]; @@ -357,7 +357,7 @@ - (void)testSetImageFromFilePlaceholder_MemoryCacheMiss_UIControlStateSelected [_sut hnk_setImageFromFile:path forState:state placeholder:placeholder]; - XCTAssertEqualObjects(_sut.hnk_imageFetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_imageFetcher.key, fetcher.key, @""); XCTAssertEqualObjects([_sut imageForState:state], placeholder, @""); } @@ -367,7 +367,7 @@ - (void)testSetImageFromFilePlaceholderSuccessFailure_MemoryCacheHit id fetcher = [[HNKDiskFetcher alloc] initWithPath:path]; UIImage *image = [UIImage hnk_imageWithColor:[UIColor greenColor] size:CGSizeMake(10, 20)]; HNKCacheFormat *format = _sut.hnk_imageFormat; - [[HNKCache sharedCache] setImage:image forKey:fetcher.cacheKey formatName:format.name]; + [[HNKCache sharedCache] setImage:image forKey:fetcher.key formatName:format.name]; const UIControlState state = UIControlStateNormal; __block BOOL success = NO; @@ -391,7 +391,7 @@ - (void)testSetImageFromURL_MemoryCacheHit_UIControlStateNormal id fetcher = [[HNKNetworkFetcher alloc] initWithURL:URL]; UIImage *image = [UIImage hnk_imageWithColor:[UIColor greenColor] size:CGSizeMake(10, 20)]; HNKCacheFormat *format = _sut.hnk_imageFormat; - [[HNKCache sharedCache] setImage:image forKey:fetcher.cacheKey formatName:format.name]; + [[HNKCache sharedCache] setImage:image forKey:fetcher.key formatName:format.name]; const UIControlState state = UIControlStateNormal; [_sut hnk_setImageFromURL:URL forState:state]; @@ -409,7 +409,7 @@ - (void)testSetImageFromURLPlaceholder_MemoryCacheMiss_UIControlStateSelected [_sut hnk_setImageFromURL:URL forState:state placeholder:placeholder]; - XCTAssertEqualObjects(_sut.hnk_imageFetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_imageFetcher.key, fetcher.key, @""); XCTAssertEqualObjects([_sut imageForState:state], placeholder, @""); } @@ -419,7 +419,7 @@ - (void)testSetImageFromURLPlaceholderSuccessFailure_MemoryCacheHit id fetcher = [[HNKNetworkFetcher alloc] initWithURL:URL]; UIImage *image = [UIImage hnk_imageWithColor:[UIColor greenColor] size:CGSizeMake(10, 20)]; HNKCacheFormat *format = _sut.hnk_imageFormat; - [[HNKCache sharedCache] setImage:image forKey:fetcher.cacheKey formatName:format.name]; + [[HNKCache sharedCache] setImage:image forKey:fetcher.key formatName:format.name]; const UIControlState state = UIControlStateNormal; __block BOOL success = NO; @@ -442,7 +442,7 @@ - (void)testSetImageFromFetcher_MemoryCacheHit_UIControlStateNormal id fetcher = [[HNKSimpleFetcher alloc] initWithKey:self.name image:nil]; UIImage *image = [UIImage hnk_imageWithColor:[UIColor greenColor] size:CGSizeMake(10, 20)]; HNKCacheFormat *format = _sut.hnk_imageFormat; - [[HNKCache sharedCache] setImage:image forKey:fetcher.cacheKey formatName:format.name]; + [[HNKCache sharedCache] setImage:image forKey:fetcher.key formatName:format.name]; const UIControlState state = UIControlStateNormal; [_sut hnk_setImageFromFetcher:fetcher forState:state]; @@ -468,7 +468,7 @@ - (void)testSetImageFromFetcherPlaceholderSuccessFailure_MemoryCacheHit id fetcher = [[HNKSimpleFetcher alloc] initWithKey:self.name image:nil]; UIImage *image = [UIImage hnk_imageWithColor:[UIColor greenColor] size:CGSizeMake(10, 20)]; HNKCacheFormat *format = _sut.hnk_imageFormat; - [[HNKCache sharedCache] setImage:image forKey:fetcher.cacheKey formatName:format.name]; + [[HNKCache sharedCache] setImage:image forKey:fetcher.key formatName:format.name]; const UIControlState state = UIControlStateNormal; __block BOOL success = NO; @@ -590,7 +590,7 @@ - (void)testSetBackgroundImageWithKey_MemoryCacheMiss [_sut hnk_setBackgroundImage:image withKey:key forState:UIControlStateNormal]; - XCTAssertEqualObjects(_sut.hnk_backgroundImageFetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_backgroundImageFetcher.key, key, @""); XCTAssertNil([_sut backgroundImageForState:UIControlStateNormal], @""); } @@ -604,7 +604,7 @@ - (void)testSetBackgroundImageWithKey_ImageSet_MemoryCacheMiss [_sut hnk_setBackgroundImage:image withKey:key forState:state]; - XCTAssertEqualObjects(_sut.hnk_backgroundImageFetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_backgroundImageFetcher.key, key, @""); XCTAssertEqualObjects([_sut backgroundImageForState:state], previousImage, @""); } @@ -630,7 +630,7 @@ - (void)testSetBackgroundImageWithKeyPlaceholder_MemoryCacheMiss [_sut hnk_setBackgroundImage:image withKey:key forState:UIControlStateNormal placeholder:placeholder]; - XCTAssertEqualObjects(_sut.hnk_backgroundImageFetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_backgroundImageFetcher.key, key, @""); XCTAssertEqualObjects([_sut backgroundImageForState:UIControlStateNormal], placeholder, @""); } @@ -645,7 +645,7 @@ - (void)testSetBackgroundImageWithKeyPlaceholder_ImageSet_MemoryCacheMiss [_sut hnk_setBackgroundImage:image withKey:key forState:state placeholder:placeholder]; - XCTAssertEqualObjects(_sut.hnk_backgroundImageFetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_backgroundImageFetcher.key, key, @""); XCTAssertEqualObjects([_sut backgroundImageForState:state], placeholder, @""); } @@ -694,7 +694,7 @@ - (void)testSetBackgroundImageWithKeyPlaceholderSuccessFailure_MemoryCacheMiss [_sut hnk_setBackgroundImage:image withKey:key forState:state placeholder:nil success:nil failure:nil]; - XCTAssertEqualObjects(_sut.hnk_backgroundImageFetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_backgroundImageFetcher.key, key, @""); XCTAssertNil([_sut backgroundImageForState:state], @""); } @@ -708,7 +708,7 @@ - (void)testSetBackgroundImageWithKeyPlaceholderSuccessFailure_ImageSet_MemoryCa [_sut hnk_setBackgroundImage:image withKey:key forState:state placeholder:nil success:nil failure:nil]; - XCTAssertEqualObjects(_sut.hnk_backgroundImageFetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_backgroundImageFetcher.key, key, @""); XCTAssertEqualObjects([_sut backgroundImageForState:state], previousImage, @""); } @@ -720,7 +720,7 @@ - (void)testSetBackgroundImageFromFile_MemoryCacheHit_UIControlStateNormal id fetcher = [[HNKDiskFetcher alloc] initWithPath:path]; UIImage *image = [UIImage hnk_imageWithColor:[UIColor greenColor] size:CGSizeMake(10, 20)]; HNKCacheFormat *format = _sut.hnk_backgroundImageFormat; - [[HNKCache sharedCache] setImage:image forKey:fetcher.cacheKey formatName:format.name]; + [[HNKCache sharedCache] setImage:image forKey:fetcher.key formatName:format.name]; const UIControlState state = UIControlStateNormal; [_sut hnk_setBackgroundImageFromFile:path forState:state]; @@ -738,7 +738,7 @@ - (void)testSetBackgroundImageFromFilePlaceholder_MemoryCacheMiss_UIControlState [_sut hnk_setBackgroundImageFromFile:path forState:state placeholder:placeholder]; - XCTAssertEqualObjects(_sut.hnk_backgroundImageFetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_backgroundImageFetcher.key, fetcher.key, @""); XCTAssertEqualObjects([_sut backgroundImageForState:state], placeholder, @""); } @@ -748,7 +748,7 @@ - (void)testSetBackgroundImageFromFilePlaceholderSuccessFailure_MemoryCacheHit id fetcher = [[HNKDiskFetcher alloc] initWithPath:path]; UIImage *image = [UIImage hnk_imageWithColor:[UIColor greenColor] size:CGSizeMake(10, 20)]; HNKCacheFormat *format = _sut.hnk_backgroundImageFormat; - [[HNKCache sharedCache] setImage:image forKey:fetcher.cacheKey formatName:format.name]; + [[HNKCache sharedCache] setImage:image forKey:fetcher.key formatName:format.name]; const UIControlState state = UIControlStateNormal; __block BOOL success = NO; @@ -772,7 +772,7 @@ - (void)testSetBackgroundImageFromURL_MemoryCacheHit_UIControlStateNormal id fetcher = [[HNKNetworkFetcher alloc] initWithURL:URL]; UIImage *image = [UIImage hnk_imageWithColor:[UIColor greenColor] size:CGSizeMake(10, 20)]; HNKCacheFormat *format = _sut.hnk_backgroundImageFormat; - [[HNKCache sharedCache] setImage:image forKey:fetcher.cacheKey formatName:format.name]; + [[HNKCache sharedCache] setImage:image forKey:fetcher.key formatName:format.name]; const UIControlState state = UIControlStateNormal; [_sut hnk_setBackgroundImageFromURL:URL forState:state]; @@ -790,7 +790,7 @@ - (void)testSetBackgroundImageFromURLPlaceholder_MemoryCacheMiss_UIControlStateS [_sut hnk_setBackgroundImageFromURL:URL forState:state placeholder:placeholder]; - XCTAssertEqualObjects(_sut.hnk_backgroundImageFetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_backgroundImageFetcher.key, fetcher.key, @""); XCTAssertEqualObjects([_sut backgroundImageForState:state], placeholder, @""); } @@ -800,7 +800,7 @@ - (void)testSetBackgroundImageFromURLPlaceholderSuccessFailure_MemoryCacheHit id fetcher = [[HNKNetworkFetcher alloc] initWithURL:URL]; UIImage *image = [UIImage hnk_imageWithColor:[UIColor greenColor] size:CGSizeMake(10, 20)]; HNKCacheFormat *format = _sut.hnk_backgroundImageFormat; - [[HNKCache sharedCache] setImage:image forKey:fetcher.cacheKey formatName:format.name]; + [[HNKCache sharedCache] setImage:image forKey:fetcher.key formatName:format.name]; const UIControlState state = UIControlStateNormal; __block BOOL success = NO; @@ -823,7 +823,7 @@ - (void)testSetBackgroundImageFromFetcher_MemoryCacheHit_UIControlStateNormal id fetcher = [[HNKSimpleFetcher alloc] initWithKey:self.name image:nil]; UIImage *image = [UIImage hnk_imageWithColor:[UIColor greenColor] size:CGSizeMake(10, 20)]; HNKCacheFormat *format = _sut.hnk_backgroundImageFormat; - [[HNKCache sharedCache] setImage:image forKey:fetcher.cacheKey formatName:format.name]; + [[HNKCache sharedCache] setImage:image forKey:fetcher.key formatName:format.name]; const UIControlState state = UIControlStateNormal; [_sut hnk_setBackgroundImageFromFetcher:fetcher forState:state]; @@ -849,7 +849,7 @@ - (void)testSetBackgroundImageFromFetcherPlaceholderSuccessFailure_MemoryCacheHi id fetcher = [[HNKSimpleFetcher alloc] initWithKey:self.name image:nil]; UIImage *image = [UIImage hnk_imageWithColor:[UIColor greenColor] size:CGSizeMake(10, 20)]; HNKCacheFormat *format = _sut.hnk_backgroundImageFormat; - [[HNKCache sharedCache] setImage:image forKey:fetcher.cacheKey formatName:format.name]; + [[HNKCache sharedCache] setImage:image forKey:fetcher.key formatName:format.name]; const UIControlState state = UIControlStateNormal; __block BOOL success = NO; diff --git a/HanekeTests/UIImageView+HanekeTests.m b/HanekeTests/UIImageView+HanekeTests.m index e20b932..d0f4fab 100644 --- a/HanekeTests/UIImageView+HanekeTests.m +++ b/HanekeTests/UIImageView+HanekeTests.m @@ -120,7 +120,7 @@ - (void)testSetImageWithKey_MemoryCacheMiss [_sut hnk_setImage:image withKey:key]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, key, @""); XCTAssertNil(_sut.image, @""); } @@ -146,7 +146,7 @@ - (void)testSetImageWithKey_ImageSet_MemoryCacheMiss [_sut hnk_setImage:image withKey:key]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, key, @""); XCTAssertEqualObjects(_sut.image, previousImage, @""); } @@ -158,7 +158,7 @@ - (void)testSetImageWithKeyPlaceholder_MemoryCacheMiss [_sut hnk_setImage:image withKey:key placeholder:placeholder]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, key, @""); XCTAssertEqualObjects(_sut.image, placeholder, @""); } @@ -186,7 +186,7 @@ - (void)testSetImageWithKeyPlaceholder_ImageSet_NilPlaceholder_MemoryCacheMiss [_sut hnk_setImage:image withKey:key]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, key, @""); UIImage *result = _sut.image; XCTAssertEqualObjects(result, previousImage, @""); } @@ -234,7 +234,7 @@ - (void)testSetImageWithKeyPlaceholderSuccessFailure_MemoryCacheMiss [_sut hnk_setImage:image withKey:key placeholder:nil success:nil failure:nil]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, key, @""); XCTAssertNil(_sut.image, @""); } @@ -247,7 +247,7 @@ - (void)testSetImageWithKeyPlaceholderSuccessFailure_ImageSet_MemoryCacheMiss [_sut hnk_setImage:image withKey:key placeholder:nil success:nil failure:nil]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, key, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, key, @""); UIImage *result = _sut.image; XCTAssertEqualObjects(result, previousImage, @""); } @@ -263,7 +263,7 @@ - (void)testSetImageFromFile_MemoryCacheMiss [_sut hnk_setImageFromFile:path]; HNKDiskFetcher *fetcher = [[HNKDiskFetcher alloc] initWithPath:path]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, fetcher.key, @""); XCTAssertNil(_sut.image, @""); [[NSFileManager defaultManager] removeItemAtPath:path error:nil]; @@ -280,7 +280,7 @@ - (void)testSetImageFromFile_ImageSet_MemoryCacheMiss [_sut hnk_setImageFromFile:path]; HNKDiskFetcher *fetcher = [[HNKDiskFetcher alloc] initWithPath:path]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, fetcher.key, @""); XCTAssertEqualObjects(_sut.image, previousImage, @""); [[NSFileManager defaultManager] removeItemAtPath:path error:nil]; @@ -323,7 +323,7 @@ - (void)testSetImageFromFilePlaceholder_MemoryCacheMiss [_sut hnk_setImageFromFile:path placeholder:placeholder]; HNKDiskFetcher *fetcher = [[HNKDiskFetcher alloc] initWithPath:path]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, fetcher.key, @""); UIImage *result = _sut.image; XCTAssertEqualObjects(result, placeholder, @""); } @@ -337,7 +337,7 @@ - (void)testSetImageFromFilePlaceholder_ImageSet_NilPlaceholder_MemoryCacheMiss [_sut hnk_setImageFromFile:path placeholder:nil]; HNKDiskFetcher *fetcher = [[HNKDiskFetcher alloc] initWithPath:path]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, fetcher.key, @""); UIImage *result = _sut.image; XCTAssertEqualObjects(result, previousImage, @""); } @@ -381,7 +381,7 @@ - (void)testSetImageFromFilePlaceholderSuccessFailure_MemoryCacheMiss [_sut hnk_setImageFromFile:path placeholder:nil success:nil failure:nil]; HNKDiskFetcher *fetcher = [[HNKDiskFetcher alloc] initWithPath:path]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, fetcher.key, @""); XCTAssertNil(_sut.image, @""); } @@ -394,7 +394,7 @@ - (void)testSetImageFromFilePlaceholderSuccessFailure_ImageSet_MemoryCacheMiss [_sut hnk_setImageFromFile:path placeholder:nil success:nil failure:nil]; HNKDiskFetcher *fetcher = [[HNKDiskFetcher alloc] initWithPath:path]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, fetcher.key, @""); UIImage *result = _sut.image; XCTAssertEqualObjects(result, previousImage, @""); } @@ -435,7 +435,7 @@ - (void)testSetImageFromFilePlaceholderSuccessFailure_InvalidData }]; HNKDiskFetcher *fetcher = [[HNKDiskFetcher alloc] initWithPath:path]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, fetcher.key, @""); }]; [[NSFileManager defaultManager] removeItemAtPath:path error:nil]; @@ -536,7 +536,7 @@ - (void)testSetImageFromURL_MemoryCacheMiss [_sut hnk_setImageFromURL:url]; id fetcher = [[HNKNetworkFetcher alloc] initWithURL:url]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, fetcher.key, @""); XCTAssertNil(_sut.image, @""); } @@ -549,7 +549,7 @@ - (void)testSetImageFromURL_ImageSet_MemoryCacheMiss [_sut hnk_setImageFromURL:url]; id fetcher = [[HNKNetworkFetcher alloc] initWithURL:url]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, fetcher.key, @""); XCTAssertEqualObjects(_sut.image, previousImage, @""); } @@ -593,7 +593,7 @@ - (void)testSetImageFromURLPlaceholder_MemoryCacheMiss [_sut hnk_setImageFromURL:url placeholder:placeholder]; id fetcher = [[HNKNetworkFetcher alloc] initWithURL:url]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, fetcher.key, @""); UIImage *result = _sut.image; XCTAssertEqualObjects(result, placeholder, @""); } @@ -608,7 +608,7 @@ - (void)testSetImageFromURLPlaceholder_ImageSet_NilPlaceholder_MemoryCacheMiss [_sut hnk_setImageFromURL:url placeholder:nil]; id fetcher = [[HNKNetworkFetcher alloc] initWithURL:url]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, fetcher.key, @""); UIImage *result = _sut.image; XCTAssertEqualObjects(result, previousImage, @""); } @@ -620,7 +620,7 @@ - (void)testSetImageFromURLPlaceholderSuccessFailure_MemoryCacheMiss [_sut hnk_setImageFromURL:url placeholder:nil success:nil failure:nil]; id fetcher = [[HNKNetworkFetcher alloc] initWithURL:url]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, fetcher.key, @""); XCTAssertNil(_sut.image, @""); } @@ -633,7 +633,7 @@ - (void)testSetImageFromURLPlaceholderSuccessFailure_ImageSet_MemoryCacheMiss [_sut hnk_setImageFromURL:url placeholder:nil success:nil failure:nil]; id fetcher = [[HNKNetworkFetcher alloc] initWithURL:url]; - XCTAssertEqualObjects(_sut.hnk_fetcher.cacheKey, fetcher.cacheKey, @""); + XCTAssertEqualObjects(_sut.hnk_fetcher.key, fetcher.key, @""); UIImage *result = _sut.image; XCTAssertEqualObjects(result, previousImage, @""); }