Created
February 5, 2018 08:16
-
-
Save levantAJ/1693c6ed6f6352201fcf9105807c8879 to your computer and use it in GitHub Desktop.
Combination Tests
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
- (void)testCacheSnapshotCombinations { | |
for (int i = 0; i < 32; i++) { | |
@autoreleasepool { | |
//Given: | |
UIImage *snapshotImage = [UIImage new]; | |
id image = OCMClassMock([UIImage class]); | |
OCMStub([image imageForView:OCMOCK_ANY]).andReturn(snapshotImage); | |
if (i & (1 << 0)) { | |
self.sut.bounds = CGRectMake(0, 0, 123, 456); | |
} else { | |
self.sut.bounds = CGRectZero; | |
} | |
if (i & (1 << 1)) { | |
self.sut.attributedText = [[NSAttributedString alloc] init]; | |
} else { | |
self.sut.attributedText = nil; | |
} | |
if (i & (1 << 2)) { | |
self.sut.rawText = @"This is raw text"; | |
} else { | |
self.sut.rawText = @""; // or empty | |
} | |
if (i & (1 << 3)) { | |
OCMStub([self.cacher cachedImageForParameter:OCMOCK_ANY]).andReturn(nil); | |
} else { | |
OCMStub([self.cacher cachedImageForParameter:OCMOCK_ANY]).andReturn(snapshotImage); | |
} | |
if (i & (1 << 4)) { | |
OCMStub([self.service hasEmojisForString:OCMOCK_ANY]).andReturn(YES); | |
} else { | |
OCMStub([self.service hasEmojisForString:OCMOCK_ANY]).andReturn(NO); | |
} | |
if (i != 31) { | |
OCMReject([image imageForView:OCMOCK_ANY]); | |
OCMReject([self.cacher cacheImage:OCMOCK_ANY forParameter:OCMOCK_ANY]); | |
} | |
//When: | |
[self.sut cacheSnapshot]; | |
//Then: | |
if (i == 31) { | |
OCMVerify([image imageForView:self.sut]); | |
OCMVerify([self.cacher cacheImage:snapshotImage forParameter:OCMOCK_ANY]); | |
} | |
[image stopMocking]; | |
} | |
[self tearDown]; | |
[self setUp]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment